Add an entity that tracks the margin for each user within each market. The entity will update each time they deposit, withdraw, or modify their position.
Cap liquidation losses to initial margin + total deposits. This occurs when funding is really high or closing price results in excess losses taken by the debt pool.