Skip to content

XLS‐30 AMM FAQ

Elliot Lee edited this page Jul 8, 2024 · 1 revision

account addresses

After a test network reset, you can re-create settings and data. AMM accounts may not use the same addresses after the reset.

Q: How are AMM account addresses generated?

A: It's based on a hash of the two assets (currency + issuer) plus a counter / nonce in case of collision. It's effectively deterministic if there are no collisions, but non-deterministic if there are.

LP Token value

To figure out how much a given amount of LP Tokens is worth, in terms of the two assets in an AMM's pool:

Call amm_info and then do some calculations on amount/amount2 and lp_token.

Suppose I hold an amount of LP Tokens equal to N. Pseudo-code:

var asset  // first asset of the AMM pool
var asset2 // second asset of the AMM pool
var N      // number of LP Tokens I hold

amm_result = get amm_info(asset, asset2)

// Calculate what fraction of total LPT I hold
my_share = N / amm_result.amm.lp_token.value

my_asset1 = amm_result.amm.amount.value * my_share
my_asset2 = amm_result.amm.amount2.value * my_share

print("My share of the AMM's pool is worth:")
print(my_asset1, amm_result.amm.amount.currency)
print("and")
print(my_asset2, amm_result.amm.amount2.currency)

amm withdraw all would wrap your LPTokens for the underlying assets.

If you own 5% of all LPT, then that means you can theoretically withdraw for 5% each of both assets in the pool.