A theory of Automated Market Makers in DeFi