Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas based keeper rewards #1890

Closed
wants to merge 42 commits into from
Closed

Gas based keeper rewards #1890

wants to merge 42 commits into from

Conversation

leomassazza
Copy link
Contributor

@leomassazza leomassazza commented Oct 30, 2023

The objective of this PR is to get the cost of a transaction based on gas price. It is used to dynamically calculate the keeper rewards for settlement, flag and liquidate, and to calculate the required margin to pay the keeper upon liquidation.

It makes use of a node that gets a transaction cost based on current gas price, and then the keeper rewards are added to the cost.


Detailed TODO list:

  • Add mock TxGasPriceOracle
  • Add node for keeper rewards gas cost
  • Add KeeperCost library to storage that calls the node
  • Add node to bootstrap
  • Configure node with all zeros (not alter current tests)
  • Tests pass with node
  • Test not configurable by non-owner
  • Test to check revert if not configured
  • Add cost of execution on settlement
  • Add cost of execution on flag
  • Add cost of execution on liquidation
  • Add cost of flag/liquidate to isElegibleForLiquidation
  • Dynamic min and max keeper reward caps
  • Test settlement cost is used on settlement
  • Test caps on flag + liquidate
  • Test flag / liquidate for 1 margin 1 small position
  • Test flag / liquidate for 1 margin 2 small positions (multiple feeds for positions)
  • Test flag / liquidate for 1 margin 1 large position (multiple steps)
  • Test flag / liquidate for 2 margins 1 small position (multiple feeds for margin)
  • Test flag/liquidate cost is added to isElegibleForLiquidation
  • Test like Order.marginValidation.test with caps
  • Add extra reward for liquidators (execution reward on top of cost)
  • On tests, confirm liquidator got the rewards
  • review comments and docs and add missing ones
  • cleanup (no console logs or dev stuff)
  • lint
  • all test pass green

@leomassazza leomassazza marked this pull request as ready for review November 3, 2023 15:32
Copy link
Contributor

@sunnyvempati sunnyvempati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hope the comments make sense. hmu in the AM with any q's. we're very close! great work on this

markets/perps-market/contracts/storage/KeeperCosts.sol Outdated Show resolved Hide resolved
markets/perps-market/contracts/storage/PerpsAccount.sol Outdated Show resolved Hide resolved
markets/perps-market/contracts/storage/KeeperCosts.sol Outdated Show resolved Hide resolved
markets/perps-market/contracts/storage/AsyncOrder.sol Outdated Show resolved Hide resolved
@leomassazza leomassazza self-assigned this Nov 7, 2023
Copy link
Contributor

@sunnyvempati sunnyvempati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple changes; pre-approving. awesome work on this

markets/perps-market/contracts/storage/AsyncOrder.sol Outdated Show resolved Hide resolved
markets/perps-market/contracts/storage/PerpsAccount.sol Outdated Show resolved Hide resolved
markets/perps-market/contracts/storage/KeeperCosts.sol Outdated Show resolved Hide resolved
markets/perps-market/contracts/storage/PerpsAccount.sol Outdated Show resolved Hide resolved
@noahlitvin
Copy link
Contributor

Closing in favor of #1904

@noahlitvin noahlitvin closed this Nov 13, 2023
@noisekit noisekit deleted the gas-based-keeper-rewards branch November 13, 2023 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants