Steemit Crypto Academy:- Season 5 Week 7 :- Curve Finance:- home work post for professor @sapwood

in SteemitCryptoAcademy3 years ago (edited)
Hey there everyone this is @prakhar9675 this side and this homework post is for professor @sapwood. So let's answer all the questions asked by the professor.

images (13).jpeg
Source

(1) Discuss the various features of Curve Finance? What are the different types of pools available in Curve Finance? What are the major DeFi protocols Curve is integrated with? How does Curve Finance improve the second layer utility of a token of a different protocol?

Discuss the various features of Curve Finance?

The Curve Finance is an AMM DEX, but the liquidity is profound into different kinds of pools, the fundamental aim is to make a trade with negligible slippage and produce alluring APY for the liquidity suppliers.

It began as stablecoin swap, however, with steady evolution and periodical progress & integration with other DeFi protocols, it covered an enormous assortment of pools including the tokenized token of different platforms to add a second layer utility of the coin.

The development of different famous protocols has given different kinds of stable coins: DAI, TUSD, sUSD, bUSD, USDC, etc. The end user might require one stable coin to move into the other network or protocol and may likewise have to trade one type for the other. The need of stable coin is the need of the crypto market. To make it more liquid, interoperability is required and to additional make it more versatile and tradeable you want trade of stablecoins with minimal slippage and low exchange fees.

The customary protocols doesn't offer alluring means and cost-saving means to trade one stablecoin for other. For different other AMM DEX, the trade isn't savvy because of extreme gas expenses. Curve Finance started asn an alternative to address this issue when it began as stablecoin swap with low slippage and low fees. In any case, with such countless advancements around it, it has extended its reach to numerous different protocols of DeFi.

image16.png

I will elaborate different features individually.

(1) Pools
(2) Factory
(3) DAO
(4) Trade

(1) Pools: The pools can be liquidity pools, and lending pools. Liquidity pools generate fees from each exchanges and compensate it to the liquidity providers. Lending pools generate interest and compensate it to the liquidity providers. The integration of liquidity pool and lending pools consistently augment the benefit for the liquidity suppliers in Curve Finance and also helps the traders to exchange with lowest possible trading fees.

image1.png

There are other types of pools: e.g. tri-pools, where three tokens are pooled together. The professor has clarified that the pools can be made with multiple coins, which are called n-dimensional pool. This sort pf pool makes low slippage and better conversion standard for traders.

Curve offers tri-pools and tetra pools and it very well may be pool of likewise assets and it can likewise be a pool of distinctively acting assets.

There are likewise another type called V2 pools in which non-pegged assets and differently behaving assets are pooled and they are simillar to AMM DEX like Uniswap.

The stablecoin pools are consistently pegged assets inside the pool. So such pools are not presented to the risk of impermanent loss.

I will show you the screen capture of the Pool part of Curve finance.

A couple of pools are shown below:

There is one more type of pool which is well known as incentivized pool. In such pools, the related protocol incentivize the liquidity provider with extra reward with the native token of the protocol to boost liquidity providers. Actually the trade in stable coin also creates a minor shift from the pegged value, but that also brings in arbitrage trading who exchange it cheap and balances the pool again, so to make it more alluring for liquidity providerssome protocol reward the liquidity providers with native token. For instance, Sythetix offers generally 40% APY for the sUSD pool.

(2) Factory-This is to permit anyone to create a pool; anybody with seed liquidity can make a metapool in Curve finance. Anybody can set its own boundary of fees, but has to be in the range of 0.04% and 1%. The 1% is the upper boundary and 0.04% is the lower boundary of fees. Half of the expenses charged in any pool is the Admin charges and go to Curve DAO.

image3.png

You can see a tab at the top Factory: Create Pool, Deploy Gauge, Create Gauge Vote.

Various types of pool that can be created are-Meta USD, Meta BTC, Meta BTC(ren), Plain, etc. Each pool type has indicated the number of tokens for the pool and the type of assets.

The Gauge vote is chosen by the veCRV holders.

