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

feat: automated rKP3R and ibEUR reward distribution #4

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

wei3erHase
Copy link

@wei3erHase wei3erHase commented May 18, 2022

Fixed Forex Reward Distribution Job

GaugeProxy contract extracted from https://etherscan.io/address/0x81a8CAb6bb568fC94bCa70C9AdbFCF05592dEd7b

GaugeProxyV2 Changelog

  • Updated min solidity compiler to 0.8.12
  • Created corresponding interfaces
  • Added natspec to IGaugeProxy
  • Added variable and setter for a keeper
  • Changed access control on distribute() from gov to keeper
  • Addded forceDistribute() allowed for gov
  • Added gov parameter in constructor
  • Executes infinite KP3R approval to rKP3R contract on constructor
  constructor(address _gov) {
    gov = _gov;
    _safeApprove(_kp3rV1, _rkp3r, type(uint256).max);
  }
  • Automates KP3R and rKP3R handling into the distribution function
function _distribute() internal {
    uint256 _balance = IKeep3rV1Proxy(_kp3rV1Proxy).draw();
    IrKP3R(_rkp3r).deposit(_balance);
    ...

RewardDistributionJob

Has 3 functions to be upkept, each has a timeout

  • work(): distributes rKP3R to gauges, calls ibController.profit() and ibBurner.update_snx()
  • exchange(): calls ibBurner.exchanger()
  • distribute(): calls ibBurner.distribute()

Registry

Keep3r Governance: 0x0d5dc686d0a2abbfdafdfb4d0533e886517d4e83
GaugeProxyV2: 0xEdA0b82211Bb7e6E7F0415713580ce91A3C41767
RewardDistributionJob: TBD

Gauge Proxy Deployment

  • Defi Wonderland deploys GaugeProxyV2 (with 0x0d5dc686d0a2abbfdafdfb4d0533e886517d4e83 as gov)

Initialization

  • Keep3r Governance adds a reward on Keep3rV1Proxy for the GaugeProxyV2 address Keep3rV1Proxy.addRecipient( GaugeProxyV2.address, WEEKLY_AMOUNT_OF_KP3R )
  • Keep3r Governance registers existing gauges into the contract GaugeProxyV2.addGauge( _pool, _gauge )
  • Keep3r Governance sets contract address as reward_distributor in Curve for the corresponding gauges
  • Keep3r Governance executes first reward distribution using forceDistribute(), initializing the draw mechanism on Keep3rV1Proxy, next distribution will be possible a week after execution timestamp

Upkeep

  • Keep3r Governance reviews RewardDistributionJob
  • Defi Wonderland deploys RewardDistributionJob (with 0x0d5dc686d0a2abbfdafdfb4d0533e886517d4e83 as gov)
  • Defi Wonderland registers job Keep3rV2.addJob(RewardDistributionJob)
  • Defi Wonderland changes job ownership to Keep3r Governance
  • Defi Wonderland publishes CLI for job upkeeping
  • Keep3r Governance accept job ownership change Keep3rV2.acceptJobOwnership( RewardDistributionJob )
  • Keep3r Governance fund the job with kLPs (min amount: 3KP3R / x WETH)
  • Keep3r Governance registers RewardDistributionJob as keeper address GaugeProxyV2.setKeeper(RewardDistributionJob)

* chore: added hardhat boilerplate

* chore: run linter

* fix: rm legacy code

* feat: added vyper compiler

* feat: added github workflows

* chore: revert linter

* fix: solhint ignore
* chore: added hardhat boilerplate

* chore: run linter

* fix: rm legacy code

* feat: added vyper compiler

* feat: added github workflows

* fix: linter error

* feat: adding basic test structure

* fix: typings bug

* feat: added tests scaffolding

* fix: revert linter

* fix: run prettier
* feat: added reward distribution e2e test

* chore: retrieved latest GaugeProxy version from etherscan

* fix: e2e test importing current contracts

* chore: gaugeProxyV2

* chore: revert unnecessary changes

* fix: run linter
* refactor: separated interfaces

* feat: added draw functionality

* feat: added keeper functionality

* style: renaming
* feat: added keep3r job scaffolding

* feat: added interface to gaugeProxy

* fix: natpsec bug

* test: added job to e2e

* test: added utils unit tests

* fix: run linter

* feat: added job unit test

* feat: added coverage

* feat: fixes and comments in PR

* fix: linter

* fix: rm overrides in job
* feat: added unit test to GaugeProxy distribution

* feat: added deployment script

* feat: added delegate script

* fix: linter

* fix: missing await

* fix: weird bug

* feat: added natspec

* fix: added eth-sdk to postinstall

* chore: returned contracts to original location

* fix: ignoring eth-sdk abis

* feat: added governance in constructor

* fix: linter

* feat: added inheritdoc for natpsec

* fix: remove delgate deployment script

* feat: improved tests

* fix: linter

* fix: typo

* feat: improved unit test
Copy link

@0xGorilla 0xGorilla left a comment

Choose a reason for hiding this comment

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

🔥

@wei3erHase wei3erHase changed the title feat: automated rKP3R reward distribution feat: automated rKP3R and ibEUR reward distribution Jul 5, 2022
gitbook-com bot pushed a commit to SeaSaltyFunk/ff that referenced this pull request Sep 30, 2022
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.

2 participants