{"id":16019552,"url":"https://github.com/gjaldon/comet_wrapper","last_synced_at":"2025-03-18T03:31:17.834Z","repository":{"id":149548057,"uuid":"602411318","full_name":"gjaldon/comet_wrapper","owner":"gjaldon","description":"Wrapped Compound III Token","archived":false,"fork":false,"pushed_at":"2023-08-29T00:40:55.000Z","size":257,"stargazers_count":10,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-28T06:32:06.813Z","etag":null,"topics":["compound","defi","ethereum"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gjaldon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-16T06:32:49.000Z","updated_at":"2024-12-24T13:33:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a066182-09a7-4439-8b0c-e0102e1662c7","html_url":"https://github.com/gjaldon/comet_wrapper","commit_stats":{"total_commits":67,"total_committers":1,"mean_commits":67.0,"dds":0.0,"last_synced_commit":"b8a29577f1ce39e96a655c5b4414b648eda652dd"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gjaldon%2Fcomet_wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gjaldon%2Fcomet_wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gjaldon%2Fcomet_wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gjaldon%2Fcomet_wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gjaldon","download_url":"https://codeload.github.com/gjaldon/comet_wrapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243896636,"owners_count":20365407,"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":["compound","defi","ethereum"],"created_at":"2024-10-08T17:04:45.110Z","updated_at":"2025-03-18T03:31:17.828Z","avatar_url":"https://github.com/gjaldon.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CometWrapper\n\nA wrapped token for any of the Compound III tokens.\n\n## Deployments\n\n| Network  | Base Asset | CometWrapper Address                       |\n| -------- | ---------- | ------------------------------------------ |\n| Mainnet  | USDC       | Upcoming                                   |\n| Mainnet  | WETH       | Upcoming                                   |\n| Polygon  | USDC       | Upcoming                                   |\n| Arbitrum | USDC       | Upcoming                                   |\n| Avalance | USDC       | Upcoming                                   |\n| Base     | USDC       | Upcoming                                   |\n| Base     | WETH       | Upcoming                                   |\n\n## Overview\n\nCompound III tokens like cUSDCv3 and cWETHv3 are rebasing tokens. Protocols are designed to work with tokens that do not automatically increase balances like rebasing tokens do. The standard solution to this problem is to use a wrapped token.\nThis wrapped token allows other protocols to more easily integrate with Compound III tokens and treat it like any standard ERC20 token.\n\n## Design Decisions\n\n`CometWrapper` was designed to nullify inflation attacks which could cause losses for users. It's a method of manipulating the price of Wrapped tokens which enables attackers to steal underlying tokens from target depositors or make it prohibitively expensive for future depositors to use the contract.\n\nTo nullify inflation attacks, `CometWrapper` maintains internal accounting of all Compound III tokens deposited and withdrawn. This internal accounting only gets updated through the functions `mint`, `redeem`, `deposit` and `withdraw`. This means that any direct transfer of Compound III tokens will not be recognized by the `CometWrapper` contract to prevent malicious actors from manipulating the exchange rate of Wrapped Compound III token to the actual Compound III token. The tradeoff is that any tokens directly transferred to `CometWrapper` will be forever locked and unrecoverable.\n\n### Shares Redemption\n\nWhen doing Comet transfers, Comet may decrease sender's principal by 1 more than the specified amount in favor of the receiver. To take into account this quirk of Comet transfers, this CometWrapper will always transfer assets worth `shares - 1` and burn `shares` amount when calling `redeem`. \n\nIn this way, any rounding error would be in favor of CometWrapper and at the expense of users. The loss for users is negligible since it is only 1 unit of Wrapped cUSDCv3. However, this serves as protection against insolvency for CometWrapper so that it nevers ends up in a state where users' total shares is greater than the total supply of Wrapped cUSDCv3. Note that the loss of 1 share does not always happen for every redeem and in some cases the decrease in shares for the user and the contract is equal. \n\n### Non-standard ERC-4626 Behavior\n\n`mint` and `redeem` will not result in exactly `shares` amount of shares minted or redeemed, which is the standard behavior for ERC-4626. This is because CometWrapper uses `userBasic.principal` in Comet to represent `shares` and they map 1:1. Since principal in Comet may round up during transfers or round down during Comet.deposit() or Comet.withdraw(), shares minted or redeemed will have the same behavior. This tradeoff is done so we may maintain the invariant that `totalSupply` of shares in CometWrapper is always equal to the CometWrapper's `userBasic.principal` in Comet.\n\n## Usage\n\n`CometWrapper` implements the ERC4626 Tokenized Vault Standard and is used like any other ERC4626 contracts.\n\n### Wrapping Tokens\n\nTo wrap a Compound III token like cUSDCv3, you will need to have cUSDCv3 balance in your wallet and then do the following:\n\n1. `comet.allow(cometWrapperAddress, true)` - allow CometWrapper to move your cUSDCv3 tokens from your wallet to the CometWrapper contract when you call `deposit` or `mint`.\n2. `cometWrapper.mint(amount, receiver)` - the first parameter is the amount of Wrapped tokens to be minted.\n   OR `cometWrapper.deposit(amount, receiver)` - the first parameter is the amount of Comet tokens that will be deposited.\n\n### Withdrawing Tokens\n\nTo withdraw a Compound III token like cUSDCv3, you may use either `withdraw` or `redeem`. For example:\n\n- `cometWrapper.withdraw(amount, receiver, owner)` - `amount` is the number of Compound III tokens to be withdrawn. You can only withdraw tokens that you deposited.\n- `cometWrapper.redeem(amount, receiver, owner)` - `amount` is the number of Wrapped Compound III tokens to be redeemed in exchange for the deposited Compound III tokens.\n\n### Claiming Rewards\n\nComet tokens deposited in CometWrapper will continue to accrue rewards if reward accrual is enabled in Comet. CometWrapper keeps track of users' rewards and users would earn rewards as they would in Comet. The only difference is in claiming of the rewards. Instead of claiming rewards from the CometRewards contract, users will claim it from CometWrapper like so `cometWrapper.claimTo(alice)`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgjaldon%2Fcomet_wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgjaldon%2Fcomet_wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgjaldon%2Fcomet_wrapper/lists"}