Skip to content

Instantly share code, notes, and snippets.

@itoonx
Last active July 31, 2021 13:01
Show Gist options
  • Save itoonx/6fa6794ddf859af79bae185aec31ad11 to your computer and use it in GitHub Desktop.
Save itoonx/6fa6794ddf859af79bae185aec31ad11 to your computer and use it in GitHub Desktop.
AMM Model of UniswapV2

AMM Model of UniswapV2

LP Token calculator - สูตรการหามูลค่า LP Token

1 LP Value = ( Total value of Pool / Circulating supply LP )

RAY Price = 10.85

RAY Amount = 1,486,494.518254 Token

RAY Value = Amount * Price => (RAY Amount * Price )

16113783.77387336 USD

USDT Price = 1

USDT Amount = 16,052,921.852287 Token

USDT Value = Amount * Price Feed => (USDT Amount * Price )

16,052,921.852287 USD

Total Value = (16113783.77387336 + 16,052,921.852287) = 32166705.62616036

Circulating Supply LP = 1,778,036.815305

LP Value Formula = 18.091135880469699

Your Staking = 315.648927

Your LP Value = 5710.447628881460745 USD


Price calculator - สูตรการหาเรท Swap

Price = ( X * Y = K ) or (TokenX * TokenY = K) Example:

ETH Pool = 10

XRP Pool = 500

K Weight = 10 * 500 = 5000

Swap(1 ETH) = ?XRP

1 ETH to ETH pool

11 ETH * ? XRP = 5000

?XRP = 5000 / 11 = 454.545454545454545

UpdatePool(XRP Pool) = 500 - 454.545454545454545

XRP Pool = 45.454545454545455

Trading Fee X ETH = 0.3%

Fee = (454.545454545454545 * 0.3) / 100) = 1.363636363636364

Balance to receive = 454.545454545454545 - 1.363636363636364 = 453.181818181818181

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment