Curve Finance- An efficient automated market maker with better leverage & minimal slippage - Steemit Crypto Academy- S5W7- Homework Post for @sapwood

in hive-108451 •  3 years ago 
Hello Professor @sapwood. It's nice to see a new class again. I admit that at first it was a challenge but after doing more research (A LOT OF DIFFERENT SOURCES) I understood and really liked this platform called Curve Finance.

Let's start


Curve Finance.png
Image edited by me in Powerpoint

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 improves the second layer utility of a token of a different protocol?

In essence, Curve Finance defines itself as a decentralized exchange in which the main features are liquidity pools and an interface for exchanging and lending currencies.


1.png
Image taken from: Source

Here we can see the Curve Finance stablecoin trading interface. Naturally, the platform has other features, for example in the trades section, where we can find other pairs to perform exchange operations:


2.png
Image taken from: Source

As you can see, in this section we can view and adjust the graph of the selected pair.

Another feature that I think is great is "Factory" in which we can create and start our own Liquidity pool.


3.png
Image taken from: Source

First, we must select the type of pool as well as the tokens that will make up the pool. Then we select the implementation, the parameters, and the Metadata.

Regarding the Pools, it is a whole world apart.

Pools & Types of pools available

The available pool options are immense, among which the following stand out Compound, PAX, USDT, BUSD, 3POOL, Y, REN, SETH, SBTC, among others.


4.png
Image taken from: Source

All these options are contained among the different types offered by the platform. Among the types of Pools are:

1-Lending Pools: These are pools integrated to a lending protocol. These are pools in which additional earnings (in the form of interest) are obtained for lending cryptos, in addition to the typical earnings based on the transaction fees. Among the lending pools we have: Compound, Y, BUSD, and PAX.

2-TriPool: Also known as Plain Pools, which is composed of the three main Stablecoin: DAI, USDC, and USDT. For such reason, this is the largest Curve pool. I should note that this type is a non-lending gas pool.

3- Bitcoin pools: This is one of the new features of the platform, and as the name suggests these are pools that use tokenized Bitcoin, such as renBTC, wBTC, hBTC, and sBTC. The renBTC and wBTC pools, for example, receive transaction fees, although because they are low volumes (for the moment) their APY is low.

On the other hand, sBTC is a synthetic version of bitcoin on the Ethereum blockchain and is the pool that offers the best performance.

Major DeFi protocols integrated

I can mention Compound, Yearn Finance, Synthetix, and AAVE. In fact, the integration is such that the liquidity fund can also be supplied through Compound or Yearn Finance for example, and thus generate more revenue for the liquidity providers.

The way this integration works is that Curve's lending pools are linked to platforms such as Compound / Yearn Finance / AAVE, in order to enable those loans.

These pools are made up of "wrapped" versions of the tokens, so the system allows them to be interconnected with the various protocols.

The downside of this integration is that since the protocols depend on each other, a problem in one platform can affect the other.

How does Curve Finance improves the second layer utility of a token of a different protocol?

The key term to explain this is "Composability", which can be defined as harmonizing, adjusting, reconciling, and agreeing with another individual to achieve a pact or agreement.

Curve is a platform that performs this function across protocols, so through Curve Finance, we can earn interest or rewards "on and off Curve" thanks to interoperable tokens such as ctokens.

Let's take again the example of the Compound protocol. If we lend DAI (within Compound), a cDAI token is generated which is a collateral to be able to earn and withdraw interest from the DAI lent in Compound.

But the most wonderful thing comes next, as Curve users can use these cDAI tokens obtained on the Compound platform and use them in a curve liquidity pool in order to earn additional profits and to add a second layer of utility from the same investment.

In this way we see how Curve enables harmonization and Composability between different protocols, thus allowing a wider range of options to gain returns on assets.

Like the Compound example, we can use other interoperable tokens from Yearn Finance, AAVE, Synthetix to reapply this same example.

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

