> 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/staker/pool.gno.md).

# pool.gno

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

## Types

### ExternalIncentive

```go
type ExternalIncentive struct
```

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

#### Methods

**AccumulatedPenaltyAmount**

```go
func (e *ExternalIncentive) AccumulatedPenaltyAmount() int64
```

AccumulatedPenaltyAmount returns the accumulated warmup penalty amount

#### Return Values

| Name     | Type  | Description                                                             |
| -------- | ----- | ----------------------------------------------------------------------- |
| `amount` | int64 | Warm-up penalty accumulated from reward collections for this incentive. |

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

**Clone**

```go
func (e *ExternalIncentive) Clone() *ExternalIncentive
```

Clone returns an independent ExternalIncentive value with scalar fields copied and its fixed-point rate duplicated.

#### Return Values

| Name        | Type                | Description                                                                                                      |
| ----------- | ------------------- | ---------------------------------------------------------------------------------------------------------------- |
| `incentive` | \*ExternalIncentive | Copied external incentive record; its fixed-point rate is cloned when present and otherwise initialized to zero. |

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

**CreatedHeight**

```go
func (e *ExternalIncentive) CreatedHeight() int64
```

CreatedHeight returns the created height

#### Return Values

| Name     | Type  | Description                                             |
| -------- | ----- | ------------------------------------------------------- |
| `height` | int64 | Block height at which the incentive record was created. |

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

**CreatedTimestamp**

```go
func (e *ExternalIncentive) CreatedTimestamp() int64
```

CreatedTimestamp returns the created timestamp

#### Return Values

| Name        | Type  | Description                                                          |
| ----------- | ----- | -------------------------------------------------------------------- |
| `timestamp` | int64 | Unix timestamp in seconds at which the incentive record was created. |

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

**Creator**

```go
func (e *ExternalIncentive) Creator() address
```

Creator returns the creator address

#### Return Values

| Name      | Type    | Description                                    |
| --------- | ------- | ---------------------------------------------- |
| `creator` | address | Address that created and funded the incentive. |

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

**DepositGnsAmount**

```go
func (e *ExternalIncentive) DepositGnsAmount() int64
```

DepositGnsAmount returns the deposit GNS amount

#### Return Values

| Name     | Type  | Description                                           |
| -------- | ----- | ----------------------------------------------------- |
| `amount` | int64 | GNS amount deposited to back this external incentive. |

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

**DistributedRewardAmount**

```go
func (e *ExternalIncentive) DistributedRewardAmount() int64
```

DistributedRewardAmount returns the distributed reward amount

#### Return Values

| Name     | Type  | Description                                                                |
| -------- | ----- | -------------------------------------------------------------------------- |
| `amount` | int64 | Reward amount already delivered to positions or refunded at incentive end. |

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

**EndTimestamp**

```go
func (e *ExternalIncentive) EndTimestamp() int64
```

EndTimestamp returns the end timestamp

#### Return Values

| Name        | Type  | Description                                                   |
| ----------- | ----- | ------------------------------------------------------------- |
| `timestamp` | int64 | Unix timestamp in seconds at which the incentive window ends. |

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

**IncentiveId**

```go
func (e *ExternalIncentive) IncentiveId() string
```

IncentiveId returns the incentive ID

#### Return Values

| Name | Type   | Description                                     |
| ---- | ------ | ----------------------------------------------- |
| `id` | string | Identifier assigned to this external incentive. |

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

**Refunded**

```go
func (e *ExternalIncentive) Refunded() bool
```

Refunded returns the refunded status

#### Return Values

| Name       | Type | Description                                                                      |
| ---------- | ---- | -------------------------------------------------------------------------------- |
| `refunded` | bool | True when incentive finalization has marked its refundable balances as returned. |

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

**RewardAmount**

```go
func (e *ExternalIncentive) RewardAmount() int64
```

RewardAmount returns the reward amount

#### Return Values

| Name     | Type  | Description                                                      |
| -------- | ----- | ---------------------------------------------------------------- |
| `amount` | int64 | Mutable reward amount remaining after distributions and refunds. |

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

**RewardPerSecondX128**

```go
func (e *ExternalIncentive) RewardPerSecondX128() *u256.Uint
```

RewardPerSecondX128 returns the Q128-scaled reward per second. The underlying value is (rewardAmount << 128) / duration.

#### Return Values

| Name   | Type        | Description                                                            |
| ------ | ----------- | ---------------------------------------------------------------------- |
| `rate` | \*u256.Uint | Reward emitted per second, scaled by 2^128 for fixed-point accounting. |

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

**RewardToken**

```go
func (e *ExternalIncentive) RewardToken() string
```

RewardToken returns the reward token

#### Return Values

| Name    | Type   | Description                                      |
| ------- | ------ | ------------------------------------------------ |
| `token` | string | Reward-token path distributed by this incentive. |

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

**SetAccumulatedPenaltyAmount**

```go
func (e *ExternalIncentive) SetAccumulatedPenaltyAmount(
	accumulatedPenaltyAmount int64
)
```

SetAccumulatedPenaltyAmount sets the accumulated warmup penalty amount

#### Parameters

| Name                       | Type  | Description                                                                |
| -------------------------- | ----- | -------------------------------------------------------------------------- |
| `accumulatedPenaltyAmount` | int64 | Warm-up penalty amount to store in the incentive's accumulated accounting. |

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

**SetCreatedHeight**

```go
func (e *ExternalIncentive) SetCreatedHeight(
	createdHeight int64
)
```

SetCreatedHeight sets the created height

#### Parameters

| Name            | Type  | Description                                                |
| --------------- | ----- | ---------------------------------------------------------- |
| `createdHeight` | int64 | Block height to record as the incentive's creation height. |

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

**SetCreatedTimestamp**

```go
func (e *ExternalIncentive) SetCreatedTimestamp(
	createdTimestamp int64
)
```

SetCreatedTimestamp sets the created timestamp

#### Parameters

| Name               | Type  | Description                                                         |
| ------------------ | ----- | ------------------------------------------------------------------- |
| `createdTimestamp` | int64 | Unix timestamp in seconds to record as the incentive creation time. |

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

