One of our friends was originally intending on getting married this fall. A couple months ago, the funds he was going to use for the wedding were tied up in ETH. He was concerned with ETH’s volatility; even though he was very positive about long-term payoffs, he was nervous that the value could tank right before the wedding. When Matt and Nate were discussing this concern with him, they came up with the idea for Pancakes, which would be a way for all investors to stay invested in ETH, but in a much safer manner.
What it does
When you invest in ETH, or any other token, the value fluctuates; this is known as market risk. Sometimes, investors are okay with this risk, especially because risk is usually accompanied higher returns, but other times, when investors need liquidity or stability, the risk can be concerning. Pancakes is a way for investors all of whom are long on ETH to swap returns for decreased risk and volatility.
Pancakes creates a way for more conservative investors (investors in the Buttermilk token, BUTTR) to give up some of their return to more aggressive investors (investors in the Chocolate Chip token, CHOCO) in exchange for stability:
- When ETH appreciates in value, everyone makes money, but some of the money that BUTTR holders would have earned goes to CHOCO holders
- When ETH loses value, all losses are absorbed by CHOCO holders first. It is only when CHOCO loses all its value that BUTTR tokens start to lose value.
In other words, when ETH is doing well, everyone makes money and CHOCO holders make a lot, but when the market goes down, the losses are primarily absorbed by CHOCO holders, keeping BUTTR intact.
How we built it
First we came up with a few different models for accomplishing this goal:
- The simplest model allocates a fixed percentage of profits to transfer from the BUTTR holders to the CHOCO holders at each timestep. As a result, returns for BUTTR holders are a dampened version of ETH returns, and returns for CHOCO holders are a more volatile version of ETH returns
- The next model modifies the first design to only take losses from BUTTR holders when necessary to attempt to stabilize their returns even more.
- This last model—which is the one used here—attempts to give BUTTR holders a fixed rate of return and they only lose money when CHOCO holders cannot lose any more (i.e. the token is worth zero)
We then ran some Monte Carlo simulations to choose a design, implemented it in Solidity, wrote some helper scripts with to fast forward time on Ganache CLI, and built the frontend with Vue + ethers.js to interact with the contracts.
Sample returns are shown in the images at the top of this page
Challenges we ran into
None of the three models are perfect and they all have tradeoffs, so it was tough to choose one. Ultimately we chose the third one because in our testing it seemed to provide fairly consistent results, and the fact that it generates a very stable collateral that can be used in other DeFi protocols was a great bonus.
The tough decision with design 3 is choosing a target return rate for BUTTR holders. Choose a value too low and BUTTR may never recover from an initial drop, choose a value too high and its returns can outpace CHOCO. After some trial and error with historical data we made a decision to target 0.1% per day, but ultimately still don't feel confident in this target rate. Additionally, making this value based on historical data makes it hard to deploy this system for newer assets with less price history.
We forked the mainnet using Ganache CLI so we can develop with real Chainlink price feed data. The problem here is that Pancakes is dependent on getting ETH price updates at regular intervals over many months. Simulating ETH returns over a time period using Chainlink was a challenge, so we ended up just hardcoded fixed price changes into the contract to work around this.
Another challenge a production version would face is determining how to get price updates at regular intervals. This is required because only updating ETH/USD price and token values at the start and gives different results then updating the ETH/USD price continuously. Calling this function daily may get expensive for oner person to do, so we may need to figure out how to incentivize users to call it.
Accomplishments that we're proud of
What we learned
Designing robust financial products is hard.
What's next for Pancakes
- Update the model to use a variable target rate for BUTTR holders that can adjust based on past returns and current token values
- Make the contracts more modular so they can easily be deployed with any token as the underlying asset
- Figure out a reliable and affordable way to get price updates at regular intervals