pool_state_updates.py
Pool related state update functions:
ActionDecoder's decoded actions (signals, in cadCAD lore) get passed here into s_update_pool, which redirects to the actual state update function like s_swap_exact_amount_in. The redirection is performed via a dict lookup:
pool_operation_mappings = {
JoinSwapExternAmountInInput: s_join_swap_extern_amount_in,
JoinParamsInput: s_join_pool,
SwapExactAmountInInput: s_swap_exact_amount_in,
SwapExactAmountOutInput: s_swap_exact_amount_out,
ExitPoolInput: s_exit_pool,
ExitSwapPoolAmountInInput: s_exit_swap_pool_amount_in,
ExitSwapPoolExternAmountOutInput: s_exit_swap_extern_amount_out
}Each state update function follows the same structure:
Parse input from the action and get variables from current
poolstate (related token balances)Apply related Balancer Math
Update fees if applicable
Update pool balances
Return pool so action decoder can signal updates
Some sanity checks are made, following BPool smart contracts. In REPLAY_OUTPUT mode no sanity checks are performed:
Min/Max limits in prices and token amounts are not included since the model won't late stuck transactions or tx reordering like the actual BPool contract.
Swaps
Join Multi Asset
Join Single Asset
Single Asset Exit
Exit Multi Asset
Last updated
Was this helpful?