All Projects → mcdexio → mai-protocol

mcdexio / mai-protocol

Licence: Apache-2.0 license
A Protocol for trading decentralized derivatives on Ethereum

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to mai-protocol

core
SIREN Core Smart Contracts
Stars: ✭ 39 (+77.27%)
Mutual labels:  smart-contracts, derivatives, defi
Smart-Contract-Security-Audits
Certified Smart Contract Audits (Ethereum, Hyperledger, xDAI, Huobi ECO Chain, Binance Smart Chain, Fantom, EOS, Tezos) by Chainsulting
Stars: ✭ 325 (+1377.27%)
Mutual labels:  smart-contracts, defi
clp-contracts
AMM and Continous Liquidity Provider smart contracts on NEAR blockchain
Stars: ✭ 25 (+13.64%)
Mutual labels:  smart-contracts, defi
ultimate-defi-research-base
Here we collect and discuss the best DeFI & Blockchain researches and tools. Feel free to DM me on Twitter or open pool request.
Stars: ✭ 1,074 (+4781.82%)
Mutual labels:  smart-contracts, defi
DeFi-Developer-Road-Map
DeFi Developer roadmap is a curated Web3.0 Developer handbook which includes a list of the best tools for DApps, development resources and lifehacks.
Stars: ✭ 5,658 (+25618.18%)
Mutual labels:  smart-contracts, defi
quipuswap-webapp
🌐 🧙‍♂️ Decentralized application UI for Quipuswap protocol.
Stars: ✭ 21 (-4.55%)
Mutual labels:  smart-contracts, defi
Blockchain-Alpha
Alpha from various sectors in the blockchain space.
Stars: ✭ 102 (+363.64%)
Mutual labels:  smart-contracts, defi
Scrypto-Advent-Calendar
Scrypto Advent Calendar. Learn the new programming langage to build secure DeFi applications quickly.
Stars: ✭ 22 (+0%)
Mutual labels:  smart-contracts, defi
eth option
ERC20-compatible Option Contracts
Stars: ✭ 22 (+0%)
Mutual labels:  smart-contracts, derivatives
quipuswap-core
🧙‍♂️ Repository containing QuipuSwap liquidity protocol smart-contracts written in Ligo language
Stars: ✭ 48 (+118.18%)
Mutual labels:  smart-contracts, defi
mStable-contracts
📃 Smart Contracts that make up the core of the mStable protocol
Stars: ✭ 277 (+1159.09%)
Mutual labels:  smart-contracts, defi
blockhead
Crypto portfolio tracker, DeFi dashboard, NFT viewer and data explorer for the Ethereum/EVM-based blockchain ecosystem and the web 3.0-powered metaverse https://gitcoin.co/grants/2966/blockhead
Stars: ✭ 41 (+86.36%)
Mutual labels:  smart-contracts, defi
uniswap-skim
scripts to scan all of the uniswapV2🦄 contracts on ethereum and search for skim opportunities
Stars: ✭ 126 (+472.73%)
Mutual labels:  smart-contracts, defi
awesome-waves
Curated list of awesome things for development on Waves blockchain.
Stars: ✭ 60 (+172.73%)
Mutual labels:  smart-contracts, defi
prb-math
Solidity library for advanced fixed-point math
Stars: ✭ 404 (+1736.36%)
Mutual labels:  smart-contracts, defi
challenge
Solidity Engineer Challenge
Stars: ✭ 94 (+327.27%)
Mutual labels:  smart-contracts, defi
ape
The smart contract development tool for Pythonistas, Data Scientists, and Security Professionals
Stars: ✭ 339 (+1440.91%)
Mutual labels:  smart-contracts, defi
zeneth
🏵️ Let Your ETH Chill — Gasless Ethereum account abstraction with Flashbots
Stars: ✭ 112 (+409.09%)
Mutual labels:  smart-contracts, defi
flow-protocol-ethereum
Flow Protocols powering synthetic asset and margin trading
Stars: ✭ 18 (-18.18%)
Mutual labels:  smart-contracts, defi
UpSideDai
⬆️ Take a HIGHLY leveraged position on the future price of DAI 📈.
Stars: ✭ 26 (+18.18%)
Mutual labels:  smart-contracts, defi

