Owners: @Giacomo Pasini @David Rusu
TODO
- Test wether using XOR for mint/burn salts produces a measurable improvement in proof time
- Rename
Proved{Tx/Bundle/Input/…}
to {Tx/Bundle/Input}Proof
- Make non-membership proofs on the MMR insteaf of the full tree in the IMT
How Does Uniswap Work?
- Fees are deposited directly into the Pair Token Pools during swaps
- When depositing liquidity, the LP receives lp tokens proportional to their contributions:
- If LP deposits amount0 of token0 and amount1 of token1 then the amount of lp tokens returned to the LP is calculated using:
lp_tokens = min(amount0/balance0, amount1/balance1) * lp_total_liquidity
- that is, the LP only gets credit for the smaller portion of either token contributed (if he contributes 10% of NMO in the pair and 0% of PEPE, he gets 0 LP tokens)
lp_total_supply += lp_tokens
- LP tokens are inflated after every deposit
- The Effect of this is that the product
balance0 * balance1
increases
- When withdrawing liquidity, the LP burns his LP tokens and receives equal portions (by price) of each token
lp_pct = lp_tokens / lp_total_supply
amount0 = lp_pct * balance0
amount1 = lp_pct * balance1
- LP receives
amount0
and amount1
lp_total_supply -= lp_tokens
- LP total supply is deflated after withdraw
- Effect of this is that the product
balance0 * balance1
decreases
- Swap, we assert that the final execution of the swap maintains this invariant:
(balance0Final - 0.003 * amount0In) * (balance1Final - 0.003 * amount1In) = balance0Start * balance1Start
- That is, the finale product of balances increases by 0.3% after each swap.
- Uniswap callsback to the user contract in the middle of the swap after sending the funds to the user and then asserts the above condition after the call. This lets the caller do arbitrary actions with the funds so long as the Pair receives their 0.3% fee.
- https://www.desmos.com/calculator/j8eppi5vvu
Uniswap on Nomos Design - SwapVM
- The zone will govern swaps around all (token1, token2, fee) tuples, which will be internally maintained in a map
- To reduce fees for swaps and LPing, the zone will have its internal account system
Constants