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

Xyk bonding curve #29

Merged
merged 14 commits into from
Aug 5, 2022

Conversation

0xacedia
Copy link
Contributor

@0xacedia 0xacedia commented Jul 31, 2022

Adds support for an x*y=k style bonding curve.

After discussion:

The x and y are based on virtual amounts not actual amounts.
This allows inventory to be decoupled from price/slippage.

For example, Alice may set her x to be 30 eth and her y to be 3 nfts.
But she may then only deposit 10 eth and 1 nft.
That means that the curve will move along as if there was 30 eth and 3 nfts of liquidity.
Similarly she may also specify a different ratio. x = 20 eth, y = 3 nfts (price = 20 / 3 = 6.67).
And then deposit 10 eth and 1 nft (price = 10 / 1 = 10.0).
This means that the curve will move along as if it had 20 eth and 3 nfts of liquidity.

Of course, if the virtual reserves don't match up with the actual reserves then this means that it's possible for a pool to run out of liquidity if it gets sufficiently far along the curve. However this is no different than how the linear and exponential curves behave. The key thing is the way that the curve is shaped: x*y=k.

@0xacedia 0xacedia changed the title WIP: Xyk bonding curve Xyk bonding curve Aug 1, 2022
@0xacedia
Copy link
Contributor Author

0xacedia commented Aug 1, 2022

Had to make a few changes to the test-cases to make them work with the xyk curve. Mainly just removing some of the fixed parameters in RouterRobustSwap, RouterSinglePool and RouterSinglePoolWithAssetRecipient.

@sudo-owen sudo-owen changed the base branch from main to feat/xyk-bonding-curve August 5, 2022 19:45
@sudo-owen sudo-owen merged commit 5508dca into sudoswap:feat/xyk-bonding-curve Aug 5, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants