osmosis-labs / isotonic

Smart Contracts for the Lendex Protocol
MIT License
1 stars 0 forks source link

Use time-weighted average price in calculating liquidation #110

Open ks-victor opened 2 years ago

ks-victor commented 2 years ago

For the liquidation we need to use a time weighted average price (TWAP) to avoid that people try to manipulate the price by buying large amounts from a LP pool and there by triggering liquidation using for example flash loans.

The Osmosis team is building a TWAP price fee, but this might be delayed. The question is if we use the spot price or build a TWAP price ourself. We will need to know how long time the TWAP is calculated for and if it is too long, we risk that we during a genuien market crash, don't liquidate any loans because the price crashes quicker than the time average can follow it down and we end up with a huge amount of loans where the collateral is less worth than the loan and the market is for the next long time trading at this new lower price level.

[] Discuss with Osmosis if use the spot price or build a isotonic TWAP [] Figure out what is a good time length of the TWAP and what minus percentage deviation is acceptable.

+++ not finished writing +++

It should be short enough for