{"_id":"@b0dhidharma/strategies-keep3r","_rev":"3-7559a507e1a57193cc9cc4a930166a32","name":"@b0dhidharma/strategies-keep3r","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@b0dhidharma/strategies-keep3r","version":"0.0.1","description":"Strategies Keep3r","keywords":["ethereum","yearn","keep3r","smart","contracts","solidity","hardhat"],"repository":{"type":"git","url":"git+https://github.com/yearn/strategies-keep3r.git"},"scripts":{"compile":"npx hardhat compile","coverage":"npx hardhat coverage","fork":"FORK=true npx hardhat node","fork:script":"FORK=true npx hardhat run","fork:test":"FORK=true npx hardhat test","lint:check":"solhint 'contracts/**/*.sol' && prettier --check './**'","lint:fix":"sort-package-json && prettier --write './**' && solhint --fix 'contracts/**/*.sol'","sizer":"TEST=true hardhat compile && TEST=true npx hardhat size-contracts","test":"TEST=true npx hardhat compile && TEST=true npx hardhat test","test:all":"yarn test ./test/e2e/*.spec.ts test/integration/*.spec.ts test/unit/*.spec.ts","test:e2e":"yarn test ./test/e2e/*.spec.ts","test:gas":"yarn test ./test/e2e/*.spec.ts test/unit/*.spec.ts","test:integration":"yarn test ./test/integration/*.spec.ts","test:unit":"yarn test test/unit/*.spec.ts"},"dependencies":{"@gnosis.pm/safe-core-sdk":"0.3.1","@gnosis.pm/safe-service-client":"0.1.1","@openzeppelin/contracts":"4.3.2","deasync":"0.1.23","inquirer":"8.2.0","prompt-confirm":"2.0.4","qs":"6.10.1","queue-microtask":"1.2.3"},"publishConfig":{"access":"public"},"authors":[{"name":"Luciano Bertenasco","email":"mail","url":"https://github.com/lbertenasco"},{"name":"b0dhidharma","email":"b0dhidharma@protonmail.com","url":"https://github.com/b0dhidharma"}],"gitHead":"0af6720d30e6c815c78fa43f6312c670db646b4c","bugs":{"url":"https://github.com/yearn/strategies-keep3r/issues"},"homepage":"https://github.com/yearn/strategies-keep3r#readme","_id":"@b0dhidharma/strategies-keep3r@0.0.1","_nodeVersion":"12.20.0","_npmVersion":"lerna/4.0.0/node@v12.20.0+x64 (linux)","dist":{"integrity":"sha512-28Ty8VvNBwXvWPe0xCO9D9+X59Llo8xW/fFt4eL80zgACQwdvWAZiTyhTUeXTsp0Kpc6Q3MSQ13QrCUtvos8dQ==","shasum":"bf0e0ca079631d2eb035f1669ea8e1ac969acd0f","tarball":"https://registry.npmjs.org/@b0dhidharma/strategies-keep3r/-/strategies-keep3r-0.0.1.tgz","fileCount":347,"unpackedSize":3466858,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD8V1tjCI1uwSIh0YgL96bI7bRjbH92vw2fF0OA3eF9egIhAOMe9uHohylFx7eIV8KoeP8n32DqX5MABia9D5B6R5qR"}]},"_npmUser":{"name":"b0dhidharma","email":"b0dhidharma@protonmail.com"},"directories":{},"maintainers":[{"name":"b0dhidharma","email":"b0dhidharma@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strategies-keep3r_0.0.1_1635284815396_0.17540387851088934"},"_hasShrinkwrap":false},"0.0.2":{"name":"@b0dhidharma/strategies-keep3r","version":"0.0.2","description":"Strategies Keep3r","keywords":["ethereum","yearn","keep3r","smart","contracts","solidity","hardhat"],"homepage":"https://github.com/b0dhidharma/monorepo/packages/strategies-keep3r#readme","repository":{"type":"git","url":"git+https://github.com/b0dhidharma/monorepo.git","directory":"packages/strategies-keep3r"},"scripts":{"compile":"npx hardhat compile","coverage":"npx hardhat coverage","fork":"FORK=true npx hardhat node","fork:script":"FORK=true npx hardhat run","fork:test":"FORK=true npx hardhat test","lint:check":"solhint 'contracts/**/*.sol' && prettier --check './**'","lint:fix":"sort-package-json && prettier --write './**' && solhint --fix 'contracts/**/*.sol'","sizer":"TEST=true hardhat compile && TEST=true npx hardhat size-contracts","test":"TEST=true npx hardhat compile && TEST=true npx hardhat test","test:all":"yarn test ./test/e2e/*.spec.ts test/integration/*.spec.ts test/unit/*.spec.ts","test:e2e":"yarn test ./test/e2e/*.spec.ts","test:gas":"yarn test ./test/e2e/*.spec.ts test/unit/*.spec.ts","test:integration":"yarn test ./test/integration/*.spec.ts","test:unit":"yarn test test/unit/*.spec.ts"},"dependencies":{"@b0dhidharma/contract-utils":"^0.1.1","@gnosis.pm/safe-core-sdk":"0.3.1","@gnosis.pm/safe-service-client":"0.1.1","@openzeppelin/contracts":"4.3.2","deasync":"0.1.23","inquirer":"8.2.0","prompt-confirm":"2.0.4","qs":"6.10.1","queue-microtask":"1.2.3"},"publishConfig":{"access":"public"},"authors":[{"name":"Luciano Bertenasco","email":"mail","url":"https://github.com/lbertenasco"},{"name":"b0dhidharma","email":"b0dhidharma@protonmail.com","url":"https://github.com/b0dhidharma"}],"gitHead":"2c080d4134aa4e52977abf0f909967cea3569ae3","bugs":{"url":"https://github.com/b0dhidharma/monorepo/issues"},"_id":"@b0dhidharma/strategies-keep3r@0.0.2","_nodeVersion":"12.20.0","_npmVersion":"lerna/4.0.0/node@v12.20.0+x64 (linux)","dist":{"integrity":"sha512-GT2jIbB3mZqVKJl0bggEEU5OK3lnCwIjmIj/TWAjdOLRCUegqAektVS7MrqZ5F4m5NwMnhDJ4Mrp0/7s2addlQ==","shasum":"58299039b8c96ad54567802d014f455ebc2fb7e0","tarball":"https://registry.npmjs.org/@b0dhidharma/strategies-keep3r/-/strategies-keep3r-0.0.2.tgz","fileCount":426,"unpackedSize":4544459,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzHB5CRA9TVsSAnZWagAA0lAP/2kSRqroTDuGJoAB+yYE\ncPvINDZgKEPk0Z/Scn7AbB+01D3FGmf4EXvDSSEVGumyHxdQQXBA5ampoYIp\nJ+vwE3yNXNnkehbcMd3HeM+6hLEGwJGS1BXi9ueoimhJvlfQrSJArZeKxo+8\nOXtcTQ/OXerKxykoltdx0cRbnNfbpC/kxD4w4bc8SV51sdr6TtmG59qL9Uo6\nE11vjaI/TklGmgPd0jU8n1y8AhlMIP5fL7SXStQx+m3b2a4pHhDf6UIRlNsZ\nzPqdwCKH+D44SvUwe96STO5BLxcKDGYs8gvkLdb9OoAXpRWZ3tkEej8pyPY1\n+370czpQfQNVthts9/F+/O+tAVR+xj4RwwH+Hhi1ChnRwQ577Km0tfAhnU4X\n5Y8AbIv6snQk/wOKPU07QIi2lcgFqiMeyVFlNqW6Z5m5dXY53cXmzLC70CGX\nerjGNu53dwASFcY+zObLMIEJNWbYgltaEk3cmohakJCuFKgo9aC5IK1djMD0\nKFAtFkGJwi0EoQEHtk5AHtsLRGq4BH0Oo1iBPlKgCKIt3FmXIRBTgiv0rB4L\nHXQ40Mm4YoCPHm+qFUmM89n7X6cn85BGdSXKvSSjGSjMf+BcCg8fBRTrHiQ2\n9kK1dP/aEFajWyTN88mQXd5kTeEfHEAWyXYmZJ/oQ10nydUv2zw7lMav0FAD\ngKwz\r\n=l8fi\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICsZqK1f9OJy140htxDqHsQota1HKgFekrSc11ITWp7xAiBV0YA6lbhCYVGW+hjpaHZgwrpIhIYFzqSB9g5ZX9WIZw=="}]},"_npmUser":{"name":"b0dhidharma","email":"b0dhidharma@protonmail.com"},"directories":{},"maintainers":[{"name":"b0dhidharma","email":"b0dhidharma@protonmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/strategies-keep3r_0.0.2_1635517954579_0.7770137618350337"},"_hasShrinkwrap":false}},"time":{"created":"2021-10-26T21:46:55.345Z","0.0.1":"2021-10-26T21:46:55.553Z","modified":"2022-04-04T17:23:52.063Z","0.0.2":"2021-10-29T14:32:35.040Z"},"maintainers":[{"name":"b0dhidharma","email":"b0dhidharma@protonmail.com"}],"description":"Strategies Keep3r","homepage":"https://github.com/b0dhidharma/monorepo/packages/strategies-keep3r#readme","keywords":["ethereum","yearn","keep3r","smart","contracts","solidity","hardhat"],"repository":{"type":"git","url":"git+https://github.com/b0dhidharma/monorepo.git","directory":"packages/strategies-keep3r"},"bugs":{"url":"https://github.com/b0dhidharma/monorepo/issues"},"readme":"# Strategies Keep3r\n\n## Wishlist\n\n### Strategies\n\n- [x] [`CRV`](./contracts/keep3r/CrvStrategyKeep3r.sol) (`ycrv, busd, sbtc, 3pool, comp`)\n- [x] [`DForce`](./contracts/keep3r/DforceStrategyKeep3r.sol) (`usdt, usdc`)\n- [ ] (define next strats to keep3rfy)\n\n### Vaults\n\n- [x] [`yearn`](./contracts/keep3r/VaultKeep3r.sol) (`yCrv, busdCrv, sbtcCrv, 3poolCrv, compCrv`)\n- [ ] (add more vautls to yearn vault keep3r)\n- [ ] (define next vaults types to keep3rfy)\n\n## Scripts\n\n### Get available rewards and workable for CRV (ycrv, busd, sbtc, 3pool, comp) strategies.\n\n`npx hardhat run scripts/crv/01-crv-keep3r-calculate-harvest.js`\n\n### Get available rewards and workable for DForce (sdt, usdc) strategies.\n\n`npx hardhat run scripts/dforce/01-dforce-keep3r-calculate-harvest.js`\n\n### Get available earn and workable for yearn (yCrv, busdCrv, sbtcCrv, 3poolCrv, compCrv) vaults.\n\n`npx hardhat run scripts/vault/01-vault-keep3r-calculate-earn`\n\n## Contracts\n\n---\n\n> keep3r\n\n### [`Keep3rAbstract.sol`](https://github.com/lbertenasco/contract-utils/blob/main/contracts/keep3r/Keep3rAbstract.sol)\n\nAbstract contract that should be used to extend from when creating StrategyKeep3rs (see [`CrvStrategyKeep3r.sol`](./contracts/keep3r/CrvStrategyKeep3r.sol))\n\n```sol\n  IKeep3rV1 public keep3r;\n  address public bond;\n  uint256 public minBond;\n  uint256 public earned;\n  uint256 public age;\n  constructor(address _keep3r) public\n  function _setKeep3r(address _keep3r) internal\n  function _setKeep3rRequirements(address _bond, uint256 _minBond, uint256 _earned, uint256 _age, bool _onlyEOA) internal\n  function _isKeeper() internal\n  modifier onlyKeeper()\n  modifier paysKeeper()\n  modifier paysKeeperAmount(uint256 _amount)\n  modifier paysKeeperCredit(address _credit, uint256 _amount)\n  modifier paysKeeperEth(uint256 _amount)\n```\n\n### [`MetaKeep3r.sol`](./contracts/keep3r/MetaKeep3r.sol)\n\n> TODO\n\n### [`CrvStrategyKeep3r.sol`](./contracts/keep3r/CrvStrategyKeep3r.sol)\n\n> [verified on etherscan](https://etherscan.io/address/0xd0aC37E3524F295D141d3839d5ed5F26A40b589D#code)\n\nYearn v1 CrvStrategies Keep3r for `ycrv`, `busd`, `sbtc`, `3pool` and `comp` vaults/strats.\n\n```sol\nmapping(address => uint256) public requiredHarvest;\nfunction isCrvStrategyKeep3r() external pure override returns (bool) { return true; }\n```\n\nGovernor (strategist) functions:\n\n```sol\nfunction addStrategy(address _strategy, uint256 _requiredHarvest) external override onlyGovernor;\nfunction updateRequiredHarvestAmount(address _strategy, uint256 _requiredHarvest) external override onlyGovernor;\nfunction removeStrategy(address _strategy) external override onlyGovernor;\nfunction setKeep3r(address _keep3r) external override onlyGovernor;\nfunction setKeep3rRequirements(address _bond, uint256 _minBond, uint256 _earned, uint256 _age, bool _onlyEOA) external override onlyGovernor;\n# safeguard that allows governor(strategist) to call harvest directly, not having to go through keep3r network.\nfunction forceHarvest(address _strategy) external override onlyGovernor;\n```\n\nKeep3r functions\n\n```sol\n# Called externally to get available strategies to do work for\nfunction strategies(address _strategy) public view override returns (address[] memory _strategies);\n# Called externally to get available harvest in CRV by strategy\nfunction calculateHarvest(address _strategy) public override returns (uint256 _amount);\n# returns true if available harvest is greater or equal than required harvest\nfunction workable(address _strategy) public override returns (bool);\n# pays keep3rs to call havest on crv strategies\nfunction harvest(address _strategy) external override onlyKeeper paysKeeper;\n```\n\n> call `calculateHarvest` and `workable` functions with `callStatic` to avoid spending gas. (they can be pretty slow too)\n\n### [`DforceStrategyKeep3r.sol`](./contracts/keep3r/DforceStrategyKeep3r.sol)\n\n> [verified on etherscan](https://etherscan.io/address/0x30084324619D9645019C3f2cb3a94611601a3078#code)\n\n> Almost the same functions as `CrvStrategyKeep3r`.\n\n```sol\nEnumerableSet.AddressSet internal availableStrategies;\nmapping(address => uint256) public requiredHarvest;\nfunction isDforceStrategyKeep3r() external pure override returns (bool) { return true; }\n```\n\nKeep3r functions\n\n```sol\n# Called externally to get available strategies to do work for\nfunction strategies(address _strategy) public view override returns (address[] memory _strategies);\n# Called externally to get available harvest in DForce rewards by strategy\nfunction calculateHarvest(address _strategy) public view override returns (uint256 _amount);\n# returns true if available harvest is greater or equal than required harvest\nfunction workable(address _strategy) public view override returns (bool);\n# pays keep3rs to call havest on crv strategies\nfunction harvest(address _strategy) external override onlyKeeper paysKeeper;\n```\n\n### [`VaultKeep3r.sol`](./contracts/keep3r/VaultKeep3r.sol)\n\n> [verified on etherscan](https://etherscan.io/address/0x054A87DdFdE3ccb5DDB03739375329BcC1b03203#code)\n\n```sol\nmapping(address => uint256) public requiredEarn;\nmapping(address => uint256) public lastEarnAt;\nuint256 earnCooldown;\nEnumerableSet.AddressSet internal availableVaults;\nfunction isVaultKeep3r() external pure override returns (bool) { return true; }\n```\n\nGovernor (strategist) functions:\n\n```sol\nfunction addVault(address _vault, uint256 _requiredEarn)\n  external\n  override\n  onlyGovernor;\n\nfunction updateRequiredEarnAmount(address _vault, uint256 _requiredEarn)\n  external\n  override\n  onlyGovernor;\n\nfunction removeVault(address _vault) external override onlyGovernor;\n\nfunction setEarnCooldown(uint256 _earnCooldown) external override onlyGovernor;\n\n```\n\nKeep3r functions\n\n```sol\n# Called externally to get available vaults to do work for\nfunction vaults(address _vault) public view override returns (address[] memory _vaults);\n# Called externally to get available earn in yearn by vault\nfunction calculateEarn(address _vault) public view override returns (uint256 _amount);\n# returns true if available earn is greater or equal than required earn and earnCooldown has elapsed\nfunction workable(address _vault) public view override returns (bool);\n# pays keep3rs to call havest on crv vaults\nfunction earn(address _vault) external override onlyKeeper paysKeeper;\n```\n\n---\n\n> mock\n\n### [`MockStrategy.sol`](./contracts/mock/MockStrategy.sol)\n\n> TODO\n\n### [`StrategyCurveYVoterProxyAbstract.sol`](./contracts/mock/StrategyCurveYVoterProxyAbstract.sol)\n\n> TODO\n\n## Adding new StrategyKeep3rs\n\n- you can use [`CrvStrategyKeep3r.sol`](./contracts/keep3r/CrvStrategyKeep3r.sol) as a template\n\n- adapt neccesarry functionality fo fit strategy requirements\n\n- modify `calculateHarvest` function to get your strategy pending rewards correctly\n\n  - it's better to have both `workable` and `calculateHarvest` as `view` functions, `CrvStrategyKeep3r` is not a good example for this.\n    - > it's not a view function since it has to call a crv state-modifiyng function to calculate rewards.\n    - > check [`CrvStrategyKeep3r-test.js`](./test/CrvStrategyKeep3r-test.js) for details on how to handle calls to non-view `workable` functions.\n\n- make sure you have a `harvest` function that has the `paysKeeper` modifier.\n- make sure you have a `forceHarvest` function that has the `onlyGovernor` modifier.\n\n- also take into account that any `onlyStrategist` functions on the strategy will need an `onlyGovernor` proxy function on your keep3r\n  - i.e. if the strategy contract has a `configureStrategy(...) onlyStrategist || msg.sender == strategist` you'll need to create a ` configureStrategy(...) onlyGovernor` on your `StrategyKeep3r` contract to keep having access to that method.\n\n## Useful tips for Keep3r Scripts :)\n\n- call `strategies()` function with `callStatic` to get all available strategies, loop through them to check for work.\n- always call `workable(address _strategy)` function with `callStatic` to avoid spending gas. (they can be pretty slow too)\n- always call `harvest(address _strategy)` function with `callStatic` before sending the real TX to make sure you wont get a revert. (they can be pretty slow too)\n- on `VaultKeep3r` use `vaults()` and `earn(address _vault)`\n","readmeFilename":"README.md"}