Uniswap V2 - Automated Market Maker Video

This is a thread to discuss the concept of Automated Market Maker (AMM) and how Uniswap V2 works that we covered on Youtube, a very important concept in DeFi space and has been used in many other protocols, including but not limited to Sushiswap, Pancakeswap, Quickswap, Pangolin, TraderJoe, etc.

If you have any questions, feel free to post your questions here and we are here to help you as soon as possible~

2 Likes

Hello I have a question on liquidity of USD stable coins, how they are pegged to 1 dollar on these dexes like uniswap. I know that they are pegged 1:1 against USD Dollar reserves but How an erc20 USDT or USDC is pegged to 1 dollar on Dexes

2 Likes

Hey @UsmanSoftDev thanks for the question! so they are actually not exactly pegged in DEX at all like in a USDT-USDC pool price could be pretty much goes inbalance like 1 USDT = 0.99 USDC or 1USDT = 1.1 USDC. This can be very easily seen in any stablecoin pool.

However usually this is an arbitrage opportunity that people can take advantage of which if the price is less than 1 dollar people can buy it from Uniswap and sell it in other AMMs or even in Uniswap itself, and if it’s more than 1 dollar then the same things will work and asset can be sold for higher price.

Now through this buying and selling arbitrage activity, it should be pushing the price in DEX as close as possible to 1 dollar. These arbitraging sre usually also very competitive and fast using bots which also utilize Flash Loan from Aave to take huge leverage to gain a lot from the small margin differences usually happen in DEXs.

Cheers~

Thanks @ YosephKS for reply.
So My question was USDT and USDC is just a normal ERC20 token so How it is pegged to approx 1 Dollar? Is it by ETH/USDT liquidity or what.
If I Launch an ERC20 coin how i will pegged it to approx 1 dollar. ?

that seems like a complicated question, I don’t think that it is easy to peg to 1 dollar a new ERC20 token, I think that you’ll need to have a way to keep it stable with external mechanisms outside of that new ERC20 token

Well it depends on what stablecoin it is, and it could be complicated as @cryptokid says, but in short there is custodial stablecoin like USDT, USDC, and USDP. They are basically pegged to the dollar under the assumption people trust that it is backed by the similar amount of dollar asset + sometimes some government bonds.

On the other hand, there is DAI stablecoin which is known as an algorithmic stablecoin and by nature it is non-custodial because it is backed by assets stored in a smart contract instead of an institution. Now there are many variation of algorithmic stablecoin, but most of the existing one issued are basically more like a debt/derivative asset because the value of the stablecoin is derived by the stored asset like ETH in the smart contract as collateral. Of course in the case of asset price going down, those collateral can be liquidated.

YosephKS Yes it is backed by Centralized systems I Know, USDT or USDC on Centralize Exchanges is approx 1 dollar but when we talk about AMMs there is a truth that can be seen in code. How in Uniswap they pegged their values by code?. I know this is some silly question but I want to understand it.

I know About MakerDAO DAI, They do by their complex algorithms.

on what values are you referring that are pegged by code in uniswap?

I wrote the answer above, it cannot be simply pegged in smart contract and it’s very common the tokens in LP have price deviate from it’s real price like 1 USDT = 0.99 USDC, but this is an arbitrage opportunity taken by bots to buy the asset at the cheaper price, which in turn will push the supply to 1:1 ratio and price to 1 USDT = 1 USDC

1 Like

Know that the token price in Uniswap is determined by X * Y = K equation and not in anyway pegged to anything :raised_hands: I explain this more in the video, consider rewatching it if you still wasn’t clear on it, because I explained how these works in details and even give the math derivation on how to calculate the token price

im talking about prices

Ok Thanks. 1 more Question how Ether price will be fetched on Uniswap?

You mean Ether to what pair? Regardless of the pair, the price can be fetched by using getAmountOut function in the Router contract, which exist in uniswap-v2/periphery repository, it’s calculated based on X * Y = K

2 Likes