**SetCreator**

```go
func (e *ExternalIncentive) SetCreator(
	creator address
)
```

SetCreator sets the creator address

#### Parameters

| Name      | Type    | Description                                                      |
| --------- | ------- | ---------------------------------------------------------------- |
| `creator` | address | Address to record as the incentive creator and refund recipient. |

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

**SetDepositGnsAmount**

```go
func (e *ExternalIncentive) SetDepositGnsAmount(
	depositGnsAmount int64
)
```

SetDepositGnsAmount sets the deposit GNS amount

#### Parameters

| Name               | Type  | Description                                           |
| ------------------ | ----- | ----------------------------------------------------- |
| `depositGnsAmount` | int64 | GNS amount deposited to back this external incentive. |

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

**SetDistributedRewardAmount**

```go
func (e *ExternalIncentive) SetDistributedRewardAmount(
	distributedRewardAmount int64
)
```

SetDistributedRewardAmount sets the distributed reward amount

#### Parameters

| Name                      | Type  | Description                                                        |
| ------------------------- | ----- | ------------------------------------------------------------------ |
| `distributedRewardAmount` | int64 | Reward amount delivered to positions or refunded at incentive end. |

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

**SetEndTimestamp**

```go
func (e *ExternalIncentive) SetEndTimestamp(
	endTimestamp int64
)
```

SetEndTimestamp sets the end timestamp

#### Parameters

| Name           | Type  | Description                                                   |
| -------------- | ----- | ------------------------------------------------------------- |
| `endTimestamp` | int64 | Unix timestamp in seconds at which the incentive window ends. |

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

**SetIncentiveId**

```go
func (e *ExternalIncentive) SetIncentiveId(
	incentiveId string
)
```

SetIncentiveId sets the incentive ID

#### Parameters

| Name          | Type   | Description                                  |
| ------------- | ------ | -------------------------------------------- |
| `incentiveId` | string | Identifier to store on the incentive record. |

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

**SetRefunded**

```go
func (e *ExternalIncentive) SetRefunded(
	refunded bool
)
```

SetRefunded sets the refunded status

#### Parameters

| Name       | Type | Description                                     |
| ---------- | ---- | ----------------------------------------------- |
| `refunded` | bool | Finalization status to store for the incentive. |

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

**SetRewardAmount**

```go
func (e *ExternalIncentive) SetRewardAmount(
	rewardAmount int64
)
```

SetRewardAmount sets the reward amount

#### Parameters

| Name           | Type  | Description                                                    |
| -------------- | ----- | -------------------------------------------------------------- |
| `rewardAmount` | int64 | Remaining reward amount to store after accounting adjustments. |

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

**SetRewardPerSecondX128**

```go
func (e *ExternalIncentive) SetRewardPerSecondX128(
	rewardPerSecondX128 *u256.Uint
)
```

SetRewardPerSecondX128 sets the Q128-scaled reward per second.

#### Parameters

| Name                  | Type        | Description                                                             |
| --------------------- | ----------- | ----------------------------------------------------------------------- |
| `rewardPerSecondX128` | \*u256.Uint | Q128-scaled per-second reward rate; the value is copied before storage. |

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

**SetRewardToken**

```go
func (e *ExternalIncentive) SetRewardToken(
	rewardToken string
)
```

SetRewardToken sets the reward token

#### Parameters

| Name          | Type   | Description                                                   |
| ------------- | ------ | ------------------------------------------------------------- |
| `rewardToken` | string | Token path of the reward asset distributed by this incentive. |

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

**SetTargetPoolPath**

```go
func (e *ExternalIncentive) SetTargetPoolPath(
	targetPoolPath string
)
```

SetTargetPoolPath sets the target pool path

#### Parameters

| Name             | Type   | Description                                       |
| ---------------- | ------ | ------------------------------------------------- |
| `targetPoolPath` | string | Pool path to target with this external incentive. |

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

**SetTotalRewardAmount**

```go
func (e *ExternalIncentive) SetTotalRewardAmount(
	totalRewardAmount int64
)
```

SetTotalRewardAmount sets the total reward amount

#### Parameters

| Name                | Type  | Description                                      |
| ------------------- | ----- | ------------------------------------------------ |
| `totalRewardAmount` | int64 | Total reward amount to record for the incentive. |

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

**SetUnclaimableSeconds**

```go
func (e *ExternalIncentive) SetUnclaimableSeconds(
	unclaimableSeconds int64
)
```

SetUnclaimableSeconds sets the accumulated unclaimable seconds.

#### Parameters

| Name                 | Type  | Description                                           |
| -------------------- | ----- | ----------------------------------------------------- |
| `unclaimableSeconds` | int64 | Overlapping unclaimable duration in seconds to store. |

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

**StartTimestamp**

```go
func (e *ExternalIncentive) StartTimestamp() int64
```

StartTimestamp returns the start timestamp.

It keys the byStartTime discovery index and must stay immutable after the incentive is registered, so no setter is exposed.

#### Return Values

| Name        | Type  | Description                                                    |
| ----------- | ----- | -------------------------------------------------------------- |
| `timestamp` | int64 | Unix timestamp in seconds at which reward distribution starts. |

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

**TargetPoolPath**

```go
func (e *ExternalIncentive) TargetPoolPath() string
```

TargetPoolPath returns the target pool path

#### Return Values

| Name   | Type   | Description                                    |
| ------ | ------ | ---------------------------------------------- |
| `path` | string | Pool path targeted by this external incentive. |

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

**TotalRewardAmount**

```go
func (e *ExternalIncentive) TotalRewardAmount() int64
```

TotalRewardAmount returns the total reward amount

#### Return Values

| Name     | Type  | Description                                                    |
| -------- | ----- | -------------------------------------------------------------- |
| `amount` | int64 | Total reward amount configured when the incentive was created. |

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

**UnclaimableSeconds**

```go
func (e *ExternalIncentive) UnclaimableSeconds() int64
```

