This article was first published on Chainlink
For his prize-winning Chainlink hackathon submission, smart contract developer Max Feldman used Chainlink Price Feeds to calculate on-chain price volatility for a variance swap DeFi product. In this tutorial, Max explains how to calculate volatility from Chainlink Price Feeds and use this data to trigger smart contract derivatives, showcasing yet another example of how decentralized infrastructure is expanding to support traditional financial instruments and applications.
A variance swap is a financial instrument commonly traded over the counter among traditional financial institutions. It is an agreement to pay out or receive the annualised variance of a given asset pair over a given period of time. Variance is a measure of volatility. (Here’s a helpful video walkthrough of variance swap mechanics.) During the 2020 Chainlink Virtual Hackathon, I leveraged the power of Chainlink Price Feeds to build Feldmex Variance Swaps, one of the first-ever on-chain pure volatility products.
Unlike variance swaps in traditional finance, Feldmex variance swaps are much more uniform and fit into an easy-to-use ERC20 token wrapper. Rather than trading over the counter, Feldmex variance swaps may be traded directly from a user’s Ethereum wallet, empowering both individuals and firms to leverage decentralized infrastructure for hedging volatility risk.
DeFi Variance Swap Architecture
Feldmex variance swaps have a maximum payout cap beyond which the swap will not yield more. In traditional finance, these are referred to as capped variance swaps. Payouts are capped because there is no upward bound on the possible value of variance, and we must make sure that our smart contracts are not liable to pay out more funds than they hold.
Furthermore, to prevent our system from being liable for withdrawals which it cannot withstand, we must ensure that all open positions have sufficient collateral. We can take this a ...
To keep reading, please go to the original article at: