Agent (old)
The Agent is the key smart contract in the PowerAgent network
Overview
The PPAgentV2 (later The Agent) contract 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 indirect, of PPAgentV2.sol.
The Agent is responsible for the following operations:
Keeper Registration
To participate in the PowerAgent network, a keeper has to register in the system by calling the
registerAsKeeperfunction and provide at least minimal CVP stake.Job Registration
The contract to be automated must be registered in The Agent. For this, the owner of the contract provides the address of the contract, and the configuration of the job, including the type, and tops up the job balance for keepers' reward.
Transaction xecution
To execute the task (once the conditions for execution are met), the keeper calls
executethe Agent contract function. 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.Job Update
Job owners can update the Job configuration at any time, for example, change the function of the contract to be executed, or update the conditions by which the contract should be executed. Each time a change is made, a Job with new id is created and attached to the same Job contract.
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.
Keeper Removal
Once a keeper wishes to quit participation in the PowerAgent network, they call the function
initiateRedeem. A process of stake release is launched. After a cooldown period that is specified by the job parameters, the keeper can withdraw their CVP stake by invokingfinalizeRedeem.
Specification
Internal constants
The Agent possesses the following internal (i.e., accessible to inheritors) constants:
Internal variables
The Agent possesses the following internal (i.e., accessible to inheritors) variables:
Functions
Initialization
The Agent instance is initialized by an eponymous function initialize which accepts the following arguments:
This function sets the Agent’s configuration parameters and ownership to those specified.
Parameter update
Function setAgentParams updates the configuration of the Agent. Appropriate parameters are capped by the corresponding internal constants.
Fee withdrawal
The function withdrawFees withdraws all fees the Agent has accrued to a specified address.
Custom structures
The Agent contract contains custom data structures storing information about Keepers and Jobs.
Refer to the Keeper (Old) and Job (Old) pages for detailed description.
Last updated
Was this helpful?