UnclaimableSeconds returns the accumulated seconds of unclaimable periods that overlap the incentive window. It is updated whenever an unclaimable period closes and is backfilled once from the historical unclaimable periods tree after an upgrade.

#### Return Values

| Name      | Type  | Description                                                                  |
| --------- | ----- | ---------------------------------------------------------------------------- |
| `seconds` | int64 | Accumulated seconds of unclaimable periods overlapping the incentive window. |

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

#### Constructors

* `func GetExternalIncentiveByPoolPath(poolPath string) ([]ExternalIncentive, error)` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/getter.gno#L379))
* `func NewExternalIncentive(incentiveId string, targetPoolPath string, rewardToken string, rewardAmount int64, startTimestamp int64, endTimestamp int64, creator address, depositGnsAmount int64, createdHeight int64, currentTime int64) *ExternalIncentive` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L886))

### Incentives

```go
type Incentives struct
```

Incentives represents a collection of external incentives for a specific pool.

Fields:

* incentives: BPTree storing ExternalIncentive objects indexed by incentiveId The incentiveId serves as the key to efficiently lookup incentive details
* targetPoolPath: String identifier for the pool this incentive collection belongs to Used to associate incentives with their corresponding liquidity pool
* unclaimablePeriods: Tree storing periods when rewards cannot be claimed Maps start timestamp (key) to end timestamp (value) An end timestamp of 0 indicates an ongoing unclaimable period Used to track intervals when staking rewards are not claimable
* byStartTime: Per-pool start-time index mapping an incentive's start timestamp (key) to the incentive IDs that start at that timestamp (value). This mirrors the lazy-discovery lookup previously served by a global creation-time index, but scoped to this pool's own incentives, so discovery cost is bounded by this pool's incentives instead of growing with the total number of incentives system-wide.

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

#### Methods

**AddIncentiveByStartTime**

```go
func (i *Incentives) AddIncentiveByStartTime(
	startTimestamp int64,
	incentiveId string
)
```

AddIncentiveByStartTime registers an incentive ID under its start timestamp in the per-pool start-time index. Multiple incentives starting at the same timestamp are accumulated as a list.

#### Parameters

| Name             | Type   | Description                                                             |
| ---------------- | ------ | ----------------------------------------------------------------------- |
| `startTimestamp` | int64  | Nonnegative Unix timestamp in seconds used as the start-time index key. |
| `incentiveId`    | string | Incentive identifier to append to that timestamp's bucket.              |

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

**Incentive**

```go
func (i *Incentives) Incentive(
	incentiveId string
) (*ExternalIncentive, bool)
```

Incentive returns an incentive by ID

#### Parameters

| Name          | Type   | Description                                               |
| ------------- | ------ | --------------------------------------------------------- |
| `incentiveId` | string | Identifier used to look up the external incentive record. |

#### Return Values

| Name        | Type                | Description                                                                                          |
| ----------- | ------------------- | ---------------------------------------------------------------------------------------------------- |
| `incentive` | \*ExternalIncentive | Matching ExternalIncentive pointer, or nil when no value is stored for incentiveId.                  |
| `found`     | bool                | True only when the stored value has ExternalIncentive type; false for a missing or mismatched value. |

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

**IncentiveTrees**

```go
func (i *Incentives) IncentiveTrees() *bptree.BPTree
```

Incentives returns the incentives tree

#### Return Values

| Name   | Type            | Description                                                         |
| ------ | --------------- | ------------------------------------------------------------------- |
| `tree` | \*bptree.BPTree | Mutable B+ tree mapping incentive IDs to ExternalIncentive records. |

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

**IterateIncentiveIdsByTime**

```go
func (i *Incentives) IterateIncentiveIdsByTime(
	startTime int64,
	endTime int64,
	fn func(string) bool
)
```

IterateIncentiveIdsByTime iterates over the incentive IDs that start within the inclusive \[startTime, endTime] range, visiting only the buckets that fall in the range. ReverseIterate is used because it is inclusive on both ends, matching the discovery semantics previously implemented as (startTimestamp >= startTime && startTimestamp <= endTime).

#### Parameters

| Name        | Type              | Description                                                                                 |
| ----------- | ----------------- | ------------------------------------------------------------------------------------------- |
| `startTime` | int64             | Inclusive lower Unix timestamp bound for incentive starts.                                  |
| `endTime`   | int64             | Inclusive upper Unix timestamp bound for incentive starts.                                  |
| `fn`        | func(string) bool | Callback receiving each matching incentive ID; returning true requests that iteration stop. |

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

**IterateIncentives**

```go
func (i *Incentives) IterateIncentives(
	fn func(string, *ExternalIncentive) bool
)
```

IterateIncentives iterates over all incentives

#### Parameters

| Name | Type                                   | Description                                                                                   |
| ---- | -------------------------------------- | --------------------------------------------------------------------------------------------- |
| `fn` | func(string, \*ExternalIncentive) bool | Callback receiving each incentive ID and record; returning true requests that iteration stop. |

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

**RemoveIncentive**

```go
func (i *Incentives) RemoveIncentive(
	incentiveId string
)
```

RemoveIncentive deletes an incentive by ID.

Only an incentive that never started may be removed: once rewards begin accruing, deposits and the refund accounting reference the record, so an ended incentive is marked refunded instead of removed.

#### Parameters

| Name          | Type   | Description                                            |
| ------------- | ------ | ------------------------------------------------------ |
| `incentiveId` | string | Identifier of the external incentive record to remove. |

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

**RemoveIncentiveByStartTime**

```go
func (i *Incentives) RemoveIncentiveByStartTime(
	startTimestamp int64,
	incentiveId string
)
```

RemoveIncentiveByStartTime unregisters an incentive ID from the per-pool start-time index. The bucket itself is dropped once its last ID is removed, so the index never keeps an empty entry that discovery would still visit.

#### Parameters

| Name             | Type   | Description                                                                        |
| ---------------- | ------ | ---------------------------------------------------------------------------------- |
| `startTimestamp` | int64  | Nonnegative Unix timestamp in seconds identifying the start-time bucket.           |
| `incentiveId`    | string | Incentive identifier to remove from that bucket; all matching entries are omitted. |

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

