unisWAPV2PAIR,薄荷功能,如何创建流动性与添加的流动性的比例
function mint(address to) external lock returns (uint liquidity) {
}
以上功能的实现使流动性被添加到要解决的地址中,但是流动性只是根据储备金的差异和代币的差异而铸造的,它将如何根据发件人添加的流动性成比例地创建流动性,
我是否缺少某些东西,是否丢失了某些东西,如果用户始终调用薄荷功能,他将不会在地址中添加免费的LP代币,因为我们可以看到薄荷功能是外部的,而不是内部
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您缺少功能主体和所有逻辑并在内部进行检查它。
You are missing the function body and all the logic and checks inside it.
mint()函数本身只有薄荷lp令牌可以弥补实际LP平衡和预期LP平衡之间的差异。如果实际和预期余额之间没有区别,则没有LP令牌。
一种常见的做法是使用路由器函数将令牌发送到配对合同,然后调用
mint()
函数 - 这两者都是一项交易的一部分,因此无法完成此操作。如果有基本令牌发送到该配对合同的情况下,而无需调用
mint()
函数,那么任何人都可以自由调用该函数以代表此差异的LP令牌。但是,只有一次,作为LP薄荷零,差异。The mint() function itself only mints LP tokens to make up for a difference between actual LP balance and expected LP balance. If there's no difference between the actual and expected balances, no LP tokens are minted.
A common practice is to use the router function addLiquidity() which sends tokens to the Pair contract, and then invokes the
mint()
function - both as part of one transaction, so there's no way to frontrun this action.If there were underlying tokens sent to the Pair contract without invoking the
mint()
function, then anyone could invoke this function freely claiming LP tokens representing this difference. However only once, as the LP mint zeros up the difference.当用户添加流动性时,
因为主要方程是基于增加的流动性与LP令牌股票的增加成正比。这是有道理的,因为增加流动性对价格没有影响,因此,如果您增加了更多的流动性,则应该收到与收到的LP代币成正比的,例如,
假设您拥有T股,并且希望将流动性从L0提高到L1。还会为您造成多少股?
我们需要查找
mintamount
。最后
mint()
is called when a user added liquidity.Because the main equation is based on increasing liquidity is proportional to an increase in LP token shares. This makes sense because adding liquidity has no effect on price, so if you add more liquidity, you should receive LP tokens proportional to what you have received before
Let's say you have T shares and you want to increase liquidity from L0 to L1. How many more shares will be minted for you?
We need to find
mintAmount
.Finally