* token-swap: Fix withdrawal all tokens slippage
When withdrawing, the slippage check is done before `min`ing the token a
and b amounts, which makes it possible to ignore the desired slippage,
and lose out on a lot more than expected.
This has an additional knock-on effect. When burning all of the pool
tokens, it becomes impossible to ever use it again.
* Check for slippage after getting the actual amount that would be
traded
* Re-initialize the pool token amount on the next deposit if all pool
tokens were burned
Fixes#1629
* Fmt + clippy
* Deposit one side on 0 pool tokens just gives new supply back
* Add price parameter for flat / constant price curve
This encompasses a lot of changes to properly support the constant price
curve, and fixes some old pain points to make the whole thing easier to
use, including:
* refactor fees out of the curve
* move all fee calculations into new Fees type
* modify constraints to only care about curve types and fee
* add price parameter into constant price curve (flat curve)
* Run cargo fmt and clippy
* Revert interface changes and math update
* Run cargo fmt
* Address review feedback
* Fix fraction validation for zeros
* Added stable curve invariant to the token swap smart contract
* Fixed formatting
* Added missing stable curve constraints
* Symbol renames to make math clearer
* Small refactoring according to PR comments, fixes for JS tests