(3) DAO, Vote governance CRV-DAO is Curve Decentralized Autonomous Organization. It is the decentralized governance of Curve. CRV is the DAO token or governance token. Curve DAO with aggregated community voting by CRV holders decides on the inflation rate, the amount of share for the Liquidity providers, development, reserves, etc. The gauge voting is also done by staked CRV, which is also known as veCRV. To obtain veCRV the CRV holders have to lock the liquid CRV tokens for a certain period. The period can be 7 weeks to 4 years. I will discuss this later in the post.

(4) Trade-Swap has bigger liquidity pools and also routes through other liquidity pools, it has likewise been incorporated after integration with other DeFi protocols. When you exchange in Curve Finance, say trading one stablecoin for the other, it utilizes the best route using different integrated liquidity pool that is accessible in the whole Curve pool and get the trade done in the speediest way, with negligible slippage.

image2.png

How Curve Finance further develop the second layer utility of a badge of an alternate protocol?

Curve Finance has has collaborated with other DeFi protocols like Synthetix, AAVE, Compound. If a user you lend in Compound, he gets cDAI token. At the point when cDAI is redeemed the lender get back the original asset.

Curve Finance has various pools which include cDAI token, the cDAI holders can stake their cDAI token in Curve Finance to mine additional tokens.

(2) What is impermanent loss? Explain with examples? How does Curve Finance mitigate this loss?

Impermanent loss is a loss that exists in a pool where the resources are differently trading. For instance, ETH-USD, TRX-USD, BNB-USD. One side of such pool is a speculative coin and the other is a pegged coin.

As it is impermament loss, it can not become permanent except if you pull out your liquidity. At the point when you add liquidity to a pool you add same weight to the two sides of the LP Pool and you are offered a LP token as a trade off. At the point when you redeem that LP token your get your assets back as free tokens, but the released assets may not be returned in a similar(original) weight you provided.

The difference between asset's worth at the time of adding liquidity and pulling out liquidity is the acknowledged as impermanent loss.

At any point if you measure the deviation or change in net asset's worth compared to the time of adding liquidity is known as impermanent loss.

I will clarify by an example.

Assume I want to add TRX-USDT to the liquidity pool of Sunswap. Today the cost of TRX is 0.077. Assuming that I add 1000 TRX, its value is 77 USDT, it ought to be adjusted by equivalent USDT, so I should add 77 USDT too.

At the time of adding liquidity, the resources worth of TRX-USDT for me= 77+77= 154 USDT

How about we expect to be that following a month TRX trades at 0.1 USDT. The AMM-DEX curve is XY=K. The TRX must be balanced equally in weight with Y constantly. Assuming it shofts, the arbitrage trader will hop in as it offers a profit to them to exchange the pair cheap.

However, for my situation, the TRX is presently 0.1 USDT, and I have added 1000 TRX, so X side is currently 1000 * 0.1= 100 USDT. The Y side is as yet 77 USDT. It looks shabbier to the arbitrage traders, they will purchase all my TRX until it gets back to the trade cost of 1 TRX= 0.1 USDT.

So they will exchange until the XY turns out to be equally adjusted.

X+Y= 77+77= 154 USDT

X'+Y'= 100+77= 177 USDT

Now I will use a calculator table and enter the various other future forecasts of TRX(upaide and downside) and check what is the impermanent loss I will face.

https://dailydefi.org/tools/impermanent-loss-calculator/

If I add 500 USD with TRX and 500 USD worth USDT in TRX-USDT pair:-

Value now-TRX-0.07 USD, USDT-1 USD.

If the future cost of TRX is 0.1 USD

Worth of TRX_USDT inside liquidity pool= $1195.23
Worth of TRX_USDT outside liquidity pool= $1214.29

image4.png
https://dailydefi.org/tools/impermanent-loss-calculator/

The impermanent loss is 1.57%.

Assuming I add 500 USD with TRX and 500 USD worth USDT in TRX-USDT pair:-

Value now-TRX-0.07 USD, USDT-1 USD.

Assuming that the future cost of TRX is 0.05 USD

