Keep3r Network: Keep3rV1Helper

Keep3r Helpers calculate how much KP3R a transaction receives. These are updateable by governance. We quickly wanted to explain the current implementation;

The first call in any Keep3r reward function is isKeeper(address) this sets a global state variable for the duration of this transaction. This tracks how much gas was used.

function isKeeper(address keeper) external returns (bool) {
_gasUsed = gasleft();
return keepers[keeper];

The final call in a reward function is worked(address) which indirectly calls workReceipt(address, uint)

function worked(address keeper) external {
workReceipt(keeper, KPRH.getQuoteLimit(_gasUsed.sub(gasleft())));

You will notice the call to KPRH (Keep3rV1Helper) with _gasUsed.sub(gasleft()) this calculates the amount of gas spent on the transaction;

Image for post
Image for post

Using the above transaction as example, gas used was 574,413 , this is sent to the getQuoteLimit(uint) function of the current Keep3rV1Helper implementation.

IChainLinkFeed public constant FASTGAS = IChainLinkFeed(0x169E633A2D1E6c10dD91238Ba11c4A708dfEF37C);
IUniswapV2Oracle public constant UNIQUOTE = IUniswapV2Oracle(0x127a2975c4E1c75f1ed4757a861bbd42523DB035);

From the above we can see 2 core calculations;

  • gasUsed * FASTGAS this gives the amount of wei used by the transaction
  • quote WETH sell for KP3R buy this calculates the amount of KP3R for the amount of sold wei

The future scope is to upgrade Keep3rV1Helper to a more profitable implementation, it is currently designed to be less than or equal to the amount of gas spent to avoid promoting front-running and unfair competition. As the system has more bonded users these rewards can be upgraded.

Read more about jobs and rewards here

Written by

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store