**RemoveUnclaimablePeriod**

```go
func (i *Incentives) RemoveUnclaimablePeriod(
	startTimestamp int64
)
```

RemoveUnclaimablePeriod removes the interval keyed by its start timestamp.

#### Parameters

| Name             | Type  | Description                                                               |
| ---------------- | ----- | ------------------------------------------------------------------------- |
| `startTimestamp` | int64 | Nonnegative Unix timestamp in seconds identifying the interval to remove. |

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

**SetIncentive**

```go
func (i *Incentives) SetIncentive(
	incentiveId string,
	incentive *ExternalIncentive
)
```

SetIncentive sets an incentive by ID

#### Parameters

| Name          | Type                | Description                                        |
| ------------- | ------------------- | -------------------------------------------------- |
| `incentiveId` | string              | Identifier under which to store the incentive.     |
| `incentive`   | \*ExternalIncentive | ExternalIncentive record to store for incentiveId. |

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

**SetIncentives**

```go
func (i *Incentives) SetIncentives(
	incentives *bptree.BPTree
)
```

SetIncentives sets the incentives tree

#### Parameters

| Name         | Type            | Description                                          |
| ------------ | --------------- | ---------------------------------------------------- |
| `incentives` | \*bptree.BPTree | B+ tree to use for incentive ID lookups and storage. |

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

**SetTargetPoolPath**

```go
func (i *Incentives) SetTargetPoolPath(
	targetPoolPath string
)
```

SetTargetPoolPath sets the target pool path

#### Parameters

| Name             | Type   | Description                                            |
| ---------------- | ------ | ------------------------------------------------------ |
| `targetPoolPath` | string | Pool path to associate with this incentive collection. |

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

**SetUnclaimablePeriod**

```go
func (i *Incentives) SetUnclaimablePeriod(
	startTimestamp int64,
	endTimestamp int64
)
```

SetUnclaimablePeriod records an interval during which staking rewards cannot be claimed.

#### Parameters

| Name             | Type  | Description                                                                          |
| ---------------- | ----- | ------------------------------------------------------------------------------------ |
| `startTimestamp` | int64 | Nonnegative Unix timestamp in seconds at which the interval begins.                  |
| `endTimestamp`   | int64 | Unix timestamp in seconds at which the interval ends; 0 records an ongoing interval. |

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

**SetUnclaimablePeriods**

```go
func (i *Incentives) SetUnclaimablePeriods(
	unclaimablePeriods *UintTree
)
```

SetUnclaimablePeriods sets the unclaimable periods tree

#### Parameters

| Name                 | Type       | Description                                                           |
| -------------------- | ---------- | --------------------------------------------------------------------- |
| `unclaimablePeriods` | \*UintTree | Tree of reward-unclaimable intervals keyed by their start timestamps. |

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

**TargetPoolPath**

```go
func (i *Incentives) TargetPoolPath() string
```

TargetPoolPath returns the target pool path

#### Return Values

| Name   | Type   | Description                                           |
| ------ | ------ | ----------------------------------------------------- |
| `path` | string | Pool path to which this incentive collection belongs. |

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

**UnclaimablePeriods**

```go
func (i *Incentives) UnclaimablePeriods() *UintTree
```

UnclaimablePeriods returns the unclaimable periods tree

#### Return Values

| Name      | Type       | Description                                                                                       |
| --------- | ---------- | ------------------------------------------------------------------------------------------------- |
| `periods` | \*UintTree | Tree mapping unclaimable-period start timestamps to end timestamps; end 0 denotes an open period. |

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

#### Constructors

* `func NewIncentives(targetPoolPath string) *Incentives` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L547))

### Pool

```go
type Pool struct
```

Pool is a struct for storing an incentivized pool information Each pool stores Incentives and Ticks associated with it.

Fields:

* poolPath: The path of the pool.
  * stakedLiquidity: The current total staked liquidity of the in-range positions for the pool. Updated when tick cross happens or stake/unstake happens. Used to calculate the global reward ratio accumulation or decide whether to enter/exit unclaimable period.
  * lastUnclaimableTime: The time at which the unclaimable period started. Set to 0 when the pool is not in an unclaimable period.
  * unclaimableAcc: The accumulated undistributed unclaimable reward. Reset to 0 when processUnclaimableReward is called and sent to community pool.
  * rewardCache: The cached per-second reward emitted for this pool. Stores new entry only when the reward is changed. PoolTier.cacheReward() updates this.
* incentives: The external incentives associated with the pool.
* ticks: The Ticks associated with the pool.
  * globalRewardRatioAccumulation: Global ratio of Time / TotalStake accumulation(since the pool creation) Stores new entry only when tick cross or stake/unstake happens. It is used to calculate the reward for a staked position at certain time.
  * historicalTick: The historical tick for the pool at a given time. It does not reflect the exact tick at the timestamp, but it provides correct ordering for the staked position's ticks. Therefore, you should not compare it for equality, only for ordering. Set when tick cross happens or a new position is created.

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

#### Methods

**Clone**

```go
func (p *Pool) Clone() *Pool
```

Clone returns a pool copy of the scalar state with a fresh tick container.

#### Return Values

| Name   | Type   | Description                                                                                                                    |
| ------ | ------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `pool` | \*Pool | Pool copy carrying scalar state and a fresh tick container; backing trees and incentives are nil, and nil receiver yields nil. |

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

**GlobalRewardRatioAccumulation**

```go
func (p *Pool) GlobalRewardRatioAccumulation() *UintTree
```

GlobalRewardRatioAccumulation returns the global reward ratio accumulation tree

#### Return Values

| Name   | Type       | Description                                                                  |
| ------ | ---------- | ---------------------------------------------------------------------------- |
| `tree` | \*UintTree | Historical global time-per-total-stake accumulation keyed by Unix timestamp. |

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

**HistoricalTick**

```go
func (p *Pool) HistoricalTick() *UintTree
```

HistoricalTick returns the historical tick tree

