← click here to see all projects

Description

Our goal of the month is to bootstrap ETH option trading on opyn. We've built 2 UI frontends for trading, and also a new AMM. This is a balancer smart pool which decreases impermanent loss for liquidity providers (LPs). The first UI is built with existing Uniswap exchanges, (Link: https://opynmonitor.xyz/#/trade/uniswap/), where we provided a greeks board with some other stats that help traders make better decisions. The second UI is a OTC trading interface using 0x. (Link: https://noraliucode.github.io/opyn-taco/), where users with larger orders can submit an order and enjoy zero slippage when someone take their orders. We also built a balancer smart pool AMM, which ensures the price is updated based on current ETH price and timestamp before every trade and adjusts the weight to decrease impermanent loss. When the option expires, the weight of oTokens in the pool becomes 0 and users won't be able to drain the pool with worthless tokens. The smart pool is live on Kovan testnet: https://opynmonitor.xyz/#/balancer

How It's Made

We came up with different ideas about how to help the opyn team bootstrap trading volume, and end up doing all of them! We took lots of time designing the first Uniswap Pro trading UI, because Uniswap is where most users are trading opyn options now, and we wanted to build a more easy-to-use interface for traders. We use theGraph a lot for pulling historical data, and calculate N&L, positions, greeks for traders so they can easily utilize some strategies like "delta hedging" an options position. The greek values are partial derivatives of the famous Black-Scholes pricing model for option contracts. In order to minimize mathematical errors and maximize pricing speed, we used a pre-existing Javascript library called `black-scholes` to automatically price the greeks in real-time. The second UI is a little bit different, we want to provide alternatives for traders who don't want to use Uniswap because of the big slippage caused by low liquidity, we also believe that migrating some liquidity to 0x can help reduce opyn's loss on Uniswap market making. We already built a 0x trading page before the hackerthon, so we want to focus on building easy-to-use interface to bootstrap liquidity for 0x. Couple users ask us to build a OTC interface, so we did it! This is mainly done with 0x's mesh network API, we submit the order there and the liquidity will automatically be accessable on any other platform. As for the balancer smart pool, we spent most of our time designing the AMM algorithm and doing research on some more financial topics. We end up using an approximation formula for Black-Scholes which is cheaper to calculate in solidity: Put = (0.40*(spot - ((strike-spot)/2))*(iv*sqrt(time)) + (strike-spot)/2). This is a crude estimate of calculating the price of a put option that is close to being "at the money" (ATM). This formula is only good for a limited range of option strike values and further research into option financial models must be conducted to get better prices for options that are OTM or ITM. The idea is: we adjust the weight of oETH (option token) in the pool as time goes by (or when eth price goes up and make the option less valuable). The adjustment function is the one shown above, we write a controller contract which automate the process before each trade happens against the balancer pool. Within each trade, we 1) update the weights, 2) set the pool to public, 3) trade against the pool, 4) lock the pool up to disable public trading and 5) update implied volatility. 1) is for price adjustment as we mentioned. if it's been a long time since last trade, we need to adjust the price otherwise the UP will loss too much to arbitragers. 2) and 4) is the tricky part, by using the lock, users are forced to trade against the pool through our controller contract, so we can make sure we fairly adjust the price for everyone equally. step 5 is another important step. After the trade take place, we will update a global variable which represent "implied volatility" derived from current spot price. This value gives traders a hint about how good the current price is, and when the next trade happens, the price adjustment is going to be based on this IV. The AMM is currently on Kovan, and when it's live on mainnet we will need an oracle for ETH price. We're using oracle from Compound now.

← click here to see all projects