keep3r.network
Search…
Jobs

Quick Start Examples

Simple Keeper

To setup a keeper function simply add the following modifier;
1
modifier keep() {
2
require(KPR.isKeeper(msg.sender), "::isKeeper: keeper is not registered");
3
_;
4
KPR.worked(msg.sender);
5
}
Copied!
The above will make sure the caller is a registered keeper as well as reward them with an amount of KPR equal to their gas spent + premium. Make sure to have credit assigned in the Keep3r system for the relevant job.

Adding Jobs

Jobs can be created directly via governance or by submitting a job proposal to governance automatically via adding liquidity.

Submit a job via governance

Simply create a new proposal via governance to add a new job
1
/**
2
* @notice Allows governance to add new job systems
3
* @param job address of the contract for which work should be performed
4
*/
5
function addJob(address job) external;
Copied!

Submit a job via adding liquidity

You will need to provide liquidity to one of the approved liquidity pairs (for example KPR-ETH). You put your LP tokens in escrow and receive credit. When the credit is used up, you can simply withdraw the LP tokens. You will receive 100% of the LP tokens back that you deposited.
1
/**
2
* @notice Allows liquidity providers to submit jobs
3
* @param liquidity the liquidity being added
4
* @param job the job to assign credit to
5
* @param amount the amount of liquidity tokens to use
6
*/
7
function addLiquidityToJob(address liquidity, address job, uint amount) external
Copied!

Managing Credit

Jobs need credit to be able to pay keepers, this credit can either be paid for directly, or by being a liquidity provider in the system. If you pay directly, this is a direct expense, if you are a liquidity provider, you get all your liquidity back after you are done being a provider.

Add credit to a job via Liquidity

Step 1 is to provide LP tokens as credit. You receive all your LP tokens back when you no longer need to provide credit for a contract.
1
/**
2
* @notice Allows liquidity providers to submit jobs
3
* @param liquidity the liquidity being added
4
* @param job the job to assign credit to
5
* @param amount the amount of liquidity tokens to use
6
*/
7
function addLiquidityToJob(address liquidity, address job, uint amount) external
Copied!
Wait LIQUIDITYBOND (default 3 days) days.
1
/**
2
* @notice Applies the credit provided in addLiquidityToJob to the job
3
* @param provider the liquidity provider
4
* @param liquidity the pair being added as liquidity
5
* @param job the job that is receiving the credit
6
*/
7
function applyCreditToJob(address provider, address liquidity, address job) external
Copied!

Remove liquidity from a job

1
/**
2
* @notice Unbond liquidity for a job
3
* @param liquidity the pair being unbound
4
* @param job the job being unbound from
5
* @param amount the amount of liquidity being removed
6
*/
7
function unbondLiquidityFromJob(address liquidity, address job, uint amount) external
Copied!
Wait UNBOND (default 14 days) days.
1
/**
2
* @notice Allows liquidity providers to remove liquidity
3
* @param liquidity the pair being unbound
4
* @param job the job being unbound from
5
*/
6
function removeLiquidityFromJob(address liquidity, address job) external
Copied!

Adding credit directly (non ETH)

1
/**
2
* @notice Add credit to a job to be paid out for work
3
* @param credit the credit being assigned to the job
4
* @param job the job being credited
5
* @param amount the amount of credit being added to the job
6
*/
7
function addCredit(address credit, address job, uint amount) external
Copied!

Adding credit directly (ETH)

1
/**
2
* @notice Add ETH credit to a job to be paid out for work
3
* @param job the job being credited
4
*/
5
function addCreditETH(address job) external payable
Copied!

Selecting Keepers

Dependent on your requirements you might allow any keepers, or you want to limit specific keepers, you can filter keepers based on age, bond, total earned funds, or even arbitrary values such as additional bonded tokens.

No access control

Accept all keepers in the system.
1
/**
2
* @notice confirms if the current keeper is registered, can be used for general (non critical) functions
3
* @param keeper the keeper being investigated
4
* @return true/false if the address is a keeper
5
*/
6
function isKeeper(address keeper) external returns (bool)
Copied!

Filtered access control

Filter keepers based on bonded amount, earned funds, and age in system.
1
/**
2
* @notice confirms if the current keeper is registered and has a minimum bond, should be used for protected functions
3
* @param keeper the keeper being investigated
4
* @param minBond the minimum requirement for the asset provided in bond
5
* @param earned the total funds earned in the keepers lifetime
6
* @param age the age of the keeper in the system
7
* @return true/false if the address is a keeper and has more than the bond
8
*/
9
function isMinKeeper(address keeper, uint minBond, uint earned, uint age) external returns (bool)
Copied!
Additionally you can filter keepers on additional bonds, for example a keeper might need to have SNX to be able to participate in the Synthetix ecosystem.
1
/**
2
* @notice confirms if the current keeper is registered and has a minimum bond, should be used for protected functions
3
* @param keeper the keeper being investigated
4
* @param bond the bound asset being evaluated
5
* @param minBond the minimum requirement for the asset provided in bond
6
* @param earned the total funds earned in the keepers lifetime
7
* @param age the age of the keeper in the system
8
* @return true/false if the address is a keeper and has more than the bond
9
*/
10
function isBondedKeeper(address keeper, address bond, uint minBond, uint earned, uint age) external returns (bool)
Copied!

Paying Keepers

There are three primary payment mechanisms and these are based on the credit provided;
  • Pay via liquidity provided tokens (based on addLiquidityToJob)
  • Pay in direct ETH (based on addCreditETH)
  • Pay in direct token (based on addCredit)

Auto Pay

If you don't want to worry about calculating payment, you can simply let the system calculate the payment itself;
1
/**
2
* @notice Implemented by jobs to show that a keeper performed work
3
* @param keeper address of the keeper that performed the work
4
*/
5
function worked(address keeper) external
Copied!

Pay with KPR

The maximum amount that can be paid out per call is (gasUsed * fastGasPrice) * 1.1
1
/**
2
* @notice Implemented by jobs to show that a keeper performed work
3
* @param keeper address of the keeper that performed the work
4
* @param amount the reward that should be allocated
5
*/
6
function workReceipt(address keeper, uint amount) external
Copied!

Pay with token

There is no limit on how many tokens can be paid out via this mechanism
1
/**
2
* @notice Implemented by jobs to show that a keeper performed work
3
* @param credit the asset being awarded to the keeper
4
* @param keeper address of the keeper that performed the work
5
* @param amount the reward that should be allocated
6
*/
7
function receipt(address credit, address keeper, uint amount) external
Copied!

Pay with ETH

There is no limit on how many tokens can be paid out via this mechanism
1
/**
2
* @notice Implemented by jobs to show that a keeper performend work
3
* @param keeper address of the keeper that performed the work
4
* @param amount the amount of ETH sent to the keeper
5
*/
6
function receiptETH(address keeper, uint amount) external
Copied!
Last modified 1yr ago