当前位置:网站首页>Uniswapv2 peripheral contract learning (IX) -- examplecombinedswapadddremoveliquidity sol
Uniswapv2 peripheral contract learning (IX) -- examplecombinedswapadddremoveliquidity sol
2022-06-09 14:02:00 【MateZero】
I remember a sentence from my circle of friends , If Defi It is the crown of Ethereum , that Uniswap It is the Pearl in this crown .Uniswap So far V2 edition , relative V1, Its functions are more comprehensive and optimized , However, the contract source code is not complicated . This article is for personal learning UniswapV2 Source code of a series of record articles .
One 、 Single asset liquidity supply
We know ,Uniswap When providing liquidity, both assets in the transaction pair must be injected proportionally at the same time , Then get the liquidity token . Two assets are required at the same time , This virtually raises the threshold for users . If the user has only one ( Or just focus on one ) What about assets ? Can you provide liquidity supply ? The answer is OK .
stay Router The contract provides an interface for liquidity management , It also provides an interface for asset transactions . Then we can combine these two functions in the same function , Trading assets before providing liquidity , Or remove liquidity before trading assets .
If a single asset provides liquidity , First, a part of the assets provided should be traded , Get another asset , So there are two kinds of assets . Then call Router The increased liquidity interface of the contract injects assets to provide liquidity . How many assets will be distributed for trading to ensure that all assets are injected ( The proportion at the time of injection is the same as that in the post transaction transaction pair ), Is the core of this operation , You need to use a formula to calculate .
If you remove liquidity and get a single asset , This is relatively simple . First remove the liquidity and get two kinds of assets , Then exchange one of these assets for another . The asset thus obtained is the amount of withdrawal plus the amount of transaction .
You can see , Yes Uniswap Speaking of , The essence of single asset liquidity supply here is double asset injection ( Determined by its underlying implementation ), It just converts a single asset into a dual asset in advance .
notes : There are other types of single asset liquidity supply , for example BancorV
边栏推荐
猜你喜欢

Yunna database monitoring tool, database monitoring operation and maintenance tool

Analysis on the resumption of the most serious downtime in the history of Facebook on October 4, 2021

TCP/IP协议(1)
![[Clickhouse column] installation and verification of stand-alone version](/img/fa/d8f88243a78f4253e01d04b587c6b4.png)
[Clickhouse column] installation and verification of stand-alone version

What are the types and aspects of Yunna asset management system

Yunna | which department manages the fixed assets and who manages them

AI 考生挑战高考作文,平均 1 秒生成 1 篇,水平超 75% 考生

CSDN音视频技术开发者在线调研

未磁科技完成超亿元A轮融资,核心团队毕业于北航

C语言 结构体 | 链表
随机推荐
leetcode:497. 非重叠矩形中的随机点【随缘随机 + 前缀和二分 + 过了就行】
Wechat applet
Event storm method of DDD modeling methodology
Yunna | how to do a good inventory of fixed assets? How to count fixed assets
L'ambassade aux États - Unis avertit les citoyens chinois aux États - Unis de la sécurité des voyages d'été
Yunna intelligent operation and maintenance management system platform, visual operation and maintenance system management
Prototype chain? New misconceptions
Network attacks focus on people's livelihood. How can we effectively defend against DDoS and apt attacks?
输入一行字符(最多80个),从第location个位置开始,截取number个字符并将其输出。
Development and present situation of Network Space Surveying and mapping at home and abroad
Explain the three ways to remove duplicate data in MySQL
HCIA datacom experiment IPv4 addressing and IPv4 routing basic experiment
C语言 结构体 | 链表
字节序,object类
#yyds干货盘点# 解决剑指offer:矩形覆盖
Dr. Stanford put forward the idea of ultra fast and saving memory attention. The gpt-2 training speed was increased by 3.5 times, and the Bert speed reached a record
TCP/IP协议机制详解
记忆化搜索+状态压缩leetcode.464
QUIC必看
win11启用多用户远程桌面同时登陆