Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于调整 Wtfswap 流动性区间逻辑的方案 #94

Closed
yutingzhao1991 opened this issue Jun 18, 2024 · 3 comments
Closed

关于调整 Wtfswap 流动性区间逻辑的方案 #94

yutingzhao1991 opened this issue Jun 18, 2024 · 3 comments

Comments

@yutingzhao1991
Copy link
Collaborator

@Web3Pignard 讨论了一下,当前 positionType 分别取 -1, 0, 1 ,代表低于价格范围下限、在价格范围内、超出价格范围,这个逻辑可能存在一个问题。

价格范围是在 Pool 的 initialize 方法中初始化的,而这个方法只能调用一次,这样会导致 Pool 的价格范围可能会被恶意设置,或者会由于代币价格的波动导致价格的范围变得没有意义。

Uniswap V3 的价格范围是设置在 Position 上面的,但是这样会导致收取 fee 的逻辑太复杂,不利于教学。经过讨论后决定基于 Uniswap V2 的逻辑进行改进,吸收 Uniswap 价格区间的概念。不同的价格区间都可以创建出不同的 Pool,而不是像 V2 那样默认是 0 到正无穷。另外我们处于教学的目的,不用像 V3 那样考虑充分利用流动性,所以不用基于 Position 来设置价格范围。只需要支持在一个池子内交易即可。

修改后的逻辑变成:

  • 交易对、费率、价格范围,唯一确定一个池子。
  • 每次交易只在一个池子内发生,池子内所有的 LP 按照流动性比例瓜分手续费。
  • 由 DApp 前端来决定在哪个池子内交易。
@yutingzhao1991
Copy link
Collaborator Author

@hattiepwvi @gpteth 也可以看看,这样 Pool 合约的实现应该会更简单一些。

@hattiepwvi
Copy link
Collaborator

hattiepwvi commented Jun 18, 2024 via email

@yutingzhao1991
Copy link
Collaborator Author

已经调整

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants