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;
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);address constant WETH = address(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address constant KP3R = address(0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44);function quote(uint spent) public view returns (uint) {
return UNIQUOTE.consult(WETH, spent, KP3R);
}function quoteGas(uint gasUsed) external view returns (uint) {
return gasUsed.mul(uint(FASTGAS.latestAnswer()));
}function getQuoteLimit(uint gasUsed) external view returns (uint) {
return quote(gasUsed.mul(uint(FASTGAS.latestAnswer())));
}
From the above we can see 2 core calculations;
gasUsed * FASTGAS
this gives the amount ofwei
used by the transactionquote WETH sell for KP3R buy
this calculates the amount of KP3R for the amount of soldwei
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