keep3r-network / keep3r.network

An incentivized keeper network for anonymous keeper and job registration
372 stars 117 forks source link

workReceipt reward amount capped at gas cost #20

Closed gitpusha closed 4 years ago

gitpusha commented 4 years ago

Hi,

While reading through the Keep3r.sol code I found this require statement in the workReceipt function:

https://github.com/keep3r-network/keep3r.network/blob/144a307864df5030ee92fb8861d27c7f71dc48c8/contracts/Keep3r.sol#L1070

It seems like the amount that a job can reward a Keeper is capped at gasUsed.mul(uint(FASTGAS.latestAnswer())) .

Should it not be this instead:

require(
    amount >= KPRH.getQuoteLimit(_gasUsed.sub(gasleft())),
    "workReceipt: min limit"
);

Thus ensuring a minimum reward to cover gasCost for the Keeper, but not placing a maximum on what reward the job might want to pay out?

I noticed this when skimming so might also just be a misunderstanding from my zoomed in view.

SirLancelot-OG commented 4 years ago

From the docs:

The maximum amount that can be paid out per call is (gasUsed fastGasPrice) 1.1

Which is slightly confusing to me, because workReceipt() is used for KPR payouts: https://docs.keep3r.network/jobs#pay-with-kpr

So KPR payouts are limited by ETH-denominated gas spent?

gitpusha commented 4 years ago

Ah so the cap is only for KPR reward payments.

Do you know if there is some conversion happening to pay out ETH gasUsed * fastGasPrice) * 1.1 KPR equivalents to the Keeper who did the job? Or is the Keeper just receiving plain old KPR 1:1 gasUsed * fastGasPrice) * 1.1 ?

andrecronje commented 4 years ago

Correct, there are 3 payment mechanisms;

receipt(address credit, address keeper, uint amount)

This has no upper cap and it is up to the job to decide, the credit can be anything, so Aave could use AAVE or Synthetix SNX, etc to additionally incentivize keepers.

receiptETH(address keeper, uint amount) external

As above, but ETH.

And then the system token KP3R which is minted from liquidity

workReceipt(address keeper, uint amount) public

It is capped to how much it can give up, but KPRH (Keep3rV1Helper) can be updated.

The current implementation works as described here

So after there are more bonded keepers, we can vote to upgrade KPRH to increase the distribution / call. I decided to keep it < gas spent for now to avoid keepers rushing into jobs. I don't like to incentivize reckless behavior.

gitpusha commented 3 years ago

ok, thanks for explaining!