Giter Site home page Giter Site logo

comet_wrapper's Introduction

CometWrapper

A wrapped token for any of the Compound III tokens.

Overview

Compound 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. This wrapped token allows other protocols to more easily integrate with Compound III tokens and treat it like any standard ERC20 token.

Design Decisions

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.

To 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.

Usage

CometWrapper implements the ERC4626 Tokenized Vault Standard and is used like any other ERC4626 contracts.

Wrapping Tokens

To wrap a Compound III token like cUSDCv3, you will need to have cUSDCv3 balance in your wallet and then do the following:

  1. comet.allow(cometWrapperAddress, true) - allow CometWrapper to move your cUSDCv3 tokens from your wallet to the CometWrapper contract when you call deposit or mint.
  2. cometWrapper.mint(amount, receiver) - the first parameter is the amount of Wrapped tokens to be minted. OR cometWrapper.deposit(amount, receiver) - the first parameter is the amount of Comet tokens that will be deposited.

Withdrawing Tokens

To witdhraw a Compound III token like cUSDCv3, you may use either withdraw or redeem. For example:

  • cometWrapper.withdraw(amount, receiver, owner) - amount is the number of Compound III tokens to be withdrawn. You can only withdraw tokens that you deposited.
  • 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.

comet_wrapper's People

Contributors

gjaldon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.