Separating token accounting and pool logic
BEX’s Vault and Pool architecture separates the token accounting and management from the pool logic and AMM math. The responsibility for calculating amounts for swaps, joins, and exits is delegated to the pool contracts, while the Vault holds all of the tokens within the various pools (which can even be of different types).
Send swap request
You send a swap request to the Vault, specifying the pool ID to swap through and the amount to swap.
Calculate balance changes
The pool contract calculates the balance changes from the swap, returning those amounts to the Vault.