How swap functionality and Automated Market Makers (AMMs) work with smart contracts in the DeFi ecosystem.