Understanding DeFi: The Foundations of Decentralized Finance