Worth of TRX_USDT inside liquidity pool= $845.15
Worth of TRX_USDT outside liquidity pool= $857.14

The impermanent loss is 1.57%.

In 2 different future scenarios (Upside and Downside), I am lose as impermanent loss whether price appreciates or depreciates.

That is because of the fact that TRX and USDT doesn't trade the same way, they are differently behaving assets.

Curve finance mitigates this issue by cautiously pooling similar kinds of tokens.

As an example, 3Pool of Curve finance pools DAI+USDT+USDC. Every one of the pool here are steady coins, so there will not impermanent loss, in light of the fact thatall the three tokens will simulatenously move in one direction. Since they move and trade simillarly, the binding curve wont need to adjust and rebalance unlike in the case of TRX-USD. So it does not encourage the arbitrage traders, no arbitrage trading at the cost of liquidity pool. No impermannet loss will be borne by the liquidity providers.

Different types of pool, where non-pegged tokens are pooled, however, they are likewise trading assets with the main difference is their tokenized adaptation with other protocols.

As an example, in steth pool, there are two coins ETH+stETH. One is the ETH coin, the other token (stETH) is the tokenized token of ETH.

What is the difference between constant product invariant and constant sum invariant? How does Curve Finance accommodate these two to offer a wider zone of INPUT/OUTPUT balance? How does it lower the slippage?

In 2-dimensional liquidity pool, there are only two tokens adjusted equally in their weight, XY=K. The result of the weight of X and Y is consistent all the time.

The weight of X is characterized by the supply in the pool and the value of the token.

X= {quantity of x, cost of the token x}
Y= {quantity of y, cost of the token y}

In different behaving assets the price of x and y are not fixed or not similar to each other.

Differently behaving pairs LP: ETH-USD, BNB-USD, ETH-DAI, ETH-wBNB, and so forth

The price or value of x and y both may likewise be variable. ETH and BNB are not pegged assets, if ETH-wBNB are combined together to make a pool, the smart contract doesn't have any idea about the price or value of the tokens pooled.

There is one more type of pool, which is more than 2-dimensional, for instance, 3Pool is a 3-dimensional pool. Another type of pool will be pool of tokens with pegged tokens only, for example USDC, USDT, TUSD, etc.

Assuming the fixed tokens are only pooled in LP, the algorithm know the price of the token.. The amount of token can fluctuate and can be chosen and exchanged by the clients using the protocol.

If it is pegged tokens like USDC, USDT, etc

X= {quantity of the symbolic x, cost of the token x= $1}
Y= {quantity of the symbolic y, cost of the token y= $1}

In In constant product market maker XY=K, in constant sum market maker, X+Y=K

image.png
Source

XY is a hyperbola and has a restricted zone where the things work for a trader. On the left hand side and on the right hand side of the XY=K the curve has tremendous slippage, so it has bidirectional loss for the traders and liquidity providers.

Coming to X+Y=K is a straight line. It doesn't have slippage like XY=K. However, in X+Y=K, only the value or price is steady and assuming the amount of token is superimposed in X+Y, it produces a hypersurface, with the exchanging zone a lot more extensive than XY=K, which is more proper with less slippage and loss.

Curve Finance deals with a curve that is between these two cruves, XY=K and X+Y=K. The straightline is theoretical in real market, as supply of the tokens will be thought about and that continues to vary, it can not be a straight line.

Assuming that the liquidity decreases this curve approaches XY=K, or all in all, the curve will marginally move to XY=K, with better liquidity this curve will move to X+Y=K.

So Curve Finance supply demand curve dances between XY=K and X+Y=K.

Assuming it shifts to X+Y=K, it will have limitless liquidity, and zero slippage, in genuine world, the pools have better liquidity and can not be limitless liquidity; so Curve integrates with various liqudity pool to make a trade resoanable with low fees and slippage, in the event that it coordinates with various liquidity protocols, it ultimately makes the liquidity a lot greater than the 2-dimensional AMM liquidity pool. In the event that the liquidity size builds, the Curve will begin moving to X+Y=K, along these lines making slippage much lower and better exchange, practical exchange for the clients.

