ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
Simulating single-asset entry (joinSwapExternAmountIn) - "Join with" column has amount you're depositing. Output is poolAmountOut, and newTokenBalance
2
Can repeat by copying F into C (updating token balance), and H into the total supply B12.
3
4
Join with
5
TokenWeightBalancetoken amtRatio in
newTokenBalanceIn
PoolAmountOut
new totalSupply
1) In column D, type in the document you are depositing for single asset entry (e.g., 0.6 WETH)
6
SXAU20.132000.1320302.5757164
You are limited to 1/2 the current balance - if you try to add 1 WETH, it won't let you (ratio in turns red)
7
WETH41.35001.350302.5757164
2) If you enter a valid amount, ratio in is deposit/balance = 0.444; < 0.5, so ok
8
WBTC81.194001.1940302.5757164
3) It computes the new WETH balance (balance + deposit - fees = 1.926)
9
rBPT6100001000302.5757164
4) It computes the poolAmountOut - the number of tokens it will mint when you deposit the WETH
10
20
This is calculated using the weights, balances, WETH's proportion in the pool, and total liquidity (exponential formula)
11
5) Since we're minting pool tokens, the total supply goes up (just existing supply + poolAmountOut)
12
Swap fee0.05
6) To do this iteratively, you would copy the new token balance (overwrite 1.35 with 1.926)
13
Total supply302.5757164
and the new total supply (overwrite 302.57 in B13 with 324.86 in H7).
14
15
spot price is: (balanceIn/weightIn) / (balanceOut/weightOut) * 1/(1- swap fee)
16
17
Simulating multi-asset exit (exitPool) - Pool amount in is the amount of pool tokens you're burning
18
Pool
To simulate exitPool
19
TokenWeightBalance
Multi-asset-out
Amount IntokenOut
new totalSupply
new balances
1) Type the number of pool tokens you're burning in B30
20
SXAU20.1320.04363100.02833557752292.57571640.10366
2) It will show you the balances you would be withdrawing for that number of tokens
21
WETH41.350.4461700302.57571640.90383
3) The total supply would then decrease by poolAmountOut
22
WBTC81.1940.3947400302.57571640.79965
4) To iterate, you would copy the new balances from H to C, and adjust the total supply and "This LP balance"
23
rBPT610033.0495800302.575716466.95042
24
20
To simulate single asset withdrawal (exitswapPoolAmountIn)
25
1) Type in the pool tokens you are burning in column E; for instance, 100 tokens worth of WBTC
26
Swap fee0.05
2) It will show you the amount you'd be withdrawing (0.33 WBTC), and the new balance and new total supply
27
Total supply302.5757164
28
This LP bal202.5757164
29
30
PoolAmountIn
100
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100