> 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/launchpad/reward_manager.gno.md).

# reward\_manager.gno

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

## Types

### RewardManager

```go
type RewardManager struct
```

RewardManager manages the distribution of rewards for a project tier.

This struct contains the necessary data and methods to calculate and track rewards for deposits associated with a project tier.

Fields:

* rewards (bptree.BPTree): A map of deposit IDs to their associated reward states.
* distributeAmountPerSecondX128 (u256.Uint): The amount of tokens to be distributed per second, represented as a Q128 fixed-point number.
* accumulatedRewardPerDepositX128 (u256.Uint): The accumulated reward per GNS stake, represented as a Q128 fixed-point number.
* totalDistributeAmount (int64): The total token allocation for this tier.
* totalClaimedAmount (int64): The total amount of tokens claimed.
* distributeStartTime (int64): The start time of the reward calculation.
* distributeEndTime (int64): The end time of the reward calculation.
* accumulatedDistributeAmount (int64): A legacy field not maintained by v1 reward accounting; normally zero unless explicitly set.
* rewardClaimableDuration (int64): The duration of reward claimable.

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L24)

#### Methods

**AccumulatedDistributeAmount**

```go
func (rm *RewardManager) AccumulatedDistributeAmount() int64
```

AccumulatedDistributeAmount returns the legacy reward-manager field. v1 reward paths do not maintain it, so normal reads return zero unless it was explicitly set.

#### Return Values

| Name     | Type  | Description                                                                                                                 |
| -------- | ----- | --------------------------------------------------------------------------------------------------------------------------- |
| `amount` | int64 | legacy accumulated distribution amount in token base units; v1 accounting normally leaves it at zero unless explicitly set. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L226)

**AccumulatedRewardPerDepositX128**

```go
func (rm *RewardManager) AccumulatedRewardPerDepositX128() *u256.Uint
```

AccumulatedRewardPerDepositX128 returns the accumulated reward per deposit (Q128) of the reward manager.

#### Return Values

| Name                              | Type        | Description                                                                |
| --------------------------------- | ----------- | -------------------------------------------------------------------------- |
| `accumulatedRewardPerDepositX128` | \*u256.Uint | accumulated reward index per deposited GNS unit in Q128 fixed-point units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L96)

**AccumulatedTime**

```go
func (rm *RewardManager) AccumulatedTime() int64
```

AccumulatedTime returns the accumulated time of the reward manager.

#### Return Values

| Name   | Type  | Description                                                                      |
| ------ | ----- | -------------------------------------------------------------------------------- |
| `time` | int64 | last reward-accumulation timestamp in Unix seconds, or zero before accumulation. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L243)

**ActiveClaimedAmount**

```go
func (rm *RewardManager) ActiveClaimedAmount() int64
```

ActiveClaimedAmount returns the reward amount claimed by currently active reward states.

#### Return Values

| Name     | Type  | Description                                       |
| -------- | ----- | ------------------------------------------------- |
| `amount` | int64 | active claimed reward amount in token base units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L160)

**ActiveDepositAmount**

```go
func (rm *RewardManager) ActiveDepositAmount() int64
```

ActiveDepositAmount returns the principal represented by currently active reward states.

#### Return Values

| Name     | Type  | Description                                   |
| -------- | ----- | --------------------------------------------- |
| `amount` | int64 | active deposited GNS principal in base units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L144)

**ActivePriceDebtX128**

```go
func (rm *RewardManager) ActivePriceDebtX128() *u256.Uint
```

ActivePriceDebtX128 returns the sum of active deposits' initial reward-index debts.

#### Return Values

| Name   | Type        | Description                                            |
| ------ | ----------- | ------------------------------------------------------ |
| `debt` | \*u256.Uint | aggregate active price debt in Q128 fixed-point units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L176)

**Clone**

```go
func (rm RewardManager) Clone() *RewardManager
```

Clone returns an independent copy of the reward manager, including its reward states and Q128 values.

#### Return Values

| Name            | Type            | Description                                                       |
| --------------- | --------------- | ----------------------------------------------------------------- |
| `rewardManager` | \*RewardManager | deep copy with a separate reward tree and mutable numeric values. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L275)

**DistributeAmountPerSecondX128**

```go
func (rm *RewardManager) DistributeAmountPerSecondX128() *u256.Uint
```

DistributeAmountPerSecondX128 returns the distribute amount per second (Q128) of the reward manager.

#### Return Values

