Code Monkey home page Code Monkey logo

charm-options's Introduction

Charm Finance

Charm Finance is an AMM (automated market-maker) for options on Ethereum

It uses an LS-LMSR (Othman et al., 2013) to price the options. In short, it acts like token bonding curve, minting/burning option tokens as users buy/sell them.

At expiration, the settlement price is fetched from a Uniswap V2 oracle. Users can them redeem their options for the settlement value

This repo also includes an ERC20 governance token and staking reward pools

Owner privileges

Please note the owner of the options market is highly privileged and has the permissions below. These are only intended to be used in an emergency situation. These permissions will be removed in future versions.

  • Pause the contract indefinitely. This includes preventing users from buying, selling, and redeeming their options.

  • Change the contract’s oracle. If an invalid or malicious oracle is provided, users can potentially lose funds.

  • Change the contract’s expiry date.

  • Prematurely settle the contract before its expiry date.

Repo

The main contract is OptionsMarketMaker.sol. This contains methods buy and sell that let users mint/burn options. Calling settle after expiration fetches the settlement price from the oracle and users can call redeem to redeem their options for the settlement value.

OptionsToken.sol is an ERC20 token representing ownership of an option.

UniswapOracle.sol is used by OptionsMarketMaker.sol to fetch the TWAP price at expiration from a Uniswap market.

CharmToken.sol is an ERC20 token that will be distributed as incentives/rewards and used for governance

rewards/StakingRewards.sol let users stake an ERC20 token to receive Charm tokens. It's based on https://github.com/Synthetixio/synthetix/blob/develop/contracts/StakingRewards.sol.

rewards/SeedRewards.sol is similar to StakingRewards.sol but instead of receiving/sending a staking token, it directly buys/sells options in the market-maker. This allows users to deposit/withdraw liquidity with a single transaction.

Pausable.sol is extended by OptionsMarketMaker.sol and StakingRewards.sol and allows the owner to pause deposits in those contracts.

contracts/mocks contains mock contracts for unit tests which include methods for setting fake data in them.

We use the log and exp methods in the library ABDKMath64x64.sol to calculate the LS-LMSR cost function in OptionsMarketMaker.sol.

We use UniERC20.sol as a wrapper around ETH and ERC20 tokens for convenience. It's based on https://github.com/CryptoManiacsZone/mooniswap/blob/master/contracts/libraries/UniERC20.sol

Commands

Run solidity formatter

npm run lint:fix

Run python formatter on unit tests

black .

Run unit tests

brownie test

Compile

brownie compile

charm-options's People

Contributors

mxwtnb avatar

Stargazers

 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.