#### Return Values

| Name   | Type       | Description                                                    |
| ------ | ---------- | -------------------------------------------------------------- |
| `tree` | \*UintTree | Historical tick-ID ordering snapshots keyed by Unix timestamp. |

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

**Incentives**

```go
func (p *Pool) Incentives() *Incentives
```

Incentives returns the incentives

#### Return Values

| Name         | Type         | Description                                              |
| ------------ | ------------ | -------------------------------------------------------- |
| `incentives` | \*Incentives | External-incentive collection associated with this pool. |

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

**LastUnclaimableTime**

```go
func (p *Pool) LastUnclaimableTime() int64
```

LastUnclaimableTime returns the last unclaimable time

#### Return Values

| Name        | Type  | Description                                                                                                             |
| ----------- | ----- | ----------------------------------------------------------------------------------------------------------------------- |
| `timestamp` | int64 | Unix timestamp in seconds at which the pool entered its current unclaimable period, or 0 when tracking has not started. |

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

**PoolPath**

```go
func (p *Pool) PoolPath() string
```

PoolPath returns the pool path

#### Return Values

| Name   | Type   | Description                                                         |
| ------ | ------ | ------------------------------------------------------------------- |
| `path` | string | Pool identifier used to associate this state with a liquidity pool. |

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

**RewardCache**

```go
func (p *Pool) RewardCache() *UintTree
```

RewardCache returns the reward cache tree

#### Return Values

| Name   | Type       | Description                                                     |
| ------ | ---------- | --------------------------------------------------------------- |
| `tree` | \*UintTree | Historical per-second GNS reward cache keyed by Unix timestamp. |

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

**SetGlobalRewardRatioAccumulation**

```go
func (p *Pool) SetGlobalRewardRatioAccumulation(
	globalRewardRatioAccumulation *UintTree
)
```

SetGlobalRewardRatioAccumulation sets the global reward ratio accumulation tree

#### Parameters

| Name                            | Type       | Description                                                         |
| ------------------------------- | ---------- | ------------------------------------------------------------------- |
| `globalRewardRatioAccumulation` | \*UintTree | Tree of serialized Q128-scaled reward-ratio accumulation snapshots. |

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

**SetGlobalRewardRatioAccumulationAt**

```go
func (p *Pool) SetGlobalRewardRatioAccumulationAt(
	currentTime int64,
	acc string
)
```

SetGlobalRewardRatioAccumulationAt records a serialized global reward-ratio accumulation snapshot.

#### Parameters

| Name          | Type   | Description                                                     |
| ------------- | ------ | --------------------------------------------------------------- |
| `currentTime` | int64  | Nonnegative Unix timestamp in seconds used as the snapshot key. |
| `acc`         | string | Serialized Q128-scaled global reward-ratio accumulation value.  |

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

**SetHistoricalTick**

```go
func (p *Pool) SetHistoricalTick(
	historicalTick *UintTree
)
```

SetHistoricalTick sets the historical tick tree

#### Parameters

| Name             | Type       | Description                                                             |
| ---------------- | ---------- | ----------------------------------------------------------------------- |
| `historicalTick` | \*UintTree | Tree of tick IDs representing the ordering history of staked positions. |

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

**SetHistoricalTickAt**

```go
func (p *Pool) SetHistoricalTickAt(
	currentTime int64,
	tick int32
)
```

SetHistoricalTickAt records the tick ordering snapshot for a timestamp.

#### Parameters

| Name          | Type  | Description                                                         |
| ------------- | ----- | ------------------------------------------------------------------- |
| `currentTime` | int64 | Nonnegative Unix timestamp in seconds used as the snapshot key.     |
| `tick`        | int32 | Tick ID representing the pool's historical ordering at currentTime. |

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

**SetIncentives**

```go
func (p *Pool) SetIncentives(
	incentives *Incentives
)
```

SetIncentives sets the incentives

#### Parameters

| Name         | Type         | Description                                               |
| ------------ | ------------ | --------------------------------------------------------- |
| `incentives` | \*Incentives | External-incentive collection to associate with the pool. |

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

**SetLastUnclaimableTime**

```go
func (p *Pool) SetLastUnclaimableTime(
	lastUnclaimableTime int64
)
```

SetLastUnclaimableTime sets the last unclaimable time

#### Parameters

| Name                  | Type  | Description                                                                                                    |
| --------------------- | ----- | -------------------------------------------------------------------------------------------------------------- |
| `lastUnclaimableTime` | int64 | Unix timestamp in seconds marking the start of the current unclaimable period; use 0 when no period is active. |

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

**SetPoolPath**

```go
func (p *Pool) SetPoolPath(
	poolPath string
)
```

SetPoolPath sets the pool path

#### Parameters

| Name       | Type   | Description               |
| ---------- | ------ | ------------------------- |
| `poolPath` | string | Pool identifier to store. |

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

**SetRewardCache**

```go
func (p *Pool) SetRewardCache(
	rewardCache *UintTree
)
```

SetRewardCache sets the reward cache tree

#### Parameters

| Name          | Type       | Description                                                 |
| ------------- | ---------- | ----------------------------------------------------------- |
| `rewardCache` | \*UintTree | Tree containing the pool's per-second GNS reward snapshots. |

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

**SetRewardCacheAt**

```go
func (p *Pool) SetRewardCacheAt(
	currentTime int64,
	reward int64
)
```

SetRewardCacheAt records the per-second reward rate for a timestamp.

#### Parameters

| Name          | Type  | Description                                                                  |
| ------------- | ----- | ---------------------------------------------------------------------------- |
| `currentTime` | int64 | Nonnegative Unix timestamp in seconds used as the cache key.                 |
| `reward`      | int64 | GNS reward emitted per second from currentTime until the next cached change. |

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

**SetStakedLiquidity**

```go
func (p *Pool) SetStakedLiquidity(
	stakedLiquidity *UintTree
)
```

SetStakedLiquidity sets the staked liquidity tree

#### Parameters

