> For the complete documentation index, see [llms.txt](https://docs.inverter.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inverter.network/contracts/technical-reference/modules/logic-module/interfaces/ilm_pc_kpirewarder_v1.sol.md).

# ILM\_PC\_KPIRewarder\_v1.sol

[Git Source](https://github.com/InverterNetwork/inverter-contracts/blob/649b450f02fc8b735c128ff0821467e71966c666/src/modules/logicModule/interfaces/ILM_PC_KPIRewarder_v1.sol)

### Functions

#### postAssertion

Posts an assertion to the Optimistic Oracle, specifying the KPI to use and the asserted value.

```solidity
function postAssertion(
    bytes32 dataId,
    uint assertedValue,
    address asserter,
    uint targetKPI
) external returns (bytes32 assertionId);
```

**Parameters**

| Name            | Type      | Description                                                              |
| --------------- | --------- | ------------------------------------------------------------------------ |
| `dataId`        | `bytes32` | The dataId to be posted.                                                 |
| `assertedValue` | `uint256` | The target value that will be asserted and posted as data to the oracle. |
| `asserter`      | `address` | The address of the asserter.                                             |
| `targetKPI`     | `uint256` | The KPI to be used for distribution once the assertion confirms.         |

**Returns**

| Name          | Type      | Description                                        |
| ------------- | --------- | -------------------------------------------------- |
| `assertionId` | `bytes32` | The assertionId received for the posted assertion. |

#### createKPI

Creates a KPI for the Rewarder.

```solidity
function createKPI(
    bool _continuous,
    uint[] calldata _trancheValues,
    uint[] calldata _trancheRewards
) external returns (uint);
```

**Parameters**

| Name              | Type        | Description                                                         |
| ----------------- | ----------- | ------------------------------------------------------------------- |
| `_continuous`     | `bool`      | Should the tranche rewards be distributed continuously or in steps. |
| `_trancheValues`  | `uint256[]` | The value at which the tranches end.                                |
| `_trancheRewards` | `uint256[]` | The rewards to be distributed at completion of each tranche.        |

**Returns**

| Name     | Type      | Description |
| -------- | --------- | ----------- |
| `<none>` | `uint256` | The KPI id. |

#### depositFeeFunds

Deposits funds into the contract so it can pay for the oracle bond and fee itself.

```solidity
function depositFeeFunds(uint amount) external;
```

**Parameters**

| Name     | Type      | Description            |
| -------- | --------- | ---------------------- |
| `amount` | `uint256` | The amount to deposit. |

#### getKPI

Returns the KPI with the given number.

```solidity
function getKPI(uint KPInum) external view returns (KPI memory);
```

**Parameters**

| Name     | Type      | Description                      |
| -------- | --------- | -------------------------------- |
| `KPInum` | `uint256` | The number of the KPI to return. |

**Returns**

| Name     | Type  | Description |
| -------- | ----- | ----------- |
| `<none>` | `KPI` | The KPI.    |

#### getAssertionConfig

Returns the Assertion Configuration for a given assertionId.

```solidity
function getAssertionConfig(bytes32 assertionId)
    external
    view
    returns (RewardRoundConfiguration memory);
```

**Parameters**

| Name          | Type      | Description                        |
| ------------- | --------- | ---------------------------------- |
| `assertionId` | `bytes32` | The id of the Assertion to return. |

**Returns**

| Name     | Type                       | Description                  |
| -------- | -------------------------- | ---------------------------- |
| `<none>` | `RewardRoundConfiguration` | The Assertion Configuration. |

#### deleteStuckAssertion

Deletes a stuck assertion.

*This function is only callable by the Orchestrator Admin.*

```solidity
function deleteStuckAssertion(bytes32 assertionId) external;
```

**Parameters**

| Name          | Type      | Description                        |
| ------------- | --------- | ---------------------------------- |
| `assertionId` | `bytes32` | The id of the assertion to delete. |

#### getKPICounter

Returns the current KPI counter.

```solidity
function getKPICounter() external view returns (uint);
```

**Returns**

| Name     | Type      | Description      |
| -------- | --------- | ---------------- |
| `<none>` | `uint256` | The KPI counter. |

#### getAssertionPending

Returns the assertion pending flag.

```solidity
function getAssertionPending() external view returns (bool);
```

**Returns**

| Name     | Type   | Description                 |
| -------- | ------ | --------------------------- |
| `<none>` | `bool` | The assertion pending flag. |

### Events

#### KPICreated

Event emitted when a KPI is created.

```solidity
event KPICreated(
    uint indexed KPI_Id,
    uint numOfTranches,
    uint totalKPIRewards,
    bool continuous,
    uint[] trancheValues,
    uint[] trancheRewards
);
```

**Parameters**

| Name              | Type        | Description                                                  |
| ----------------- | ----------- | ------------------------------------------------------------ |
| `KPI_Id`          | `uint256`   | The id of the KPI.                                           |
| `numOfTranches`   | `uint256`   | The number of tranches in the KPI.                           |
| `totalKPIRewards` | `uint256`   | The total rewards for the KPI.                               |
| `continuous`      | `bool`      | Whether the KPI is continuous or not.                        |
| `trancheValues`   | `uint256[]` | The values at which each tranche ends.                       |
| `trancheRewards`  | `uint256[]` | The rewards to be distributed at completion of each tranche. |

#### RewardRoundConfigured

Event emitted when a reward round is configured.

```solidity
event RewardRoundConfigured(
    bytes32 indexed assertionId,
    uint creationTime,
    uint assertedValue,
    uint indexed KpiToUse
);
```

**Parameters**

| Name            | Type      | Description                                                      |
| --------------- | --------- | ---------------------------------------------------------------- |
| `assertionId`   | `bytes32` | The id of the assertion.                                         |
| `creationTime`  | `uint256` | The timestamp the assertion was created.                         |
| `assertedValue` | `uint256` | The value that was asserted.                                     |
| `KpiToUse`      | `uint256` | The KPI to be used for distribution once the assertion confirms. |

#### FeeFundsDeposited

Event emitted when funds for paying the bonding fee are deposited into the contract.

```solidity
event FeeFundsDeposited(address indexed token, uint amount);
```

**Parameters**

| Name     | Type      | Description                     |
| -------- | --------- | ------------------------------- |
| `token`  | `address` | The token used for the deposit. |
| `amount` | `uint256` | The amount deposited.           |

#### DeletedStuckAssertion

Event emitted when a stuck assertion gets deleted.

```solidity
event DeletedStuckAssertion(bytes32 indexed assertionId);
```

### Errors

#### Module\_\_LM\_PC\_KPIRewarder\_v1\_\_InvalidTrancheNumber

The KPI beinge created has either no tranches or too many.

```solidity
error Module__LM_PC_KPIRewarder_v1__InvalidTrancheNumber();
```

#### Module\_\_LM\_PC\_KPIRewarder\_v1\_\_InvalidKPIValueLengths

The number of tranches in the KPI does not match the number of rewards.

```solidity
error Module__LM_PC_KPIRewarder_v1__InvalidKPIValueLengths();
```

#### Module\_\_LM\_PC\_KPIRewarder\_v1\_\_InvalidKPITrancheValues

The values for the tranches are not in ascending order.

```solidity
error Module__LM_PC_KPIRewarder_v1__InvalidKPITrancheValues();
```

#### Module\_\_LM\_PC\_KPIRewarder\_v1\_\_InvalidKPINumber

The KPI number is invalid.

```solidity
error Module__LM_PC_KPIRewarder_v1__InvalidKPINumber();
```

#### Module\_\_LM\_PC\_KPIRewarder\_v1\_\_ModuleCannotUseStakingTokenAsBond

The Token used paying the bond cannot be the same that is being staked.

```solidity
error Module__LM_PC_KPIRewarder_v1__ModuleCannotUseStakingTokenAsBond();
```

#### Module\_\_LM\_PC\_KPIRewarder\_v1\_\_UnresolvedAssertionExists

An assertion can only by posted if the preceding one is resolved.

```solidity
error Module__LM_PC_KPIRewarder_v1__UnresolvedAssertionExists();
```

#### Module\_\_LM\_PC\_KPIRewarder\_v1\_\_CannotStakeWhenAssertionPending

The user cannot stake while an assertion is unresolved.

```solidity
error Module__LM_PC_KPIRewarder_v1__CannotStakeWhenAssertionPending();
```

#### Module\_\_LM\_PC\_KPIRewarder\_v1\_\_NonExistentAssertionId

Callback received references non existent assertionId.

```solidity
error Module__LM_PC_KPIRewarder_v1__NonExistentAssertionId(bytes32 assertionId);
```

#### Module\_\_LM\_PC\_KPIRewarder\_v1\_\_AssertionNotStuck

The assertion that is being removed was not stuck.

```solidity
error Module__LM_PC_KPIRewarder_v1__AssertionNotStuck(bytes32 assertionId);
```

### Structs

#### KPI

A KPI to be used for reward distribution.

```solidity
struct KPI {
    uint numOfTranches;
    uint totalRewards;
    bool continuous;
    uint[] trancheValues;
    uint[] trancheRewards;
}
```

**Properties**

| Name             | Type        | Description                                                            |
| ---------------- | ----------- | ---------------------------------------------------------------------- |
| `numOfTranches`  | `uint256`   | The number of tranches the KPI is divided into.                        |
| `totalRewards`   | `uint256`   | The total rewards to be distributed.                                   |
| `continuous`     | `bool`      | If the tranche rewards should be distributed continuously or in steps. |
| `trancheValues`  | `uint256[]` | The value at which each tranche ends.                                  |
| `trancheRewards` | `uint256[]` | The rewards to be distributed at completion of each tranche.           |

#### RewardRoundConfiguration

The configuration of the reward round tied.

```solidity
struct RewardRoundConfiguration {
    uint creationTime;
    uint assertedValue;
    uint KpiToUse;
    bool distributed;
}
```

**Properties**

| Name            | Type      | Description                                                      |
| --------------- | --------- | ---------------------------------------------------------------- |
| `creationTime`  | `uint256` | The timestamp the assertion was posted.                          |
| `assertedValue` | `uint256` | The value that was asserted.                                     |
| `KpiToUse`      | `uint256` | The KPI to be used for distribution once the assertion confirms. |
| `distributed`   | `bool`    | If the rewards have been distributed or not.                     |
