Giter Club home page Giter Club logo

fractional-wrapper's Introduction

Updated problem statement

Users can send a pre-specified erc-20 token (underlying) to an ERC20 contract(Fractional Wrapper).

Fractional Wrapper contract issues a number of Wrapper tokens to the sender, equal to the deposit multiplied by a fractional number, called exchange rate. Exchange rate is set by the contract owner.

This number is in the range of [0, 1000000000000000000], and available in increments of 10**-27. (ray).

At any point, a holder of Wrapper tokens can burn them to recover an amount of underlying equal to the amount of Wrapper tokens burned, divided by the exchange rate.

  1. User sends DAI to FWrapper.
  2. User receives wDAI(wDAI = DAI * ex_rate)
  3. Exchange rate set by FWrapper owner
  4. Ex_rate is has decimal precision of 10**27 precision
  5. User can liquidate and get back underlying DAI, (wDAI is burnt) ---> dai_qty = wDAI/ex_rate

Contracts

  1. DAIToken - underlying
  2. FractionalWrapper - "vault w/ ex_rate"
  3. Ownable.sol - for onlyOwner modifier, applied on setExchangeRate

Both contracts are ERC20Mock, to issue tokens. FractionalWrapper must conform to ERC4626 specification.

  • all methods must be implemented
  • implementation of convert* and preview* will be identical in this case (no need to calculate some time-weighted average for convert*).

Functions

maxDeposit/maxMint

  • dropped receiver param as specified in EIP4626, as there was no need for it in this use case.
  • made virutal so it can be overwritten for another use case.

fractional-wrapper's People

Contributors

calnix avatar

Watchers

 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.