Primitive is a permissionless options protocol.
We overview the contracts and their functions as well as how to test them.
- Core Documentation: Documentation
- Protocol Overview: Overview
Our development environment consists of the following:
- Buidler - Framework
- Solidity Visual Auditor - VS Code
- Slither - static analyzer
- Solium - linter
- Web3/Truffle plugins for Buidler
- Mocha - testing framework
- Chai, chai-bn, and bn.js - unit testing
- Truffle assertions - unit testing
- Open Zeppelin Contracts - contract dependency
Status | Contract | Address | Link |
---|---|---|---|
Active | Prime Option | 0xced83f96AA38bFe34617ea1F699F9f0022548f61 | Etherscan |
Active | Prime Redeem | 0xB0A4d596939715f203Fa9E907935938FEdEa715F | Etherscan |
Active | Prime Trader | 0xff5C103d76586BB55bb33CE01f3dEc9cEe55617f | Etherscan |
Paused | Prime Pool | 0xf7a7126C6eB9c2cC0dB9F936bA4d0D5685662830 | Etherscan |
docker build -t primitive-contracts
docker run -it --name primitive primitive
npm run test
npm run coverage
Step 1 - Install Dependencies
npm run clean-install
Step 2 - Compile Contracts
npm run compile
Step 3 - Start Buidler EVM Node
npm run bevm
Step 4 - Run the tests
npm run test
Step 1
npm i
Step 2
npm compile
Step 3 - A forked mainnet node with network ID 999 is required.
npm start:f-mainnet
Step 4
npm test:f-mainnet
For coverage, we use buidler's plugin for solidity-coverage.
npm run coverage
For linting you can run this command which uses the solium linter:
npm run lint
Solium can also fix some linting errors which can be checked with this command:
npm run lint:fix
For static analysis you can run the contracts through slither with this command:
npm slither
The Prime is a smart token with vanilla option attributes and functionality embedded into the token. It inherits the ERC-20 token standard and adds functionality which matches the specification of a vanilla option.
- Underlying asset.
- Strike Price denominated in $USD.
- Expiration date.
- Address of underlying token.
- Address of stike token.
- "Base" value (Amount of underlying tokens).
- "Price" value (Amount of strike tokens).
- Expiration Date, a UNIX timestamp.
The Base and Price attributes make up the strike ratio.
- Base / Price = Strike Ratio
The Redeem token is a helper token for the Prime which manages the accounting for the underwriters. When underwriters deposit underlying tokens they receive Primes and also a 'receipt' token, the Redeem. This Redeem token is used to withdraw strike tokens from the Prime when the Prime's underlying tokens are exercised, or its used to withdraw underlying tokens when the Primes expire.
This is an extension contract to support easier interaction with the Prime Option contract. The Prime
Option contract operates with optimistic swap technology. It assumes that tokens are sent into it
before its functions are called. The Prime Option contract does not use any transferFrom
calls.
The trader does the transferFrom
call to the user, then it transfer
s the tokens to the Prime Option contract, and finally it calls one of the functions in the Prime Option contract like mint
.
The trader contract does this all in a single transaction and it can call any function in the Prime Option contract.
This is a liquidity pool contract that has the logic to (1) Accept underlying token deposits. (2) Mint Primes with the underlying tokens. (3) Sell the Primes for premium to buyers.
Feeds a price, the premium, to the Prime Pool. The Primes are sold from the pool to buyers at this price given by the oracle.
Join our community and protocol developers in the Primitive Discord.
If you have security concerns, email us at primitive@primitive.finance.