| Name                  | Type        | Description                                                          |
| --------------------- | ----------- | -------------------------------------------------------------------- |
| `amountPerSecondX128` | \*u256.Uint | reward distribution rate in Q128 fixed-point token units per second. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L80)

**DistributeEndTime**

```go
func (rm *RewardManager) DistributeEndTime() int64
```

DistributeEndTime returns the distribute end time of the reward manager.

#### Return Values

| Name      | Type  | Description                                        |
| --------- | ----- | -------------------------------------------------- |
| `endTime` | int64 | reward distribution end timestamp in Unix seconds. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L208)

**DistributeStartTime**

```go
func (rm *RewardManager) DistributeStartTime() int64
```

DistributeStartTime returns the distribute start time of the reward manager.

#### Return Values

| Name        | Type  | Description                                          |
| ----------- | ----- | ---------------------------------------------------- |
| `startTime` | int64 | reward distribution start timestamp in Unix seconds. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L192)

**RemoveReward**

```go
func (rm *RewardManager) RemoveReward(
	depositID string
)
```

RemoveReward removes the reward state associated with a deposit ID.

#### Parameters

| Name        | Type   | Description                                       |
| ----------- | ------ | ------------------------------------------------- |
| `depositID` | string | deposit identifier whose reward state is removed. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L72)

**RewardClaimableDuration**

```go
func (rm *RewardManager) RewardClaimableDuration() int64
```

RewardClaimableDuration returns the reward claimable duration of the reward manager.

#### Return Values

| Name       | Type  | Description                                                                            |
| ---------- | ----- | -------------------------------------------------------------------------------------- |
| `duration` | int64 | time after a reward becomes claimable during which it remains collectible, in seconds. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L259)

**Rewards**

```go
func (rm *RewardManager) Rewards() *bptree.BPTree
```

Rewards returns the rewards tree of the reward manager.

#### Return Values

| Name      | Type            | Description                            |
| --------- | --------------- | -------------------------------------- |
| `rewards` | \*bptree.BPTree | reward-state tree keyed by deposit ID. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L47)

**SetAccumulatedDistributeAmount**

```go
func (rm *RewardManager) SetAccumulatedDistributeAmount(
	amount int64
)
```

SetAccumulatedDistributeAmount sets the legacy reward-manager field. It is not used by v1 reward accounting.

#### Parameters

| Name     | Type  | Description                                                                                           |
| -------- | ----- | ----------------------------------------------------------------------------------------------------- |
| `amount` | int64 | legacy accumulated distribution amount in token base units; v1 accounting does not update this field. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L235)

**SetAccumulatedRewardPerDepositX128**

```go
func (rm *RewardManager) SetAccumulatedRewardPerDepositX128(
	amount *u256.Uint
)
```

SetAccumulatedRewardPerDepositX128 sets the accumulated reward per deposit (Q128) of the reward manager.

#### Parameters

| Name     | Type        | Description                                                                                      |
| -------- | ----------- | ------------------------------------------------------------------------------------------------ |
| `amount` | \*u256.Uint | replacement accumulated reward-per-deposit index in Q128 fixed-point units; the value is copied. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L104)

**SetAccumulatedTime**

```go
func (rm *RewardManager) SetAccumulatedTime(
	time int64
)
```

SetAccumulatedTime sets the accumulated time of the reward manager.

#### Parameters

| Name   | Type  | Description                                         |
| ------ | ----- | --------------------------------------------------- |
| `time` | int64 | last reward-accumulation timestamp in Unix seconds. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L251)

**SetActiveClaimedAmount**

```go
func (rm *RewardManager) SetActiveClaimedAmount(
	amount int64
)
```

SetActiveClaimedAmount replaces the reward amount claimed by currently active reward states.

#### Parameters

| Name     | Type  | Description                                       |
| -------- | ----- | ------------------------------------------------- |
| `amount` | int64 | active claimed reward amount in token base units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L168)

**SetActiveDepositAmount**

```go
func (rm *RewardManager) SetActiveDepositAmount(
	amount int64
)
```

SetActiveDepositAmount replaces the principal represented by currently active reward states.

#### Parameters

| Name     | Type  | Description                                   |
| -------- | ----- | --------------------------------------------- |
| `amount` | int64 | active deposited GNS principal in base units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L152)

**SetActivePriceDebtX128**

```go
func (rm *RewardManager) SetActivePriceDebtX128(
	debt *u256.Uint
)
```

SetActivePriceDebtX128 replaces the aggregate active price-index debt.

#### Parameters

