Synthetixio / issues

0 stars 3 forks source link

[Futures]: feasibility of margin-call callback for cross-margin usage #392

Open artdgn opened 2 years ago

artdgn commented 2 years ago

TL;DR

The idea: call a contract during liquidation (like a "margin call") that can potentially "fix" the position by adding margin.

Motivation

The motivation is to allow contracts to manage multiple market positions on behalf of a user (or strategies) to in a capital efficient manner. Without a margin-call callback this would depend on active monitoring and keepers, but with a margin-call callback this could be done without keepers, all on-chain.

Of course great care would need to be taken to consider all the possible reentrancy issues and risks.

The benefit of this approach over switching to cross margin architecture is that this will preserve the ability to use isolated positions for simple risk-management and gas-efficiency for composability, but will add the more capital-efficient ability to have shared margin. While not fragmenting the market, and not requiring any additional keepers to work.

Rough implementation idea

Cross-margin (shared margin) example usage: