neuron-fund / neuron-options

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Neuron fund options

Architecture

AddressBook is an address discovery module that keeps track of all the contract addresses in the v2 system. Whitelist is a module that manages all restrictions set by the admin.

ONToken is the ERC20 contract that each represents an option product. Users can easily transfer any onToken just like any other ERC20 tokens, but only the Controller has the privilege to mint or burn onTokens.

ONTokenFactory is a factory contract to clone ONtoken contracts, anyone can create options with arbitrary strike price and expiry, if the onToken params composition (underlying assset, collaterals assets + collateral assets constraints + strike asset + is Put or Call) is whitelisted. These params are: underlying assset, collaterals assets, collateral assets constraints, strike asset, is Put or Call.

Controller is the entry point for all users, it manages all the opened vaults for all sellers, and also takes care of the exercise operation for buyers. Users can do several operations in a single transaction through the operate function in Controller, and Controller will mint / burn onTokens (interact with ONToken contracts), move funds (interact with MarginPool).

MarginCalculator is a very specific math library for vaults. Its purpose is to calculate payouts for options redeemers, proper collaterization of options, return of collaterals for vaults on settle.

Oracle is the oracle module for the whole system, the MarginCalculator will constantly read from oracle to determine if a vault is properly collateralized. The pricer roles are defined to determine who is in charge of submitting prices for each asset. MarginPool is the contract that stores all the funds, and only listens to transfer commands from Controller.

MarginPool is the contract that stores all the funds, and can only be called by the Controller. To open a vault, a user need to approve MarginPool contract to move its ERC20 tokens to deposit collateral and long onTokens.

Dev

Before all


  • Run npm i

  • Create .env following .env.example

Tests


Unit tests

npm run unit-tests

E2E tests

Note that e2e test require RPC node set through ALCHEMY param in .env file

npm run e2e-tests

Utils


Check contract sizes

npm run size-contracts

About

License:Mozilla Public License 2.0


Languages

Language:TypeScript 60.3%Language:Solidity 39.6%Language:JavaScript 0.1%Language:Shell 0.0%