For many, DeFi is a black box. We need more DeFi literacy on @Stacks to inspire the great builders we have to build exciting protocols.
I'll do a few threads on fundamental concepts and share hooks for interesting things to build
Let's start with Impermanent loss 🧵
With the @alexgoBtc launch, we get a new DEx on Stacks to provide liquidity (LP) to to farm sweet APYs.
But, when you LP on an AMM you lose some of your tokens due to impermanent loss. Sounds scary..
Impermanent loss isn't so scary when you understand what you're getting into.
Impermanent loss (IL) is not a bug, but a feature of Automated Market Making.
You should always offset potential IL against the expected APY to understand what you're really getting
IL happens when you provide liquidity to a liquidity pool, and the price of your deposited assets changes compared to when you deposited them.
Let's take an example 👇
Let's assume 1 STX is worth $100
Alice deposits 1 STX and 100 USDA in a liquidity pool. This means that the dollar value of Alice’s deposit is $200 at the time of deposit.
In addition, there’s a total of 10 STX and 1,000 USDA in the pool – funded by other LPs just like Alice.
So, Alice has a 10% share of the pool, and the total liquidity is $10,000.
Let’s say that the price of STX increases to 400 USDA.
While this is happening, arbitrage traders will add STX to the pool and remove USDA from it until the ratio reflects the current price.
Remember, AMMs don’t have order books. What determines the price of the assets in the pool is the ratio between them in the pool.
If STX is now 400 USDA, the ratio between how much STX and how much USDA is in the pool has changed.
There is now 5 STX and 2,000 USDA in the pool, thanks to the work of arbitrage traders.
They have added STX to the pool and withdrew USDA until the ratio reflects the new STX price of $400. They bought at a discount and in effect get paid for rebalancing the pool
So, Alice decides to withdraw her funds she’s entitled to a 10% share of the pool.
As a result, she can withdraw 0.5 STX and 200 USDA, totaling $400.
But wait, what would have happened if she simply holds her 1 STX and 100 USDA?
The combined value of these holdings would be $500 now.
We can see that Alice would have been better off by HODLing rather than depositing into the liquidity pool.
**This is Impermanent loss**
Impermanent loss happens no matter which direction the price changes.
The only thing impermanent loss cares about is the price ratio relative to the time of deposit.
Impermanent loss isn’t a great name.
It’s called impermanent bc the losses only become realized once you withdraw from the pool. At that point, the losses very much become permanent 😅
BUT you can make predictions about how much Impermanent loss you will suffer by providing liquidity in a pool to see if it's worth it versus the APY/fees.
Here’s a summary graph about losses compared to HODLing (courtesy of Binance)
In the example above, Alice lost 20% of her initial deposit of 1 STX and 100 USDA because STX went 4x relative to USDA
Where will you suffer most impermanent loss? Well, on pairs where the ratio is expected to change a lot over your LP timeframe.
Do you expect the value of STX to double vs xBTC?
Then you'll suffer about 5.7% in Impermanent loss on the pair. So your yield over that period will need to be more than that
Do you expect the value of ALEX token to 5x vs STX?
Then you'll suffer about 25.5% IL on the pair. Your yield over that period will need to be much higher
Luckily @alexgoBtc will have great liquidity rewards for the upcoming launch, so you'll be fine in most scenarios
When rewards get lower however, IL becomes something to be more careful with
In the long run, IL is making it very hard for LPs on AMMs to make any money at all.
This is part of the reason why @CurveFinance is so successful right now. Curve is a DEx for stable assets like stablecoins or BTC derivatives where price swings are minimised
.@alexgoBtc uses the Curve model for the pools of its yield tokens.
You can lend out 1 STX for X days which gives you a yield token that trades at a premium to 1 STX. ALEX made negative yields impossible so the price of the yield token pools is very concentrated (minimsing IL)
Another solution is to take pricing of assets off-chain through some good pricing algos.
You take the weapons of market makers and arbitrage traders and put them in the hands of the LPs. Without relying on the pool for pricing, there's much less IL.
Order books require more compute than AMMs, so you'll need to match orders either off-chain or on a really high throughput chain (like @ProjectSerum does on Solana).
This is where Stacks subnets/hyperchains can really shine ✨
Oh yes, and when people talk about DeFi and you lose track: Ask questions!!
Can't stress how important this is to get this ecosystem off the ground. There are no dumb questions :)
• • •
Missing some Tweet in this thread? You can try to
force a refresh