| Name              | Type       | Description                                          |
| ----------------- | ---------- | ---------------------------------------------------- |
| `stakedLiquidity` | \*UintTree | Tree of historical total staked liquidity snapshots. |

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

**SetStakedLiquidityAt**

```go
func (p *Pool) SetStakedLiquidityAt(
	currentTime int64,
	delta *u256.Uint
)
```

SetStakedLiquidityAt records the current total staked liquidity at a timestamp.

#### Parameters

| Name          | Type        | Description                                                                       |
| ------------- | ----------- | --------------------------------------------------------------------------------- |
| `currentTime` | int64       | Nonnegative Unix timestamp in seconds used as the snapshot key.                   |
| `delta`       | \*u256.Uint | Total staked liquidity at currentTime, stored as a copied Q128-scaled uint value. |

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

**SetTicks**

```go
func (p *Pool) SetTicks(
	ticks Ticks
)
```

SetTicks sets the ticks

#### Parameters

| Name    | Type  | Description                              |
| ------- | ----- | ---------------------------------------- |
| `ticks` | Ticks | Tick mapping value to store in the pool. |

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

**SetUnclaimableAcc**

```go
func (p *Pool) SetUnclaimableAcc(
	unclaimableAcc int64
)
```

SetUnclaimableAcc sets the unclaimable accumulation

#### Parameters

| Name             | Type  | Description                                                                           |
| ---------------- | ----- | ------------------------------------------------------------------------------------- |
| `unclaimableAcc` | int64 | Accumulated undistributed unclaimable reward amount in the pool's int64 reward units. |

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

**StakedLiquidity**

```go
func (p *Pool) StakedLiquidity() *UintTree
```

StakedLiquidity returns the staked liquidity tree

#### Return Values

| Name   | Type       | Description                                                                                  |
| ------ | ---------- | -------------------------------------------------------------------------------------------- |
| `tree` | \*UintTree | Historical staked-liquidity tree keyed by Unix timestamp, with Q128-scaled liquidity values. |

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

**Ticks**

```go
func (p *Pool) Ticks() *Ticks
```

Ticks returns the ticks

#### Return Values

| Name    | Type    | Description                                                |
| ------- | ------- | ---------------------------------------------------------- |
| `ticks` | \*Ticks | Addressable tick mapping for this pool's staked positions. |

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

**UnclaimableAcc**

```go
func (p *Pool) UnclaimableAcc() int64
```

UnclaimableAcc returns the unclaimable accumulation

#### Return Values

| Name     | Type  | Description                                                                           |
| -------- | ----- | ------------------------------------------------------------------------------------- |
| `amount` | int64 | Accumulated undistributed unclaimable reward amount in the pool's int64 reward units. |

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

#### Constructors

* `func GetPool(poolPath string) (*Pool, error)` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/getter.gno#L18))
* `func NewPool(poolPath string, currentTime int64) *Pool` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L288))

### SwapBatchProcessor

```go
type SwapBatchProcessor struct
```

SwapBatchProcessor processes tick crosses in batch for a swap This processor accumulates all tick crosses that occur during a single swap and processes them together at the end, reducing redundant calculations and state updates that would occur with individual tick processing

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

#### Methods

**AddCross**

```go
func (s *SwapBatchProcessor) AddCross(
	tickCross *SwapTickCross
)
```

AddCross appends a tick-cross record to the batch sequence.

#### Parameters

| Name        | Type            | Description                  |
| ----------- | --------------- | ---------------------------- |
| `tickCross` | \*SwapTickCross | Tick-cross record to append. |

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

**Crosses**

```go
func (s *SwapBatchProcessor) Crosses() []*SwapTickCross
```

Crosses returns the tick crosses accumulated by this batch.

#### Return Values

| Name      | Type               | Description                                               |
| --------- | ------------------ | --------------------------------------------------------- |
| `crosses` | \[]\*SwapTickCross | Slice of tick-cross records in the order they were added. |

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

**IsActive**

```go
func (s *SwapBatchProcessor) IsActive() bool
```

IsActive reports the processor's stored active flag.

#### Return Values

| Name     | Type | Description                                                  |
| -------- | ---- | ------------------------------------------------------------ |
| `active` | bool | True when the batch is marked active for the swap lifecycle. |

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

**LastCross**

```go
func (s *SwapBatchProcessor) LastCross() *SwapTickCross
```

LastCross returns the most recently appended tick cross.

#### Return Values

| Name    | Type            | Description                                                     |
| ------- | --------------- | --------------------------------------------------------------- |
| `cross` | \*SwapTickCross | Last tick-cross record, or nil when no crosses have been added. |

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

**Pool**

```go
func (s *SwapBatchProcessor) Pool() *Pool
```

Pool returns the pool referenced by this swap batch.

#### Return Values

| Name   | Type   | Description                                              |
| ------ | ------ | -------------------------------------------------------- |
| `pool` | \*Pool | Pool state used to process the accumulated tick crosses. |

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

**PoolPath**

```go
func (s *SwapBatchProcessor) PoolPath() string
```

PoolPath returns the pool path associated with this swap batch.

#### Return Values

| Name   | Type   | Description                                   |
| ------ | ------ | --------------------------------------------- |
| `path` | string | Pool identifier for the swap being processed. |

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

**SetCrosses**

```go
func (s *SwapBatchProcessor) SetCrosses(
	crosses []*SwapTickCross
)
```

SetCrosses replaces the batch's accumulated tick-cross sequence.

#### Parameters

| Name      | Type               | Description                                                      |
| --------- | ------------------ | ---------------------------------------------------------------- |
| `crosses` | \[]\*SwapTickCross | Tick-cross records to store as the batch's accumulated sequence. |

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

**SetIsActive**

```go
func (s *SwapBatchProcessor) SetIsActive(
	isActive bool
)
```

SetIsActive stores the processor's active lifecycle flag.

#### Parameters

| Name       | Type | Description                                  |
| ---------- | ---- | -------------------------------------------- |
| `isActive` | bool | Active flag to store for the swap lifecycle. |

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

**SetPool**

```go
func (s *SwapBatchProcessor) SetPool(
	pool *Pool
)
```

