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
- LibPosition was deployed at 0x56c54b408c44B12f6c9219C9c73Fcda4E783FC20
- Registry was deployed at 0x7f5f4087006ba4f4985b32f9d1079ee2f8594af8
- Core was deployed at 0xd60F0A53c7e97f78fe4AC9013F5749920C601494
- SwaprateMatch was deployed at 0x09a439c50465e447cb1a662da536f23a7e39374e
- TokenSpender was deployed at 0x8bd75f96EfA089aEcf6Ac4CD0B671e2428f4B2af
- TokenMinter was deployed at 0x35Aab5c69cEA76E643Fd3287aC9523bD670445b2
- OracleAggregator was deployed at 0xB69890912E40A7849fCA058bb118Cfe7d70932c4
- SyntheticAggregator was deployed at 0x3a943C50Bcde3E357916ce6E109626213Fd36105
Rinkeby
- LibPosition was deployed at 0xecfb28f107de2bFB325E339293dE3A01C1CfFA74
- Registry was deployed at 0xE665EA43121674964bcd330F65D512e718b7A50b
- Core was deployed at 0xE995d8E9E0a01c938e6ae5B05720Af245953dC57
- Match was deployed at 0x00bC68b57dbEdcffe3007890f581f1BE0a2CddaE
- SwaprateMatch was deployed at 0xC80B660E445d764B7741b59A33818d6526A830B2
- TokenSpender was deployed at 0xE39b9D5dC766102181D4C5Cd7df1691565B52032
- TokenMinter was deployed at 0xDEe1031c5D64788976E78d78c63C2fd6b411c4ee
- OracleAggregator was deployed at 0xe1Fd20231512611a5025Dec275464208070B985f
- SyntheticAggregator was deployed at 0x8Fb660ab5542D752047312443742f209C88E2170
Polygon (Matic)
Mainnet
- LibPosition was deployed at 0xd85De2Eb815eF57c84531Bc2397407B18E62C9d7
- Registry was deployed at 0x1213b2951B48a39981801e059223827ce4182354
- Core was deployed at 0xB3F6281655276150E97e5029B607a6D4d2E21972
- TokenSpender was deployed at 0xC7b068B897507312c2DACEd5E537eB658c49608D
- TokenMinter was deployed at 0x880e37B98f7c058b3563970F256614FF4a580637
- OracleAggregator was deployed at 0x56c54b408c44B12f6c9219C9c73Fcda4E783FC20
- SyntheticAggregator was deployed at 0xC955F3c0d5a87710996D13B1f9AA3A77552D7a7E
Mumbai
- LibPosition was deployed at 0x0cE1f283ca59C4F7fE7581DDb94e08eBff17869E
- Registry was deployed at 0xF228cA0a9c1A62C3b69454C6dB35d77f359D7ee1
- Core was deployed at 0x2c8c1bf1d072dfec1cBd39512aA02DF2F0943221
- Match was deployed at 0x17f47E461DFdC7c6ee320044B730588407d841f3
- SwaprateMatch was deployed at 0xdEa52ff7B21adc17FdbA46B6052aF9B1c0399565
- TokenSpender was deployed at 0x3F1fF59Ba18C8b540Be9d5Affe63a536e08dF36A
- TokenMinter was deployed at 0x6137B159970e8c9C26f12235Fb6609CfBC6EE357
- OracleAggregator was deployed at 0xa46e8eD10B0CD1FD75DC23210a5e351A1C9dE9dd
- SyntheticAggregator was deployed at 0x411b868dF2Ca9C6dc889d48019B08779747a7b8f
BSC
Mainnet
- LibPosition was deployed at 0x780F4b0E786bD703F21E4D22F48Ced4A877845De
- Registry was deployed at 0x2e9AC4D0882165dCE317F23925060Ca3551782a9
- Core was deployed at 0xC1e31C2db9f238809FE58089a7Fa7cE5aA7E52c6
- TokenSpender was deployed at 0xAb87BcB35bd0871f8278786AD75b06990d6373B3
- TokenMinter was deployed at 0x90716893C1012166F2F182b61f69f0391673dD88
- OracleAggregator was deployed at 0xC7b068B897507312c2DACEd5E537eB658c49608D
- SyntheticAggregator was deployed at 0x50680ea9B104ab8c70Ae80c46F4715a7531b3765
Testnet
- LibPosition was deployed at 0x9857f4030a76c0e2F08811DdA016eF157b0A738E
- Registry was deployed at 0xc19397ccCB7EDdFb83533cfdE6d21EfC2EB860ef
- Core was deployed at 0x05D3b4cb841F1A05736010aa1fd59389bC88770B
- Match was deployed at 0x12d0E89911130698150C5c13F964AAc468a2B076
- SwaprateMatch was deployed at 0x2B289C6271d259515fA9cca8978ca4BAb4ff1e7F
- TokenSpender was deployed at 0xF343EE410b7a313511845e964a9f6E4adBDF0398
- TokenMinter was deployed at 0xF228cA0a9c1A62C3b69454C6dB35d77f359D7ee1
- OracleAggregator was deployed at 0x2c8c1bf1d072dfec1cBd39512aA02DF2F0943221
- SyntheticAggregator was deployed at 0x17f47E461DFdC7c6ee320044B730588407d841f3
High-level flow description of user behavior
- Users
approve
their ERC20 tokens toTokenSpender
- Users choose orders on relayer frontend, sign them and pass it to relayer
- Relayer settles matched orders by sending them to
Match
orSwaprateMatch
contracts depending onOrder
type - Matching contracts validate whether all conditions for orders are met, collect margin from buyer and seller, send it to
Core
with position creations command Core
validates derivative according tosyntheticId
logic, collects margin from Matching contracts and mints position tokens withTokenMinter
- 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
Documentation and tests status of Opium contracts (would be updated with additional documentation and tests)
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
LICENSE
Copyright © 2020 Blockeys BV. All rights reserved.