Build Status Coverage Status

Mai Protocol is a smart contract for building decentralized derivatives exchanges on Ethereum.

Mai Protocol's goal is to make trading decentralized derivatives easy and efficient.

The name Mai comes from two Chinese characters "买" which means buy and "卖" which means sell. Using pinyin (the modern system for transliterating Chinese characters to Latin letters) "买" is spelled Mǎi and "卖" is spelled Mài. Thus, "Mai" means "Buy" and "Sell".

See the document for more details about Mai Protocol.

Features

Mai Protocol smart contract v1.0 has the following attributes:

  • Trading Market Protocol contracts
    • Only two operations "Buy" and "Sell" for trading contracts
    • Encapsulates the minting, exchange and redeeming operations
    • A minting pool to reduce redundant minting and redeeming
  • No order collision
  • Accurate market orders
  • Ability to collect fees as a percentage of the collateral token
  • Allows asymmetrical maker/taker fee structure
  • Highly optimized gas usage

Interfaces

Mai Protocol:

structs:
  OrderParam                   parameters for building a taker/maker order
    - trader                   address of trader
    - amount                   the amount of position to buy/sell, decimals = 5
    - price                    the price of position, decimals = 10
    - gasTokenAmount           the gas fee for order matching, in collateral token. 
    - data                     a 32 bytes long data containing order details
        - version              mai protocol version, should match mai protocol contract on chain
        - side                 side of order, should be 0(buy) or 1(sell)
        - isMarketOrder        type of order, should be 0(limit order) or 1(market order)
        - expiredAt            order expiration time in seconds
        - asMakerFeeRate       trading fee rate as a maker (rate = asMakerFeeRate / 100,000)
        - asTakerFeeRate       trading fee rate as a taker (rate = asTakerFeeRate / 100,000)
        - makerRebateRate      reserved
        - salt                 a random nonce
        - isMakerOnly          to indicate the order should only be a maker
	
  OrderAddressSet              containing addresses common across each order
    - marketContractAddress    address of market protocol contract
    - relayer                  user acturally sending matching transaction and collecting trading fees during matching.
	
  Order                        containing necessary information of an order, built by OrderParam and OrderAddressSet

actions:
  matchMarketContractOrders        match orders from taker and makers to mint/redeem/exchange tokens published by Market Protocol contracts.
    - takerOrderParam              taker of the matching
    - makerOrderParams             makers of the matching, could be one or more
    - posFilledAmounts             an array representing how much positions should match for each take-maker pair. should have the same length with makerOrderParams
    - orderAddressSet              addresses sharing among taker and makers

  cancelOrder                      cancel an order, the canceled order can no longer match or be matched.
  
  setMarketRegistryAddress  owner  set a non-0x address market register to enable market contract is in the official publishing list.
  
  setMintingPool            owner  set collateral pool for proxy, see documents for details abount collateral pool 
  
  approveERC20              owner  approve a spender to transfer erc20 token from mai-protocol
  
  withdrawERC20             owner  withdraw erc20 token from mai-protocol. note that the mai-protocol itself should NEVER hold any token
  

MintingPool:

actions:
  approveERC20                  owner  approve a spender to transfer erc20 token from minting pool
  
  withdrawERC20                 owner  withdraw erc20 token from minting pool, usually the collateral token and the market token for minting market contract positions
  
  internalMintPositionTokens    owner        converting collateral in pool to position tokens for further minting requests
  internalRedeemPositionTokens  owner        converting position tokens in pool to collateral tokens for further redeeming requests

  mintPositionTokens            whitelisted  mint position tokens from collateral pool, then send minted tokens to caller
  redeemPositionTokens          whitelisted  redeem position tokens from collateral pool, then send redeemed tokens to caller

Installation

npm install

To build json ABI files:

npm run compile

Tests

npm run coverage

Audit

Mai-protocol have been audited by ChainSecurity. Check the report.

Acknowledgments

Mai is inspired by the 0x project and Hydro

License

This project is licensed under the Apache-2.0 License - see the LICENSE.txt file for details

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].