ℹī¸Agent

Core PowerAgent contract

Overview

The PPAgentV2 (later The Agent) is the key PowerAgent contract that stores the state of the PowerAgent network. It includes the list of keepers, the logic of task execution, and keeper management.

PPAgentV2 is an upgradeable descendant, direct or indrect, of the PPAgentV2.sol contract.

Functions

The Agent is responsible for all operations in the PowerAgent network. It manages the interactions related to keepers, stakes, Jobs, and relays execution calls from the keepers to the target contracts.

The scheme above is non-exhaustive. It is only for general understanding.

Detailed information on the contract may be found here.

Keeper Management

Registration, activation and deactivation.

In order to partake in the PowerAgent, a keeper must be register in the Agent and stake a minimum amount of CVP. See the Keeper page for detailed information about keepers. The keeper may be deactivated and reactivated (for example, to perform maintenance on the machine running the PowerAgent software).

Stake Management

A keeper owner may top up or withdraw CVP from the keeper’s balance. Note that staking occurs instantly, but withdrawal comes with a cooldown for security reasons.

Rewards Management

If a keeper is configured to accrue rewards on the Agent contract, the owner may withdraw the rewards from the Agent. Rewards withdrawal is not affected by cooldown.

Job Management

Users can automate their tasks by submitting a Job into the PowerAgent network. This is done through the Agent contract. See the Job section for more details.

Inside the Agent, the Job is represented as a binary data structure and contains target contract address, target function selector and various configuration entries.

Every keeper receives native token rewards for executions. For the Job to be executed, the Job Owner has to top up its balance (or select the Owner Balance as a source of reward).

The credits may be withdrawn at any time (if the remaining credit balance is too low for execution, the job will be automatically deactivated).

Transaction Execution

When the conditions for execution of a certain job are met, the keeper calls execute function of the Agent. The Agent ensures that the task indeed should be executed and all keeper checks are passed and then relays the call to the target function.

From the target contract point of view, the msg.sender is the Agent, and the tx.origin is the keeper which initiated the transaction.

Slashing

The PowerAgent has the algorithm of punishment for malicious or negligent keepers. Various tasks can have different cost of no execution, and expensive tasks require stable and reliable execution. To prevent keepers from misbehavior, the slashing system is implemented in the Agent. If the execution of a task is failed (or not performed in time), the keeper is slashed for a certain portion of their CVP stake. This portion depends on the task specific minimal CVP stake and the cost of no execution.

To execute the task (once the conditions for execution are met), the keeper invokes the Agent's execution endpoint. After a series of check-ups, the call is passed by the Agent to the Job contract and the task is executed, or in case of any errors, the execution will revert with a corresponding error.

More details are given on the Keeper page.

Job Update

Most of the Job parameters (aside from the purely technical ones), like, for instance, the calldata source or the minimal admissible stake, can be changed by the Job owner via the interface.

Keeper Removal

A Keeper cannot be removed from the mapping, but he can be deactivated, and his stake can be withdrawn. A recommended procedure is to disable the keeper, wait for all the jobs assigned to it, if any, to slash (for this reason it is recommended to disable the keeper which has no jobs assigned), and initiate redemption of its stake. Once a cooldown period set by the Agent config passes, finalize redemption, and the previously staked CVP will have been freed.

Last updated