whenubelieve / opium-contracts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Opium contracts

Opium Protocol consist of Opium Main Smart Contracts set introduced in this repository alongside with Opium token standard smart contracts

Documentation

Protocol documentation can be found here https://docs.opium.network/

Generated documentation for code can be found here

Audit

Protocol was audited by:

Opium protocol is deployed on following addresses

Ethereum

Mainnet

Rinkeby

Polygon (Matic)

Mainnet

Mumbai

BSC

Mainnet

Testnet

High-level flow description of user behavior

  1. Users approve their ERC20 tokens to TokenSpender
  2. Users choose orders on relayer frontend, sign them and pass it to relayer
  3. Relayer settles matched orders by sending them to Match or SwaprateMatch contracts depending on Order type
  4. Matching contracts validate whether all conditions for orders are met, collect margin from buyer and seller, send it to Core with position creations command
  5. Core validates derivative according to syntheticId logic, collects margin from Matching contracts and mints position tokens with TokenMinter
  6. At execution time (maturity) users call core to burn their position tokens and receive payout from derivative
  • All smart contracts get each others addresses using Registry contract
  • Contracts in contracts/test folder are mocks and helpers for testing
  • TokenMinter implements ERC721O

opiumFlow

Documentation and tests status of Opium contracts (would be updated with additional documentation and tests)

docsAndTestsStatus

Tests

Tests are running against ganache-cli

    npm run test

Because timeTravel is used in tests, each run should be running on new ganache-cli instance

Copyright © 2020 Blockeys BV. All rights reserved.

About

License:Other


Languages

Language:JavaScript 41.5%Language:TypeScript 32.2%Language:Solidity 26.3%