Inspiration

There are a lot of scandals lately underscoring the risks associated with centralized financial institutions and custodians. It has become completely apparent that we need DeFi to solve these issues with fraud and trust. We need solutions that are transparent, trustless, and effective. We need tools that work for us, that are fair and not made to exploit one party or another. We need something like Gwin. Personally, I come from a Finance background, and I couldn't be more excited about engineering the coming age of DeFi.

What it does

Gwin brings together risk seekers with their more conservative counterparts in pools, to take on leverage, short, cool your ETH into stable USD, and even create emulated positions of Gold, Bitcoin, etc. You can deposit or withdraw at any time, and the pools function at all times, targeting optimal function and achieving it optimally 92% of the time even with pools severely out of balance. You get a highly effective, fair tool with automated function, transparency, and reliability!

How I built it

Gwin Protocol was designed to fulfill these five technical objectives:

  • To operate with any amount of ETH.
  • To function without the need to get a bunch of liquidity from providers beforehand.
  • To operate with any number of users.
  • To be able to be interacted with at any time.
  • To have natural incentives maintain the protocol.

I envisioned a balancing pool system, inspired by my experience with options contracts and how cool AMMs are. During this Hackathon, I challenged myself to develop a Stable/Long pool balancing model that people could use to either "heat up" their ETH into a long ETH/USD position or "cool it off" into a USD position. Creating a stable USD pool out of ETH and the utility of long positions alone was really neat. Realizing how great that was, I decided the sky was the limit, and I really wanted to push the envelope. I discovered that I could create pool pairs with uneven ratios and accomplish any amount of leverage. I added Chainlink's price feeds with ETH/USD, JPY/USD, BTC/USD, and XAU/USD and I used them to create ETH/BTC, ETH/JPY, and ETH/XAU pair feeds. There was no reason to stay stuck on ETH/USD, so I engineered stable (emulated) gold, Yen, and Bitcoin along with the possibility to short them. Then I felt encouraged to try something bigger, so I developed the shared cooled parent pool. This made servicing a 10x pool a lot more sensible, since it could be wiped out on a 10% day, as it was on its own. But a deposit to the cooled parent pool serves the 2x, 5x, and 10x pools all at once, and the pool optimally rebalances to each child pool. Since the balance of the 10x pool is 9 Cooled ETH per 1 Heated ETH, the cooled ETH allocated to it by the parent pool doesn't get wiped out by a swift move to the upside (it just gives up its profits) and it's protected to the downside for as long as the heated pool has interest. That was a real challenge, but I got it prototyped. Then I created the front end with some help from Moralis and deployed to the Goerli test net.

Challenges we ran into

The math was quite complex and hard to test. Dealing with Goerli and lack of test ETH was difficult, especially at the end. The time restriction has been tough too. But I appreciate the motivation, and I feel it led to something great. I'm also not great with React and Next.js yet, but loved the challenge there.

Accomplishments that I'm proud of

Creating something so elegantly simple! I had hoped to create something that could do this in contracts, but the vision came together to do it in a more seamless way beautifully. I love how the incentives create a natural balance by rewarding people who deposit to underweight pools with funds provided at very little cost to the overweight pool, given the underweight pool is so much smaller and easy to service.

What I learned

DeFi is needed! And for me, it's fun.

What's next for Gwin Protocol

To expand the concept and see where it can reach! It seems like so much is possible for it. First up, I'd like to create a fee system to reward the Cooled Pool depositors with yield directly into their shared pool. I'd love to work with some other developers too, and specifically implement it with Truflation, which I didn't have time for. It would be awesome to get Oil, Silver, and even Food onto Gwin. There's also some minor kinks to work out, the contract could be more efficient and better structured, storage could be better optimized, but I did extensive testing, including countless tens of thousands of monte carlo simulations on the math, and the concept is proven! Now it's time to clean it up and seek out those possibilities.

Notes

The Front End I showed in the video was locally hosted, and the most current version wasn't up on GitHub before the deadline. But its use is illustrated in the video. If you want, check out my GitHub for the gwin-app to non-officially check it out.

Call Out

I asked in the support chat whether I could use a concept I had developed for the Hackathon, and I was told that was okay, but that I needed to call it out. When I did Patrick Collins amazing Python/Brownie tutorial, I used the name "Gwin" for the simple staking application we built because I thought it was a perfect name for a DeFi app. I actually cloned that project and the front-end I made for it, as a starting point and kept the name. I also had developed a financial math model for a bare bones version of pool balancing in Google Sheets and tested it with Google App Scripts. I coded some of the math for a -50%, +50% pool balance version into solidity. That pool balancing version didn't even make it into the project, but its bones were used for the array of new ideas. See above what I completed during the Hackathon specifically.

Built With

Share this project:

Updates