DeFi Swap is a fairly complex idea that may require a fair amount of understanding to know it and it involves very high risks that tend to lose your investment.
Where does the DeFi idea come from?
Many people may own or trade stocks. However, people own stock through financial services: Robinhood, Fidelity, Vanguard or many other service providers. When you purchase one stock, you really do not just own one stock immediately but there is a background of the working process to help you to purchase the stock. The processes are following:
- Offers a price
- Trusted middleman execute your trades by submitting price
- There is level II market where buyers place bids and sellers place asks to determine the value of trade
- Bids and asks price will usually meet in the middle for settlement in order book (transaction was record in case of legal dispute)
- Once both buyers and sellers agree with the price with one share to offer to middleman, you will own a share of stock that middleman hold it on your behalf
Okay, why do I explain the trading stock mechanisms here. Because DeFi is a solution to replace middleman into no man or decentralized operation that only buyers and sellers interact. Its core technology relies on Automated Market Making or AMM to replace trusted middleman and Liquidity Pools or LPs to replace Order Book.
Therefore, DeFi consists of applications and peer-to-peer protocols developed on decentralized blockchain networks that require no access rights for easy lending, borrowing, or trading of financial tools.
How does AMM work?
Remember the traditional stock exchange where you submit your order to a trusted middleman to purchase one stock for you? AMM automates the ordering process by providing settlement price or final price for both buyers and sellers.
How do LPs work?
Remember the traditional stock exchange where level II buyers place bids and sellers place asked to meet in the middle? LPs provide incentives to settle the final price submitted by AMM with small transaction fees.
LP token such as Uniswap is an ERC20 token that runs on Ethereum protocol to help the network operate as incentives to miners. When pairs submit into Liquidity Pool, it will convert into LP token and you will be rewarded 0.3% with the total amount you contributed. If you withdraw from the pool, the LP token will burn to exchange the amount you take out.
For DeFi LPs, since it runs on top of Ethereum, swap operation usually did it with 50%/50% for example of $1,000 worth assets with $500 Ether and $500 USDC with 0.3% of contribution total value as incentives to enter the LPs. Then you swap into a token that pays you back with pairs you put into LPs with potential rewards. Sounds like great investment opportunities. However, the risk is larger than the rewards that you may not have imagined.
The LPs is program the way here:
eth_liquidity_pool * token_liquidity_pool = constant_product
If we input Ethereum as an example, here we got:
eth_price = token_liquidity_pool / eth_liquidity_pool
Combining these two equations, here we got:
eth_liquidity_pool = sqrt(constant_product / eth_price)
token_liquidity_pool = sqrt(constant_product / eth_price)
Impermanent loss or divergence loss will describe as:
divergence_loss = 2 * sqrt(price_ratio) / (1+price_ratio) -1
From the article “Uniswap: A Good Deal for Liquidity Providers?” suggested, the sweet spot at 1.25x of price change gives you the most returns.
But even then, you still will lose money.
Let’s switch again into swap in finance.
What is Swap in finance?
A swap is an agreement between two parties to exchange sequences of cash flows for a set period of time. However, at least one of a series of cash flows is determined by a random or uncertain variable such as an interest rate that makes the swap unpredictable.
Why do swap then? One party may need cash to take risks while the other party wants to make money out of lending.
Two basic categories of swap: interest rate or currency exposure.
Banks like to use their liabilities (deposits) to earn a fixed interest rate on loans (assets) while companies that want to expand their business in foreign countries want to do currency swap to earn up local currency.
Okay, enough with swap in finance. You get the idea. The point is you are betting the future is more expensive than currency and you hope the future is an inflation environment so that you make profits out of swap.
There are three major risks associated with the LPs. One is commonly introduced and the other one is not very obvious.
Let’s throw everything together including I introduced the stock exchange, DeFi and Swap together to understand impermanent loss.
It simply means the price becomes lower after you put assets in LPs that trigger loss.
It is a lending facility in LPs, you want your lending money to generate more profits. You are betting the future that your assets are more valuable than today’s price.
When the market fluctuates, LPs value also fluctuates. Particularly in the crypto universe, volatility has a large fluctuation on both ends, your reward may diminish by such fluctuation not to mention that other uncontrollable factors happen in LPs.
Flash Loan Attacks:
It is a loan in the DeFi pool that someone takes out when markets fluctuate because of arbitrage, collateral swaps or lower transaction fees.
Mark Cuban got burned from a flash loan scam because the borrower was able to trick lenders to believe they will repay them in full with incentives while after paying the loan to borrowers, they suddenly withdraw the full amount of money and ghost the lender.
Swap fees or gas fees:
This is the ultimate ruin mechanism that I think destroys the entire DeFi.
Ethereum miners want to maximize their profits, so they will arbitrage their mining fees.
The problem is with DeFi since timing is very important to make profits for miners. Therefore, the faster miners can arbitrage and process the fees, the more profits they can get. However, it inflated the gas fees once for all. Miners by processing faster transactions will overpay to process or add costs to running nodes.
You got the idea, everything will inflate and become expensive to process swap with high gas fees.
DeFi is a fairly complex operation that is very difficult to operate within a decentralized environment since its original ideas heavily relied on a trust system.
Stablecoin is Not So Stable
CBDC: Stablecoin 2.0 or Stablecoin Killer
Chinese CBDC: the Ultimate Financial Weapon or Just another Copycat
Disclosure: I wrote this article myself, and it expresses my own opinions. I am not receiving compensation for it. I have no business relationship with any company whose cryptocurrencies are mentioned in this article. This information is only for educational purposes.