The impermanent loss is a loss that is not permanent or has not yet been executed, hence the name, and is a process that occurs when we offer liquidity to a pool within a DeFi platform with automated market markers (AMM).

In liquidity pools, two currencies are provided which must add up to an equivalent value, for example, if we access a SAND / USDT pool, at today's price we should add 6 USDT for each SAND placed in the pool since the current (average) price of SAND is 6 USD.

The impermanent loss, therefore, is one of the risks inherent to this type of market, in which the price of one of the currencies changes drastically compared to the price of the currency already deposited, or in other words: the price of the currency currently varies with respect to the price it had when the deposit was made, thus resulting in losses. As the difference increases further, the greater the loss.

Naturally, the loss will only be realized when the liquidity is withdrawn from the pool. As long as it is not withdrawn, the impermanent loss can swing for or against.

Let's look at another example, suppose we place 20 BNB at a price of 500 USD (let's assume only) each, and 10,000 BUSD; this totals 20,000 USD.

However, the price of BNB unexpectedly rises to 550 USD. As this happens, arbitrage traders add BUSD and withdraw BNB until the ratio reflects the current price. Remember that decentralized exchanges where liquidity is deposited do not work with order books, but with the ratio determining the asset price.

If the liquidity of the pool is maintained, the ratio of the assets must change. Therefore, with BNB priced at 550 USD, our position will be 19 BNB and 10448 BUSD. This adds up to a total of 20977 USD. The funny thing is that if we had only loosened BNB, we would now have 21,000 USD.

The difference between these totals is 23 USD, and that is the loss we would make if we decided to withdraw liquidity from the pool.

As seen in class this occurs between assets that behave differently as is the case with a stablecoin (BUSD) and a volatile currency such as the BNB. For such reason the way Curve protects its users from Impermanet loss is to only allow pools of assets that behave similarly in their dynamics, that have similar or equal value.

For example, in Curve we can find stable coin liquidity pools like DAI, USDT, USDC which always keep the same value of 1USD, or “tokenized” tokens of the same underlying asset like for example sBTC, renBTC, and wBTC.

In this way, the risk of price variation between tokens is almost minimized as neither token becomes volatile with respect to the other.

3. 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?

To begin with, constant product invariant is the formula used by AMM-based decentralized exchanges such as Uniswap to establish the value of tokens in liquidity pools. Its formula is X*Y= k, where k is a constant value.

Because of this formula, graphically it can be expressed as a hyperbola as follows:


Diapositiva1.PNG
Image edited by me in Powerpoint

In this model, we find that there is a limited liquidity zone in addition to a high slippage zone on the sides of the curve, as the formula X*Y=k always seeks to guarantee liquidity by inflating the price extremely high.

Thus when the slippage zone is accessed, a very low output is obtained at the cost of very high input.

This is what happens if we want to convert $100000 USDT to USDC or BUSD, there will be some slippage.

On the other hand, constant sum invariant is the formula used by Curve Finance and is defined with the formula X+Y=k which describes a straight line.


Diapositiva2.PNG
Image edited by me in Powerpoint

This model is actually a theoretical principle where there is infinite liquidity and zero slippage. However, as I said before this is a theoretical model that does not apply in reality.

The Real application is the one that Curve Finance has made by joining both concepts into one, and building a special graph (function), which behaves in its central zone as a smooth curve that resembles a straight line or a flat region in such a way that the exchange between tokens is more efficient.


Diapositiva3.PNG
Image edited by me in Powerpoint

Essentially, for a given region this curve stays flat, which means that when you move between two quantities of token x or token y the price doesn't really fluctuate as much as it does on other AMM-based exchanges where it does fluctuate a lot.

The benefit is that for this flat region range we have a fairly stable price.

How does it lower the slippage?

The answer is that the curve of Curve Finance model is designed to widen the stable price zone and therefore decrease the slippage zone to a minimum (this generates a very small slippage even for large amounts).


Diapositiva4.PNG
Image edited by me in Powerpoint

