LM_PC_KPIRewarder_v1.sol
Inherits: ILM_PC_KPIRewarder_v1, LM_PC_Staking_v1, OptimisticOracleIntegrator
Author: Inverter Network
Provides a mechanism for distributing rewards to stakers based on Key Performance Indicators (KPIs).
Extends {LM_PC_Staking_v1} and integrates with {OptimisticOracleIntegrator} to enable KPI-based reward distribution within the staking manager.
State Variables
KPICounter
The number of KPIs created.
uint internal KPICounter;
registryOfKPIs
Registry of KPIsid -> KPI.
mapping(uint => KPI) internal registryOfKPIs;
assertionConfig
Registry of Assertion Configurations assertionId -> RewardRoundConfiguration.
mapping(bytes32 => RewardRoundConfiguration) internal assertionConfig;
assertionPending
For locking certain utilities when there are assertions open.
bool internal assertionPending;
__gap
Storage gap for future upgrades.
uint[50] private __gap;
Functions
supportsInterface
See {IERC165-supportsInterface}.
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(OptimisticOracleIntegrator, LM_PC_Staking_v1)
returns (bool);
init
function init(
IOrchestrator_v1 orchestrator_,
Metadata memory metadata,
bytes memory configData
)
external
virtual
override(LM_PC_Staking_v1, OptimisticOracleIntegrator)
initializer;
getKPI
Returns the KPI with the given number.
function getKPI(uint KPInum) external view returns (KPI memory);
Parameters
KPInum
uint256
The number of the KPI to return.
Returns
<none>
KPI
The KPI.
getAssertionConfig
Returns the Assertion Configuration for a given assertionId.
function getAssertionConfig(bytes32 assertionId)
external
view
returns (RewardRoundConfiguration memory);
Parameters
assertionId
bytes32
The id of the Assertion to return.
Returns
<none>
RewardRoundConfiguration
The Assertion Configuration.
getKPICounter
Returns the current KPI counter.
function getKPICounter() external view returns (uint);
Returns
<none>
uint256
The KPI counter.
getAssertionPending
Returns the assertion pending flag.
function getAssertionPending() external view returns (bool);
Returns
<none>
bool
The assertion pending flag.
postAssertion
Posts an assertion to the Optimistic Oracle, specifying the KPI to use and the asserted value.
about the asserter address: any address can be set as asserter, it will be expected to pay for the bond on posting. The bond tokens can also be deposited in the Module and used to pay for itself, but ONLY if the bond token is different from the one being used for staking. If the asserter is set to 0, whomever calls postAssertion will be paying the bond.
function postAssertion(
bytes32 dataId,
uint assertedValue,
address asserter,
uint targetKPI
) public onlyModuleRole(ASSERTER_ROLE) returns (bytes32 assertionId);
Parameters
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
assertionId
bytes32
The assertionId received for the posted assertion.
depositFeeFunds
Deposits funds into the contract so it can pay for the oracle bond and fee itself.
Top up funds to pay the optimistic oracle fee
function depositFeeFunds(uint amount)
external
onlyOrchestratorAdmin
nonReentrant
validAmount(amount);
Parameters
amount
uint256
The amount to deposit.
createKPI
Creates a KPI for the Rewarder.
function createKPI(
bool _continuous,
uint[] calldata _trancheValues,
uint[] calldata _trancheRewards
) external onlyOrchestratorAdmin returns (uint);
Parameters
_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
<none>
uint256
The KPI id.
stake
Stake a specified amount of tokens to earn rewards.
Should tokens already be staked, then the sending address will collect the rewards up until this point.
function stake(uint amount)
external
override
nonReentrant
validAmount(amount);
Parameters
amount
uint256
How much token should be staked.
deleteStuckAssertion
Deletes a stuck assertion.
This function is only callable by the Orchestrator Admin.
function deleteStuckAssertion(bytes32 assertionId)
public
onlyOrchestratorAdmin;
Parameters
assertionId
bytes32
The id of the assertion to delete.
assertionResolvedCallback
Callback function that is called by Optimistic Oracle V3 when an assertion is resolved.
function assertionResolvedCallback(bytes32 assertionId, bool assertedTruthfully)
public
override;
Parameters
assertionId
bytes32
The identifier of the assertion that was resolved.
assertedTruthfully
bool
Whether the assertion was resolved as truthful or not.
assertionDisputedCallback
Callback function that is called by Optimistic Oracle V3 when an assertion is disputed.
This OptimisticOracleV3 callback function needs to be defined so the OOv3 doesn't revert when it tries
function assertionDisputedCallback(bytes32 assertionId) public override;
Parameters
assertionId
bytes32
The identifier of the assertion that was disputed.
Last updated