Smardex: An Intelligent DeFi Protocol for Liquidity and Loss Mitigation