SetPool replaces the pool reference used by this swap batch.

#### Parameters

| Name   | Type   | Description                                            |
| ------ | ------ | ------------------------------------------------------ |
| `pool` | \*Pool | Pool state to reference while processing tick crosses. |

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

**SetPoolPath**

```go
func (s *SwapBatchProcessor) SetPoolPath(
	poolPath string
)
```

SetPoolPath stores the pool identifier associated with this swap batch.

#### Parameters

| Name       | Type   | Description                                       |
| ---------- | ------ | ------------------------------------------------- |
| `poolPath` | string | Pool identifier to associate with the swap batch. |

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

**SetTimestamp**

```go
func (s *SwapBatchProcessor) SetTimestamp(
	timestamp int64
)
```

SetTimestamp stores the swap-start timestamp for this batch.

#### Parameters

| Name        | Type  | Description                                             |
| ----------- | ----- | ------------------------------------------------------- |
| `timestamp` | int64 | Unix timestamp in seconds to record for the swap batch. |

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

**Timestamp**

```go
func (s *SwapBatchProcessor) Timestamp() int64
```

Timestamp returns the Unix timestamp in seconds recorded when the swap started.

#### Return Values

| Name        | Type  | Description                           |
| ----------- | ----- | ------------------------------------- |
| `timestamp` | int64 | Swap-start timestamp in Unix seconds. |

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

#### Constructors

* `func NewSwapBatchProcessor(poolPath string, pool *Pool, timestamp int64) *SwapBatchProcessor` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L1338))

### SwapTickCross

```go
type SwapTickCross struct
```

SwapTickCross stores information about a tick cross during a swap This struct is used to accumulate tick cross events during a single swap transaction for batch processing to optimize gas usage and computational efficiency

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

#### Methods

**Delta**

```go
func (s *SwapTickCross) Delta() *i256.Int
```

Delta returns the precomputed net staked-liquidity change for the crossed tick.

#### Return Values

| Name    | Type       | Description                                          |
| ------- | ---------- | ---------------------------------------------------- |
| `delta` | \*i256.Int | Signed liquidity delta to apply at the crossed tick. |

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

**TickID**

```go
func (s *SwapTickCross) TickID() int32
```

TickID returns the index of the crossed tick.

#### Return Values

| Name     | Type  | Description                           |
| -------- | ----- | ------------------------------------- |
| `tickID` | int32 | Tick index represented by this cross. |

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

**ZeroForOne**

```go
func (s *SwapTickCross) ZeroForOne() bool
```

ZeroForOne reports the swap direction represented by this cross.

#### Return Values

| Name         | Type | Description                                                        |
| ------------ | ---- | ------------------------------------------------------------------ |
| `zeroForOne` | bool | True for token0-to-token1 swaps; false for token1-to-token0 swaps. |

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

#### Constructors

* `func NewSwapTickCross(tickID int32, zeroForOne bool, delta *i256.Int) *SwapTickCross` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L1390))

### Tick

```go
type Tick struct
```

Tick represents the state of a specific tick in a pool.

Fields:

* id (int32): The ID of the tick.
* stakedLiquidityGross (\*u256.Uint): Total gross staked liquidity at this tick.
* stakedLiquidityDelta (\*i256.Int): Net change in staked liquidity at this tick.
* outsideAccumulation (\*UintTree): RewardRatioAccumulation outside the tick.

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

#### Methods

**Clone**

```go
func (t *Tick) Clone() *Tick
```

Clone returns a deep copy of the tick.

#### Return Values

| Name   | Type   | Description                                                                               |
| ------ | ------ | ----------------------------------------------------------------------------------------- |
| `tick` | \*Tick | Deep copy of the tick and its outside-accumulation tree, or nil when the receiver is nil. |

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

**Id**

```go
func (t *Tick) Id() int32
```

Id returns the tick ID

#### Return Values

| Name | Type  | Description                            |
| ---- | ----- | -------------------------------------- |
| `id` | int32 | Tick index represented by this record. |

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

**OutsideAccumulation**

```go
func (t *Tick) OutsideAccumulation() *UintTree
```

OutsideAccumulation returns the outside accumulation tree

#### Return Values

| Name   | Type       | Description                                                      |
| ------ | ---------- | ---------------------------------------------------------------- |
| `tree` | \*UintTree | Historical reward-ratio accumulation observed outside this tick. |

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

**SetId**

```go
func (t *Tick) SetId(
	id int32
)
```

SetId sets the tick ID

#### Parameters

| Name | Type  | Description                        |
| ---- | ----- | ---------------------------------- |
| `id` | int32 | Tick index to store in the record. |

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

**SetOutsideAccumulation**

```go
func (t *Tick) SetOutsideAccumulation(
	outsideAccumulation *UintTree
)
```

SetOutsideAccumulation sets the outside accumulation tree

#### Parameters

| Name                  | Type       | Description                                                         |
| --------------------- | ---------- | ------------------------------------------------------------------- |
| `outsideAccumulation` | \*UintTree | UintTree of outside-accumulation snapshots keyed by Unix timestamp. |

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

**SetOutsideAccumulationAt**

```go
func (t *Tick) SetOutsideAccumulationAt(
	timestamp int64,
	acc *u256.Uint
)
```

SetOutsideAccumulationAt sets the outside accumulation at the timestamp. SetOutsideAccumulationAt records the Q128-scaled outside accumulation at a timestamp.

#### Parameters

| Name        | Type        | Description                                                     |
| ----------- | ----------- | --------------------------------------------------------------- |
| `timestamp` | int64       | Nonnegative Unix timestamp in seconds used as the snapshot key. |
| `acc`       | \*u256.Uint | Q128-scaled accumulation value encoded into the tree.           |

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

**SetStakedLiquidityDelta**

```go
func (t *Tick) SetStakedLiquidityDelta(
	stakedLiquidityDelta *i256.Int
)
```

SetStakedLiquidityDelta sets the staked liquidity delta

#### Parameters