Additionally let's remember that Curve sponsors liquidity pools between tokens that have the same price, such as stable coins and tokens like cBTC or wBTC; therefore the exchange price will always fluctuate within the region with the flat curve, which is the stable price region. Because of this, if they were not in the same price range, the Curve formula would no longer work efficiently

The amazing thing about this particular type of formula is that Curve can get the slippage or the amount of loss between different tokens to be literally less than 1%.

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

Basically, veCRV is the token that the Curve platform gives you as a grant for having locked or stacked the CRV governance token in the first place. Recall that CRV is the governance token in Curve, which is an incentive for users to offer liquidity to the pool in exchange for voting and decision-making power within the platform.

In order to access these benefits, veCRV is required as collateral. In other words, it is the platform's way of empowering users and opening doors to certain rewards.

The term veCRV means vote-escrowed CRV, which explains a little better the nature of this token. And naturally the longer the blocked CRV lasts the more veCRV you receive.

Primarily the benefits of veCRV are voting power in platform governance decisions and in turn increasing CRV stack profits such as commissions due to transactions in the liquidity pool of up to 2.5X. In fact, half of the commissions recorded on the Curve platform are distributed among veCRV holders.

Other benefits include:

1-Profits from commissions on loans and trades in liquidity pools.

2-Rewards on CRVs and increased profits from CRV blocking.

3-Voting power in DAO proposal and gauge weights.

4-If you have more than 2.500 veCRV you can create an official DAO vote.

5-The use of some functions such as Signalling Tool is free of commissions, and that is only for having 1 veCRV.

5. 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.)

I will perform this trade on the Polygon Network, and perform the swap between USDC and DAI.

My first observation will be the following (you might get a bit of a laugh), but don't forget to have MATIC available in your Metamask wallet, otherwise, you won't be able to perform the swap, just like it happened to me in my first 10 attempts.  

The point is that the Polygon network requires the account to have Matic in order to collect the necessary commissions, and if it doesn't then the Curve exchange simply won't run.

After fixing the Matic problem, I put my input: 1 USDC , and automatically the output was 1 DAI. You can also see reflected the Exchange rate plus commissions = 0.9995, as well as the route through which it will be executed: EURTUSD.


51.png
Image taken from: Source

After clicking on the "SELL" button the first pop-up window appears for confirmation and permission to access the USDC in my wallet. Notice that in this part a commission of 0.01 USD. or 0.001974 MATIC is being charged.


52.png
Image taken from: Source

After waiting a short time, the second pop-up window will appear with a new commission of 0.04 MATIC.


53.png
Image taken from: Source

Finally, the operation has been approved, as I can show in the following polygonscan image.


54.png
Image taken from: Source

This is the HASH of the transaction:

0x1edb51e750b4773c05e10860118e6ffd7580ca46d5f3c8cfc060015568f0af62

One of the observations I could make is that the total transaction fee was only: 0.07471 USD, which makes it incredibly cheap compared to other exchanges.

Another interesting aspect is that in the HASH of the trade you can see the route Curve used to perform the trade: a total of 10 tokens transferred (green box) where we can see that not only Matic's network was involved but also AAVE's.

As for the waiting time: All the exchange operation lasted just between 4 to 5 minutes.

CONCLUSION

It is thanks to all these features that Curve Finance possesses that make it is a powerful competitor in terms of decentralized Exchanges.

Personally, I am very impressed by how clever the developers have been in creating the constant sum invariant and joining it to the constant product invariant to create a system with such a low slippage.

It is easy to understand how in such a short time Curve has reached a total volume of 23,089,589,188.50 USD in their liquidity pools and a daily volume of 777,934,938 USD. They offer what all crypto users are looking for: interoperability and scalability at very low costs.

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  
Loading...

mi profe le deseo una feliz navidad lleno de salud y que Dios Lo Bendiga a usted y a su seres querido un saludo desde la distancia

Igual hermano. Feliz año

Loading...