Code Monkey home page Code Monkey logo

protocol's Introduction

Moved to https://github.com/0xcap/protocol-v4.


CAP v4 Solidity Contracts

TODO

For details on how the margin / trading system works, please check the Whitepaper, specifically sections 4 and 4.4. Liquidation Rebates and Interest Rate no longer apply.

The items below are listed in priority order. All milestones are ASAP, with a target production launch date of early January on Arbitrum. The driving factor is high quality, speed, and code simplicity.

  • Add automated tests, including fuzzy, to achieve > 90% coverage
  • Refactor code while maintaining readability
  • Run auditing tools, get more eyes on the contracts
  • Deploy and test locally with the UI to make sure everything is working as expected
  • Create production deploy scripts

Done

  • Add methods "depositThroughUniswap" and "addLiquidityThroughUniswap" to allow deposits from a contract like Uniswap Router, to allow people to deposit any asset which is then automatically converted into the Store-supported currency. Potentially support other DEXes like 1inch.
  • Verify Chainlink contract works as expected for Arbitrum and its sequencer. Support all other Chainlink networks (or have a custom Chainlink contract for each chain)
  • If submitOrder margin exceeds freeMargin, set it to the max freeMargin available
  • Treasury fees should be paid out to a treasury address directly (set by gov)
  • Add MAX_FEE and other constants in Store to curtail gov powers in methods marked with onlyGov. The goal is to prevent gov from having too much power over system function, like setting a fee share too high and siphoning all the funds.
  • All orders including market should execute through keepers, which can be anyone, either after minSettlementTime or if chainlink price changes
  • Trigger orders execute at the chainlink price, not the price they've set
  • Give traders option to retrieve margin, closing without profit, when P/L > 0. Useful in black swan scenarios to get their margin back.
  • Flat fee
  • Allow submitting TP/SL with an order
  • Contracts: Trade, Pool, Store, Chainlink

Compiling

forge build

Testing

FOUNDRY_PROFILE=lite forge test --match-contract <test_contract_name> -vvvv
FOUNDRY_PROFILE=lite forge test --match-test <test_function_name> -vvvv

Static code analysis with slither

slither .

Deploying locally

anvil
forge install
forge script DeployLocalScript --rpc-url http://127.0.0.1:8545 --broadcast -vvvv

Deploying

Set environment variables in .env and load them with

source .env

Then run the deploy script

forge script script/DeployProd.sol:DeployProd --broadcast --verify -vvvv

protocol's People

Contributors

beskay avatar kappacappa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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