{"id":19096890,"url":"https://github.com/makerdao/dss-crop-join","last_synced_at":"2025-04-18T16:31:32.783Z","repository":{"id":40650939,"uuid":"371376481","full_name":"makerdao/dss-crop-join","owner":"makerdao","description":null,"archived":true,"fork":false,"pushed_at":"2022-08-21T14:10:02.000Z","size":1640,"stargazers_count":17,"open_issues_count":6,"forks_count":9,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-11T20:37:53.884Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/makerdao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audits/ABDK_MakerDAO_Crop_Solidity.pdf","citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-27T13:06:25.000Z","updated_at":"2024-10-08T13:10:19.000Z","dependencies_parsed_at":"2022-08-10T00:00:33.175Z","dependency_job_id":null,"html_url":"https://github.com/makerdao/dss-crop-join","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fdss-crop-join","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fdss-crop-join/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fdss-crop-join/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makerdao%2Fdss-crop-join/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makerdao","download_url":"https://codeload.github.com/makerdao/dss-crop-join/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249517937,"owners_count":21284861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T03:38:05.432Z","updated_at":"2025-04-18T16:31:31.930Z","avatar_url":"https://github.com/makerdao.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"This is a collateral adapter for Dai that allows for the distribution of\nrewards given to holders of the collateral.\n\n## Rewards Adapter\n\nWe distinguish between `push` and `pull` rewards:\n\n- in `push` rewards, the rewards are sent to holders without their input.\n- in `pull` rewards, holders must actively claim their rewards.\n\n`push` rewards are supported by default. In principle any pull-based\ntoken rewards are supported, e.g. Compound `claimComp()` and SNX-staking\n`getReward()`, with a little custom claiming logic.\n\n### Usage\n\nDevelopers need to\n\n1) Override the `crop` function with the logic for claiming the given reward\n   token and then return the tokens gained since the last crop. The default\n   is the difference in the token balance and will work for push-reward tokens.\n\n2) Override the `nav` function to show the underlying balance of the adapter\n   (the Net Asset Valuation). The default is `gem.balanceOf(adapter)`.\n\n\nUsers can `join` and `exit` as with regular adapters. The user receives\ntheir pending rewards on every `join` / `exit` and can use e.g. `join(0)`\nto receive their rewards without depositing additional collateral.\n\nThere are two additional functions:\n\n- `flee` allows for `exit` without invoking `crop`, in case of some\n  issue with the `crop` function.\n\n- `tack` is for transferring `stake` between users, following collateral\n  transfers inside the `vat`.\n\n\n#### `tack`\n\nCollateral can be transferred in [dss] in several ways: simply via\n`flux`, but also via `grab` and `frob`. `frob` and `flux` are publically\ncallable, which means that the rewards for a user may not match their\ncollateral balance. This is not a problem in itself as it isn't possible\nto exit collateral without having the appropriate `stake`, so it isn't\npossible to game rewards through e.g. `join($$$); flux(me, me2, $$$); flee($$$)`.\n\nHowever, recipients of auction proceeds will need the appropriate\n`stake` if they wish to exit.  The winner of a collateral auction receives\ntheir collateral via `clip.take`. This increases their collateral\nbalance, but not their `stake`. `tack` allows this stake to be acquired,\nfrom other users that have an excess of stake.\n\nIt isn't strictly necessary to alter the collateral auction contract, as\n`tack` can be called by users, but it would be convenient to add a\n`tack` after every `flux`:\n\n    vat.flux(ilk, a, b, x);\n    join.tack(a, b, x);\n\nThen rewards will continue to accumulate throughout the auction and will\nbe distributed appropriately to the winner and the CDP owner, with the winner\nable to reap their rewards following `take`.\n\n\n### Terms\n\n- `gem`: the underlying collateral token\n- `nav`: Net Asset Valuation, total underlying gems held by adapter\n- `nps`: `nav` per stake\n- `stake`: gems per user\n- `total`: total `stake`\n- `bonus`: the reward token, e.g. COMP\n- `stock`: last recorded balance of reward token\n- `share`: accumulated `bonus` per `gem`\n- `crops`: accumulated `bonus` per `gem` per user\n\n### Proxy Actions\n\nThis repository also includes proxy action functions, located in the DssProxyActionsCropper and DssProxyActionsEndCropper contracts. They are to be used via ds-proxy, similarly to [dss-proxy-actions](https://github.com/makerdao/dss-proxy-actions).\nThese actions interact with the Cropper and [dss-cdp-registry](https://github.com/makerdao/dss-cdp-registry).\nThe implementation assumes net asset per share (`CropJoin.nav()`) is 1.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakerdao%2Fdss-crop-join","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakerdao%2Fdss-crop-join","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakerdao%2Fdss-crop-join/lists"}