How Does a Smart Contract Perform a Margin Call and Liquidation?
The smart contract constantly monitors the collateralization ratio of a user's position using a real-time price feed from an oracle. If the ratio drops below a pre-set maintenance margin threshold, the contract automatically triggers a "margin call" and allows a liquidator (often a bot) to repay the debt.
The contract then sells the collateral at a discount to cover the debt, often imposing a penalty fee on the borrower.