A theory of Automated Market Makers in DeFi (Logical Methods in Computer Science, 2022)