What is veCRV? What are the benefits of holding veCRV token?

veCRV is the vote escrowgovernance token of Curve DAO. CRV is an incentive given to the liquidity providers in Curve Finance. In any case, veCRV is staked CRV. There is explicit lower and upper locking period characterized CRV protocol. Higher time of locking awards more veCRV tokens than the lower time of locking.

The locking period stretches out from 7 days to 4 years.

The veCRV holder have extraordinary ability to support their mining rewards in a pool by a maximum of up to 2.5X. They likewise get the portion of admin fee gathered from swap facility and lending pools in Curve Finance.

image15.png

The veCRV holders can choose and decide in favor of the diverse pools in Curve. The various pools have diverse gauge weight. In view of the allocated gauge weight the CRV inflation reward is appropriated to the various pools.

It gives the democratic privileges in Cruve DAO to conclude the liquidity check, the CRV inflation based incentive ought to be conveyed to which pool and by how much loads, that can be decided by voting of veCRV holders and appropriately changed on Thursday of every week.

The gauge weight is updated on Thurday of every week, but a veCRV holder can vote once on every 10 days. The voter can adjust the weight of voting and can also vote for multiple pools.

  1. Perform a stablecoin swap using Curve Finance using a suitable network of your choice? Include the transaction hash? Indicate the total fees incurred during the entire process? State your observation?Screenshot/Transaction Hash required?(Hint- You may use Polygon Network, I have provided the RPC details to add Polygon Network in your Metamask wallet, should you need this.)

First I needed to change to Matic Network, Curve is incorporated with Matic Network and Metamask's default setting is Etherum Network. Etherum Network gas charge is in excess of 20 USD, which doesn't seem OK and I didn't have that much cash, yet because of Curve Finance as it supports may different network; Matic is the network today I pick

First I moved 2.6 Matic from my Huobi Exchange and it showed up to my Metamask Matic wallet; I needed to pay 0.6 withdrawal fee for moving Matic from Huobi to Metamask.

You can check the transaction details using Polygonscan which is a Block explorer of Matic Network.

https://polygonscan.com/address/0x7DC2c83d2f278eE8459f629B700C0f80acfA95d6

image6.png

So first I should trade MATIC for USDC or USDT, then, at that point, I will trade that stabelcoin for another stablecoin, as the professor has asked for a stablecoin swap in Q No 5.

First I start for MATIC to USDT, I will utilize paraswap.io of Matic Network, which is another AMM trade in Polygon.

To go with Paraswap first, visit https://paraswap.io

image7.png

image8.png

image9.png

Connect your wallet. Ensure you have chosen Polygon network similar to my case in this assignment.

Sign the message.

First I trade a MATIC for 1.1 USDT. To go with, enter the output coin which is USDT and enter the sum in output box, it will eventually reflect the input.

image10.png

image11.png

image12.png

Click on trade.

Confirm Order.

I tried at least 5 times to make the trade exchanged to USDC, I do not know the reason why it is showing quesed up and pending. I have also raised the GWAEI to 102 but still it did not work. Professor, please look at my effort and consider this issues which I faced.

image17.png

Now I move to Curve Finance. I select and switch to Polygon Network. The url of Curve has now changed to https://polygon.curve.fi/

image14.png

On the input, USDC selected, on the output DAI selected. The exchange rate is 0.9995. And the swap is going to route through EURTUSD. Clicking sell will prompt the trader to sign the message and confirm the trade. I wanted to exchange USDC to DAI using Matic network. I have 1.89 MATIC stock in Metamask. But in Polyswap my swap from MATIC to USDC is pending queued for a long time. Professor, please take a note of such issues student face while doing your task.

So that's all from my side. Hope I was well understood.

All screenshots are taken by me.

CC
@sapwood

Sort:  
Loading...
Loading...

Coin Marketplace

STEEM 0.16
TRX 0.16
JST 0.030
BTC 59207.83
ETH 2464.61
USDT 1.00
SBD 2.43