Understanding Algorithmic Stablecoins: Mechanics, Risks, and Types