Gamma is a decentralized capital efficient option protocol that enables sellers to create spreads. Gamma protocol enables any user to create arbitrary option tokens, that represent the right to buy or sell a certain asset in a predefined price (strike price) at or before expiry. As the option seller in Gamma, you can reduce the amount of capital locked in the system by creating spreads. (e.g Instead of putting down 100 USDC and mint 1 ETH-USDC-100 Put, you can buy a ETH-USDC-50 Put, and only deposit 50 USDC as collateral) The oTokens created by Gamma are cash settled European option, means all the options will automatically be exercised at expiry. A holder can redeem the proceeds by sending the oTokens back, the system will pay the holder the cash value based on strike price and underlying spot price at expiry, instead of actually exchanging the underlying asset and the strike asset.
Our docs site is here. It contains tutorials, explainers, and smart contract documentation. If you'd like to view these docs on github instead, check out the docs folder in the docs repo:
For local development it is recommended to use ganache to run a local development chain. Using the ganache simulator no full Ethereum node is required.
As a pre-requisite, you need:
- Node.js (v10.18.0)
- NPM
Clone the project and install all dependencies:
$ git clone https://github.com/opynfinance/GammaProtocol.git
$ cd GammaProtocol
# install project dependencies
$ npm i
Compile all contracts:
$ npm run build
In a new terminal, launch an Ethereum RPC client, we use the default ganache-cli command to configure and run a local development ganache:
$ npm run ganache
Switch back to your other terminal and deploy the contracts, and make sure to to setup the deployments parameters in ./migrations/deployment-config.json
file:
# Local deployment
$ npm run deploy:development
# Mainnet deployment
$ npm run deploy:mainnet
Run all unit tests:
$ npm run test:unit
Run all integration tests:
$ npm run test:integration
To deploy a new PayableProxyController.sol
, it is recommended to use the deployPayableProxyController
truffle script inside the scripts
folder.
Input
truffle exec scripts/deployPayableProxyController.js --network mainnet --controller 0x7d78c401c69c56cb21f4bf80c53afd92be0BBBBB --pool 0xc02aaa39b223fe8d0a0e5c4f27ead9083c7AAaaa --weth 0x5f4eC3Df9cbd43714FE2740f5E3616155cAGAGAG --gas 50000000000
Output
Deploying payable proxy contract on mainnet 🍕
Payable proxy contract deployed! 🎉
Transaction hash: 0xebf12fc6603ee857bcabe1c0c6194XX82639a9888776f7ff6e83a409XXXXXXXX
Deployed contract address: 0x669cC97687c792fc5369d7bdd38cXXXXXXXXXX
To deploy a new ChainlinkPricer.sol
, it is recommended to use the deployChainlinkPricer
truffle script inside the scripts
folder.
Input
truffle exec scripts/deployChainlinkPricer.js --network mainnet --controller 0x7d78c401c69c56cb21f4bf80c53afd92be0BBBBB --pool 0xc02aaa39b223fe8d0a0e5c4f27ead9083c7AAaaa --weth 0x5f4eC3Df9cbd43714FE2740f5E3616155cAGAGAG --oracle 0xef196aA0e3Cb8EA6d5720557C3B611Eff6OOOOOO --gas 50000000000
Output
Deploying chainlink pricer contract on mainnet 🍕
Chainlink pricer deployed! 🎉
Transaction hash: 0xebf12fc6603ee857bcabe1c0c6194XX82639a9888776f7ff6e83a409XXXXXXXX
Deployed contract address: 0x669cC97687c792fc5369d7bdd38cXXXXXXXXXX
The PermitCallee.sol
contract allow user to call permit()
function through the Controller Call action.
To deploy a new PermitCallee.sol
, it is recommended to use the deployPermitCallee
truffle script inside the scripts
folder.
Input
truffle exec scripts/deployPermitCallee.js --network kovan --gas 50000000000
the Trade0x.sol
contract allow to batch 0x trading transactions with Gamma operate actions through the Call action.
To deploy a new Trade0x.sol
, it is recommended to use the deployTrade0x
truffle script inside the scripts
folder.
Input
truffle exec scripts/deployTrade0x.js --network kovan --exchange 0xf1ec7d0ba42f15fb5c9e3adbe86431973e44764c --assetproxy 0xaa460127562482faa5df42f2c39a025cd4a1cc0a --staking 0xe94cb304b3f515be7c95fedcfa249a84995fd748 --weth 0xd0A1E359811322d97991E03f863a0C30C2cF029C --controller 0xdEE7D0f8CcC0f7AC7e45Af454e5e7ec1552E8e4e --gas 50000000000
Clean code is the best code, so we've provided tools to automatically lint your projects.
Lint all smart contracts:
$ npm run lint:sol
Lint all tests files:
$ npm run lint:tests
We've also provided tools to make it possible to automatically fix any linting issues. It's much easier than trying to fix issues manually.
Fix all smart contracts:
$ npm run lint:sol:prettier:fix
Fix all tests files:
$ npm run lint:tests:prettier:fix
We use the solidity-coverage package to generate our coverage reports. You can find the coverage report at coveralls. Otherwise, you can generate it locally by running:
$ npm run coverage
The full report can be viewed by opening the coverage/index.html
file in a browser.
The security of the Opyn protocol is our highest priority. Our team has created a protocol that we believe is safe and dependable, and has been audited by OpenZeppelin. All smart contract code is publicly verifiable and we have a bug bounty for undiscovered vulnerabilities. We encourage our users to be mindful of risk and only use funds they can afford to lose. Options are complex instruments that when understood correctly can be powerful hedges. Smart contracts are still new and experimental technology. We want to remind our users to be optimistic about innovation while remaining cautious about where they put their money.
Please see here for details on our security audit and bug bounty program.