| Name                   | Type       | Description                                                         |
| ---------------------- | ---------- | ------------------------------------------------------------------- |
| `stakedLiquidityDelta` | \*i256.Int | New net staked liquidity delta; the value is copied before storage. |

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

**SetStakedLiquidityGross**

```go
func (t *Tick) SetStakedLiquidityGross(
	stakedLiquidityGross *u256.Uint
)
```

SetStakedLiquidityGross sets the staked liquidity gross

#### Parameters

| Name                   | Type        | Description                                                           |
| ---------------------- | ----------- | --------------------------------------------------------------------- |
| `stakedLiquidityGross` | \*u256.Uint | New total gross staked liquidity; the value is copied before storage. |

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

**StakedLiquidityDelta**

```go
func (t *Tick) StakedLiquidityDelta() *i256.Int
```

StakedLiquidityDelta returns the staked liquidity delta

#### Return Values

| Name    | Type       | Description                                            |
| ------- | ---------- | ------------------------------------------------------ |
| `delta` | \*i256.Int | Net staked liquidity change associated with this tick. |

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

**StakedLiquidityGross**

```go
func (t *Tick) StakedLiquidityGross() *u256.Uint
```

StakedLiquidityGross returns the staked liquidity gross

#### Return Values

| Name        | Type        | Description                                                       |
| ----------- | ----------- | ----------------------------------------------------------------- |
| `liquidity` | \*u256.Uint | Total gross staked liquidity currently associated with this tick. |

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

#### Constructors

* `func NewTick(tickId int32) *Tick` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L1160))

### Ticks

```go
type Ticks struct
```

Tick mapping for each pool

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

#### Methods

**Clone**

```go
func (t Ticks) Clone() Ticks
```

Clone returns a deep copy of ticks.

#### Return Values

| Name    | Type  | Description                                                         |
| ------- | ----- | ------------------------------------------------------------------- |
| `ticks` | Ticks | New Ticks value with cloned Tick records in a fresh fanout-16 tree. |

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

**Get**

```go
func (t *Ticks) Get(
	tickId int32
) *Tick
```

Get returns the tick for the given tickId, or nil if it does not exist.

#### Parameters

| Name     | Type  | Description            |
| -------- | ----- | ---------------------- |
| `tickId` | int32 | Tick index to look up. |

#### Return Values

| Name   | Type   | Description                                                                                              |
| ------ | ------ | -------------------------------------------------------------------------------------------------------- |
| `tick` | \*Tick | Matching Tick record, or nil when the encoded ID is absent; panics if a stored value has the wrong type. |

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

**Has**

```go
func (self *Ticks) Has(
	tickId int32
) bool
```

Has reports whether a tick ID is present in the underlying tree.

#### Parameters

| Name     | Type  | Description                             |
| -------- | ----- | --------------------------------------- |
| `tickId` | int32 | Tick index whose encoded key is tested. |

#### Return Values

| Name      | Type | Description                                                  |
| --------- | ---- | ------------------------------------------------------------ |
| `present` | bool | True when the encoded tick ID exists in the underlying tree. |

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

**IterateTicks**

```go
func (t *Ticks) IterateTicks(
	fn func(int32, *Tick) bool
)
```

IterateTicks iterates over all ticks

#### Parameters

| Name | Type                     | Description                                                                                           |
| ---- | ------------------------ | ----------------------------------------------------------------------------------------------------- |
| `fn` | func(int32, \*Tick) bool | Callback receiving each stored Tick and decoded tick ID; returning true requests that iteration stop. |

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

**SetTick**

```go
func (t *Ticks) SetTick(
	tickId int32,
	tick *Tick
)
```

SetTick sets a tick by ID

#### Parameters

| Name     | Type   | Description                                                                                                                                    |
| -------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `tickId` | int32  | Tick index under which to store the record.                                                                                                    |
| `tick`   | \*Tick | Non-nil Tick record to store; a zero gross staked liquidity removes the tick instead, while nil input panics during the gross-liquidity check. |

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

**SetTree**

```go
func (t *Ticks) SetTree(
	tree *bptree.BPTree
)
```

SetTree sets the ticks tree

#### Parameters

| Name   | Type            | Description                      |
| ------ | --------------- | -------------------------------- |
| `tree` | \*bptree.BPTree | B+ tree to use for tick storage. |

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

**Tree**

```go
func (t *Ticks) Tree() *bptree.BPTree
```

Tree returns the ticks tree

#### Return Values

| Name   | Type            | Description                                                     |
| ------ | --------------- | --------------------------------------------------------------- |
| `tree` | \*bptree.BPTree | Mutable B+ tree mapping encoded int32 tick IDs to Tick records. |

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

#### Constructors

* `func NewTicks() Ticks` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L1033))

### TierRatio

```go
type TierRatio struct
```

100%, 0%, 0% if no tier2 and tier3 80%, 0%, 20% if no tier2 70%, 30%, 0% if no tier3 50%, 30%, 20% if has tier2 and tier3

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

#### Fields

* `Tier1 uint64` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L1174))
* `Tier2 uint64` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L1175))
* `Tier3 uint64` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L1176))

#### Methods

**Get**

```go
func (ratio *TierRatio) Get(
	tier uint64
) (uint64, error)
```

Get returns the ratio(scaled up by 100) for the given tier.

#### Parameters

| Name   | Type   | Description                                                 |
| ------ | ------ | ----------------------------------------------------------- |
| `tier` | uint64 | Tier number to query; only tiers 1, 2, and 3 are supported. |

#### Return Values

| Name    | Type   | Description                                                    |
| ------- | ------ | -------------------------------------------------------------- |
| `ratio` | uint64 | Requested tier share scaled by 100.                            |
| `err`   | error  | Non-nil when tier is not 1, 2, or 3; nil for a supported tier. |

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

#### Constructors

* `func NewTierRatio(tier1 uint64, tier2 uint64, tier3 uint64) TierRatio` ([source](https://github.com/gnoswap-labs/gnoswap/blob/d9d34bd345a36c3eedaccf491c6615b0ac4168cd/contract/r/gnoswap/staker/pool.gno#L1188))
