Dual-Finance / risk-manager

Risk management for Dual Finance protocol DIP positions
MIT License
12 stars 4 forks source link

Rebalance spot vs perp positions post exercise #28

Open DonDuala opened 1 year ago

DonDuala commented 1 year ago

When we exercise DIPs we will not close out our perp position. This overtime can lead to the need to re-balance spot vs perp positions. Example: Upside 100 SOL DIP exercised, we're short 100 SOL-PERP on Mango, now we have 100 SOL to deposit in mango to support the short perp position so the position don't get liquidated. We'll want to sell spot, buy perp with minimal market impact making markets on the less liquid market, taking immediately upon receiving a fill on the other. Requires serum integration via mango

brittcyr commented 1 year ago

When we exercise, the amount of options in the risk manager will reduce. It will just do the opposite of a deposit with at least the delta. Do we need to prevent that from happening and deposit SOL instead?

DonDuala commented 1 year ago

Exercise triggers 2 things:

  1. DIP delta goes to zero for that specific pool
  2. Risk Manager buys/sells X delta at strike price The net result of the two should be hedged. When this typically occurs it will be a zero delta event, that is we will not need to hedge any perps since we still have that delta just in spot form now, not DIP form
DonDuala commented 1 year ago

We need to explicitly add 2 to the delta calculation when exercise happens

DonDuala commented 1 year ago

Delta Calc now accounts for spot positions across wallets and on mango.

Manually selling spot tokens on mango will force unwinds of perp positions after a rerun, but we want to poll for balance changes to these accounts as well so it happens immediately.

Auto deposit exercised spot tokens to mango will ensure no liquidation. Cap mango spot positions by notional. We will eventually need spot tokens for downside exercises however