Macarse / contracts-v1

Hegic Protocol V1.1

Home Page:https://www.hegic.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hegic Protocol V1.1

License: GPL v3 Discord Telegram Twitter Follow

(30/05/2020: 1.0 → 1.1)

Hegic is an on-chain options trading protocol on Ethereum.

The core of the Hegic Protocol V1.1 is a system of Solidity smart contracts. The main parts of the protocol are options contracts and liquidity pools contracts. Options contracts are Call Options Contract and Put Options Contract. Liquidity pools contracts are ETH Pool Contract and ERC Pool Contract.

Table of Contents

What are Options

An option is a contract giving the buyer the right, but not the obligation, to buy (in the case of a call option contract) or sell (in the case of a put option contract) the underlying asset at a specific price on or before a certain date. Traders can use on-chain options for speculation or to hedge their positions. Options are known as derivatives because they derive their value from an underlying asset. Learn more about options and Hegic Protocol on GitBook.

How Hegic Protocol V1.1 Works

alt text


alt text

HegicCallOptions and HegicPutOptions are options contracts. These contracts calculate fees (options prices), create new options, exercise options contracts on behalf of the holders and exchange holders' assets using the Uniswap Protocol for sending liquidity back to the pool during the process of exercising.

HegicETHPool and HegicERCPool are liquidity pools contracts. These non-custodial contracts accumulate liquidity from providers (writers). Pooled liquidity is used for selling (writing) options contracts to the buyers (holders). After a liquidity provider calls the provide method, they send ETH / ERC-20 tokens to the liquidity pool contract and receive writeETH / writeERC (ERC-20) tokens to their address. To leave the pool a liqudity provider calls the withdraw method, burns their writeETH / writeERC tokens and receives ETH / ERC-20 tokens to their address.


ETH Call Options are created and exercised via HegicCallOptions and HegicETHPool contracts.

ETH Call Option is an on-chain contract that gives a holder a right to swap their DAI stablecoins for ETH at a fixed price during a certain period. To activate an ETH Call Option a holder chooses the period, amount and strike for their option contract. After paying fees, the lock method of the HegicETHPool contract locks ETH strikeAmount on the pool contract. If a holder intends to swap their DAI for ETH during a fixed period that they have paid for, they call the exercise method. The HegicETHPool contract will receive holder's DAI and will send the amount of ETH that was locked on the contract for this particular holder. Calling the exchange method of the HegicETHPool contract will automatically swap DAI received from the option holder for ETH at the market price using the Uniswap Protocol's ETH-DAI pool. After the swap, ETH is sent back to the HegicETHPool contract.


ETH Put Options are created and exercised via HegicPutOptions and HegicERCPool contracts.

ETH Put Option is an on-chain contract that gives a holder a right to swap their ETH for DAI stablecoins at a fixed price during a certain period. To activate an ETH Put Option a holder chooses the period, amount and strike for their option contract. After paying fees, the lock method of the HegicERCPool contract locks DAI amount on the pool contract. If a holder intends to swap their ETH for DAI during a fixed period that they have paid for, they call the exercise method. The HegicERCPool contract will receive holder's ETH and will send the amount of DAI that was locked on the contract for this particular holder. Calling the exchange method of the HegicERCPool contract will automatically swap ETH received from the option holder for DAI at the market price using the Uniswap Protocol's ETH-DAI pool. After the swap, DAI is sent back to the HegicERCPool contract.

Important Warnings

Hegic Protocol V1.1 contracts have been audited by Bramah Systems: https://bramah.systems/audits/Hegic_Audit_Bramah.pdf. However, your funds are at risk. You can lose up to 100% of the amount that you will provide to the liquidity pools contracts. There is a technical risk that the Hegic Protocol V1.1 contracts can be hacked in the future. Never provide funds to the liquidity pools contracts than you can't afford to lose. Always do your own research.

[Added on 28.05.2020. Fixed on 31/05/2020] ATTENTION! PLEASE READ THIS! During the first 90 days after the V1.1 contracts deployment (deployed on 30/05/2020) the owner address will be a highly privileged account. It means that the contracts will be under the owner's control. After 90 days from the contractCreationTimestamp time, these priviledges will be lost forever and the contracts owner will only be able to use setLockupPeriod (LockupPeriod value can only be <60 days), setImpliedVolRate, setMaxSpread functions of the contracts.

See below:

/**
 * @notice Can be used to update the contract in critical situations
 *         in the first 90 days after deployment
 */
function transferPoolOwnership() external onlyOwner {
    require(now < contractCreationTimestamp + 90 days);
    pool.transferOwnership(owner());
}

Contracts

Contract Description Mainnet Address
HegicCallOptions ETH Call Options 0x0B660D66b05a743Df3755058c2e63d5a5f2bA2F7
HegicPutOptions ETH Put Options 0xD45cC8321e3015608cFb2D51668FFE03db80f3BE
HegicETHPool ETH Liquidity Pool 0xaDA5688293dE408A9fA4cB708F9003D140BD99cb
HegicERCPool ERC Liquidity Pool 0xD5a596d0E46Ae92D77B6c8b63848b02baDA3D7bA
Aggregator ETH/USD Price Feed 0xF79D6aFBb6dA890132F9D7c355e3015f15F3406F

Admin Key

Hegic Protocol V1.1 contracts admin key holder CAN:

  • call setLockupPeriod function to change the lock-up period for liquidity providers (can only be <60 days)

  • call setImpliedVolRate function to change the Implied Volatility proxy that influences the fees

  • call setMaxSpread function to change the maximum spread for the swap on the Uniswap Protocol

Hegic Protocol V1.1 contracts admin key holder CAN'T (after 90 days from the day of contracts deployment: 30/05/2020)

  • can't withdraw users' funds from the pools contracts using the withdraw function

  • can't lock users' funds on the liquidity pools contracts calling the call lock function

  • can't unlock users' funds on unexercised active contracts calling the unlock function

  • can't send users' writeETH / writeERC tokens calling the transfer function

  • can't exercise users' active options contracts calling the exercise function

Documents

Maintainer

Molly Wintermute. Contact: molly.wintermute@protonmail.com | https://keybase.io/mollywintermute

Acknolwedgements

Sam Sun, Lev Livnev, Dan Elitzer, Jon Itzler helped make Hegic Protocol V1.1 better. Thank you.

License

The Hegic Protocol V1.1 is under the GNU General Public License v3.0.

About

Hegic Protocol V1.1

https://www.hegic.co

License:GNU General Public License v3.0


Languages

Language:JavaScript 100.0%