Created
March 6, 2024 20:15
-
-
Save JohnPlummer/255df66376767be4111a5733ba399c1f to your computer and use it in GitHub Desktop.
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
# Constants for the initial state of the liquidity pool | |
x_initial = 1000 # Initial amount of Token A | |
y_initial = 1000 # Initial amount of Token B | |
k = x_initial * y_initial # Constant product k | |
delta_x = 100 # Amount of Token A being swapped | |
# New amount of Token A in the pool | |
x_final = x_initial + delta_x | |
# Calculate the new amount of Token B using the constant product formula | |
y_final = k / x_final | |
# Amount of Token B received | |
delta_y = y_initial - y_final | |
delta_y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment