Future House
Inspiration
In recent years, there has been an explosion in the popularity of NFTs. NFTs are a very popular and highly coveted token category in the digital space. Despite their widespread popularity, most trading is limited to buying and selling NFTs. This is due to a few reasons:
- NFT prices are a highly speculative class of assets.
- Blue-chip NFTs are very expensive, so owning one is a pipedream for retail traders.
- NFTs are illiquid by design, making it impractical to engage in short selling or shorting NFTs as one would with traditional assets.
- You can't really buy a part of an NFT.
What it does
Future House focuses on solving the illiquid nature of NFTs. By introducing perpetual future contracts for blue-chip NFTs, traders can gain exposure to valuable NFTs without the need for outright ownership.
A little bit about Perpetuals
Perpetuals are an agreement to buy or sell an asset at an unspecified point in the future. They are one of the most popular financial derivatives.
How I built it
Initially, I did not really have an idea of what I wanted to build. I was unsure of what I wanted to build. However, one thing I was certain of was I wanted to improve frontend tooling for web3. React and react-based web frameworks tend to use virtual DOMs which tend to be slower. After a bit of research I ended up building on Svelte.
So I spent my time building wafer-connect, parallelly, I explored potential projects I could build for the hackathon. Two weeks ago, I came across the idea of a Perpetual Exchange. I decided to then try and build one for NFTs. This was my first foray into DeFi, which was quite challenging. I had to understand a number of concepts from Finance which was new and interesting, I spent a lot of my time reading code written by Uniswap, Perpetual Swap, Solmate, Solady, and Chainlink. I ended up cutting a few corners here and there to meet the deadline.
Virtual Automated Market Maker
The implementation of Future House uses a standard Constant Function Market Maker, only thing there is no actual liquidity behind the curve. So, its really a Virtual Market Maker (vAMM), this has a few advantages.
- No impermanent loss (Can't have a loss if there's no liquidity :) )
- Any NFT or any token can be emulated without the need to actually lock them up in a pool.
- Perpetual prices are designed to closely track the underlying asset's price.
- Traders can gain as much exposure as they want and control the risk.
The Clearing House
The Clearing House contract controls the actual positions of the trader, with each trader having a single position for each market maker. The clearing house also keeps tracks of the funding rate of the market maker and pays out the fee as needed.
Liquidation
Anyone can liquidate a position that is below margin maintenance level, the caller gets a 10% cut, creating strong incentives for people to run liquidation bots.
Implementing the Convergence Keeper
Virtual Market Maker, like normal Market Maker, face the problem that the underlying price can diverge especially during times of high volatility. To solve this I implemented a convergence keeper, that checks every block whether the perpetual price is within 10% of the actual price. If it is not it opens an opposite position, every 30 minutes. This can probably be better optimized by doing a bit of simulations and math.
Insurance Fund
This contracts receives all the revenue from the protocol. It is used to fund the convergence keeper, and pay back traders in times when the clearing house is undercollateralized.
Price Feed
While the Polygon Mumbai implementation uses an actual price feed, I deployed a fake price feed on Sepolia, because no NFT floor price feeds exists on it.
Test
Given the time constraint I was under, I tried to write and follow a test first approach. This ended up probably saving a lot of time as I needed to make sure each function was testable while writing.
What's Next?
For Future House, completing contracts (since some features are incomplete), improving and finishing the UI, writing more tests, fuzz testing, audits, and then start deploying on an actual network instead of a test network. Area I want to explore are
- Specialized Price data feeds Example
- Time weighted average floor price, rolling average floor price of a collection should be harder to manipulate need to implement and test.
Averaging the Prices of all the NFTs in a collection instead of Floor Price. Given a collection of 10000 profile picture, with each being expensive, changing and manipulating the Average Price of the Collection should be much harder than the Floor Prices Collection.
Better market makers
Insurance pool where liquidity provider earn liquidation fees.
Built With
- foundry
- solidity
- svelte
Log in or sign up for Devpost to join the conversation.