Coder Social home page Coder Social logo

0xfutures / protocol Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 5.0 4.07 MB

0xFutures Protocol Implementation

License: GNU General Public License v3.0

JavaScript 99.27% Shell 0.73%
ethereum smart-contracts blockchain derivatives futures solidity stablecoin dai

protocol's Introduction

npm version Build Status

0xFutures protocol

0xFutures protocol implementation

Setup

> npm i -g truffle
> npm i

Test

npm run publish-abi
npm test

Deploy Contracts (local node)

This deployment command will recompile contracts, update ABI, run tests and deploy contracts to the blockchain using a local synchronised Ethereum node.

// eg. kovan
> npm run deploy-kovan

NOTE: the very first time the contracts are deployed to a new network the deployer should run 'npm run deploy-<network>-first-time' instead of 'npm run deploy-<network>' as this will install the permanent Registry contract that all future deployments share. It contains a mapping of all CFDs ever created as well as the address of the most recent CFDFactory contract.

Deploy Contracts (Infura)

Runs the same steps as the 'local node' deploy above but will deploy using a remote infura node.

See config.kovan.infura.json.template for an example configuration. Put your Infura apikey and HD wallet mnemonic phrase in the config file.

// eg. kovan with infura config
> npm run deploy-kovan-infura

See the note about 'first-time' deployment above. This applies to Infura deployment also.

Publish NPM

// ensure repo has latest abi
> npm run publish-abi
> git add abi && git commit -m "updated ABI" abi

// ensure tests are passing
> npm test

// publish NPM
> npm version patch     # bumps the version number and tags the commit
> npm publish           # see package.json scripts prepare - this will run the tests before publishing
> git push --tags

npm

The package is published with the contract ABI JSON files (abi/) and js libraries (lib/) to @0xfutures/protocol.

protocol's People

Contributors

chatch avatar julien-rg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

protocol's Issues

Reduce proxy.sol creation gas cost

Strip out unused code to reduce the footprint.
proxy.sol along with note.sol and auth.sol were copied across from dappsys mostly unchanged.
Leave in just the peices required for 0xfutures needs.

Mutual Liquidation of CFD

Allow parties to liquidate the contract mutually.

Each will call a function "liquidateMutual" on the CFD. On the second parties call the contract will be liquidated at the current market price with collateral amounts distributed to each party.

This works similar to the forceTerminate function but will not incur a penalty to the force terminating party as both parties agree to the liquidation.

Kyber market srcQty amount must reflect precision of the src token

We've been assuming a precision of 18 on all tokens so far.

However market tokens we intend on using have different precision of 6 (USDC) and 8 (WBTC) respectively.

Ensure all srcQty amounts in the trade and getExpectedRate calls are calculated using the decimals amount on the src ERC20 contract.

Support CFD creation in ETH

Currently contract collateral is in DAI and creation of a new CFD requires DAI to be sent.

This issue will add support for sending of ETH which the contract will trade for DAI on the fly as part of the create CFD process.

Use KyberNetwork to do the trade on behalf of the caller.

Market pair order should be consistent

For example for the market "ETH/DAI" ETH should be the "source" / "from" token and DAI should be the "destinatinon" / "to" token in all cases.

Keep this order for price look ups, trades etc.

Currently we have it flipped around in PriceFeedsKyber calls which leads to confusion about the market rates.

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.