The HydraDX math crate contains all the mathematical formulas for the various implementations of AMM pools.
The main goal of having this math functionality as a separate crate is to make it possible to easily compile it into WebAssembly which allows us to use the wasm library directly on the frontend.
This way, we can compute everything that is needed on the frontend side in the same way that it is calculated when a transaction is submitted using same math and without the need to talk to the node.
Another benefit which domes from this approach - it is easily testable.
XYK implementation can be found in amm.rs. It consists of following methods:
The HydraDX Omnipool math implementation can be found in the hdx module.
It has similar methods as xyk but different parameters are needed.