我目前正在开发一个Uniswap V2叉子。不过,我对如何把收费订得合意,感到有些困惑。我需要帮助找到合同和在合同中的作用,以确定费用,我喜欢。任何帮助都将不胜感激。
发布于 2021-07-26 02:09:29
3/1000的费用是硬编码的。
uint balance0Adjusted = balance0.mul(1000).sub(amount0In.mul(3));
uint balance1Adjusted = balance1.mul(1000).sub(amount1In.mul(3));
require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'UniswapV2: balance0和balance1是掉期完成后的余额/准备金,reserve0和reserve1是掉期之前的余额/准备金(掉期先完成,然后可能恢复,当不满足要求时)。
要求你不要减少储备的产品(否则你可以从池中窃取流动资金)
balance0 * balance1 >= reserve0 * reserve1其中balance将是交换后的新reserve。1000的因子并不能改变这种不平等。
balance0 * 1000 * balance1 * 1000 >= reserver0 * reserve1 * 1000**2如您所见,balance0Adjusted并不完全是balance0 * 1000。通过减少这一点,balance0必须更高才能预先满足需求(1相同),因此您必须为相同的输出投入更多。那就是3/1000的费用所在。
https://ethereum.stackexchange.com/questions/104067
复制相似问题