| Name   | Type        | Description                                                                 |
| ------ | ----------- | --------------------------------------------------------------------------- |
| `debt` | \*u256.Uint | aggregate active price debt in Q128 fixed-point units; the value is copied. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L184)

**SetDistributeAmountPerSecondX128**

```go
func (rm *RewardManager) SetDistributeAmountPerSecondX128(
	amount *u256.Uint
)
```

SetDistributeAmountPerSecondX128 sets the distribute amount per second (Q128) of the reward manager.

#### Parameters

| Name     | Type        | Description                                                                                           |
| -------- | ----------- | ----------------------------------------------------------------------------------------------------- |
| `amount` | \*u256.Uint | replacement reward distribution rate in Q128 fixed-point token units per second; the value is copied. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L88)

**SetDistributeEndTime**

```go
func (rm *RewardManager) SetDistributeEndTime(
	time int64
)
```

SetDistributeEndTime sets the distribute end time of the reward manager.

#### Parameters

| Name   | Type  | Description                                        |
| ------ | ----- | -------------------------------------------------- |
| `time` | int64 | reward distribution end timestamp in Unix seconds. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L216)

**SetDistributeStartTime**

```go
func (rm *RewardManager) SetDistributeStartTime(
	time int64
)
```

SetDistributeStartTime sets the distribute start time of the reward manager.

#### Parameters

| Name   | Type  | Description                                          |
| ------ | ----- | ---------------------------------------------------- |
| `time` | int64 | reward distribution start timestamp in Unix seconds. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L200)

**SetReward**

```go
func (rm *RewardManager) SetReward(
	depositID string,
	rewardState *RewardState
)
```

SetReward associates a reward state with a deposit ID in the manager's reward tree.

#### Parameters

| Name          | Type          | Description                                     |
| ------------- | ------------- | ----------------------------------------------- |
| `depositID`   | string        | deposit identifier used as the reward-tree key. |
| `rewardState` | \*RewardState | reward state to store for that deposit.         |

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

**SetRewardClaimableDuration**

```go
func (rm *RewardManager) SetRewardClaimableDuration(
	duration int64
)
```

SetRewardClaimableDuration sets the reward claimable duration of the reward manager.

#### Parameters

| Name       | Type  | Description                         |
| ---------- | ----- | ----------------------------------- |
| `duration` | int64 | claimable reward window in seconds. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L267)

**SetRewards**

```go
func (rm *RewardManager) SetRewards(
	rewards *bptree.BPTree
)
```

SetRewards sets the rewards tree of the reward manager.

#### Parameters

| Name      | Type            | Description                                |
| --------- | --------------- | ------------------------------------------ |
| `rewards` | \*bptree.BPTree | reward-state tree to use for this manager. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L55)

**SetTotalClaimedAmount**

```go
func (rm *RewardManager) SetTotalClaimedAmount(
	amount int64
)
```

SetTotalClaimedAmount sets the total claimed amount of the reward manager.

#### Parameters

| Name     | Type  | Description                                      |
| -------- | ----- | ------------------------------------------------ |
| `amount` | int64 | total claimed reward amount in token base units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L136)

**SetTotalDistributeAmount**

```go
func (rm *RewardManager) SetTotalDistributeAmount(
	amount int64
)
```

SetTotalDistributeAmount sets the total distribute amount of the reward manager.

#### Parameters

| Name     | Type  | Description                                               |
| -------- | ----- | --------------------------------------------------------- |
| `amount` | int64 | total reward allocation for the tier in token base units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L120)

**TotalClaimedAmount**

```go
func (rm *RewardManager) TotalClaimedAmount() int64
```

TotalClaimedAmount returns the total claimed amount of the reward manager.

#### Return Values

| Name     | Type  | Description                                                    |
| -------- | ----- | -------------------------------------------------------------- |
| `amount` | int64 | total reward amount claimed from the tier in token base units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L128)

**TotalDistributeAmount**

```go
func (rm *RewardManager) TotalDistributeAmount() int64
```

TotalDistributeAmount returns the total distribute amount of the reward manager.

#### Return Values

| Name     | Type  | Description                                               |
| -------- | ----- | --------------------------------------------------------- |
| `amount` | int64 | total reward allocation for the tier in token base units. |

[source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L112)

#### Constructors

* `func GetProjectTierRewardManager(projectTierId string) (*RewardManager, error)` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/getter.gno#L448))
* `func NewRewardManager(totalDistributeAmount int64, distributeStartTime int64, distributeEndTime int64, rewardCollectableDuration int64) *RewardManager` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/launchpad/reward_manager.gno#L313))
