-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the swap calculation to be more fair
For example, consider we have a low-divisiblity pool, like XDIAMOND, with 20k ADA and 50 XDIAMOND If the user offers 799 ADA, they could get ~1.9 XDIAMOND... except that because of rounding, and because XDIAMOND isn't divisible, we get only 1 This means the user paid almost twice as much as they could have. To ensure a fairer pricing for the user, we 1) allow less than `offer` tokens to be actually given to the pool 2) ensure that this given amount still gives the same `takes` as the `offer` 3) ensure that if we had given one less, we would have gotten less! Thus, this forces the scooper to build a transaction where the user gives 408_367_450 into the pool, and the remaining 390_632_550 is returned to them.
- Loading branch information
1 parent
7181c12
commit dd12ad9
Showing
3 changed files
with
196 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.