Posts

Why I was liquidated in Aave (Polygon)

avatar of @notak
25
@notak
·
·
0 views
·
3 min read

For those that Don't know, Aave is a platform where you deposit and lend money and earn some interest.

The current earning and deposit rates are shown below:

An opportunity arose

Just yesterday, USDC was yielding 9% for a deposit, and DAI was yielding 5% for a loan.

not only would I receive more interest than the loan interest I would get bonus rewards in MATIC.

So as you would expect I decided to leverage pretty hard. I made sure I had enough room before liquidation to sustain a 5% movement in the DAI or USDC price. I checked historical volatility, and was sure I was ok, save an extreme movement where the stablecoins lost peg.

So why was I liquidated?

As is always the case, I was sleeping when it happened, so had no time to react. I wake up this morning, and see half my balance closed out. The first thing I expected was that the price must have moved away from peg. Checked all the charts and history, and nothing like that occurred.

So what happened?

Here is where it gets interesting, and you need to start to understand how Aave receives its pricing feeds.

How does Aave receive its prices?

To have a secure price feed to avoid manipulation, Aave has a number of transmitters that must transmit the price to the pricing oracle, and then the median price is used to determine the price.

All the prices that are submitted, are the prices expressed in ETH, because Aave originally was built on Ethereum.

So for example for the price for DAI at the moment is 0.000298200360822436 ETH. Also the price for USDC at the moment is 0.00029788951 ETH You can read the contract here: USDC Price Oracle

Now the ratio of those two prices are 100.1%, so within the normal range, but this can be higher than you would expect, and it all comes down to the timing of when the price was last updated.

The USDC was updated 6:30am UTC, whereas the DAI price was updated 6:41am UTC so there is always some movement in the WETH price between updates.

What happened yesterday

Well, the ETH price fell pretty fast, by about 10%. But the USDC and DAI prices didn't as a % of the USD, but their price did rise when expressed as ETH. However there was a timing difference between when the USDC prices were updated and when the DAI prices were updated. Therefore from Aave's perspective I was in liquidation territory.

Someone knew this and took advantage of this, and collected the 5% liquidation fee from a whole stack of positions on Aave.

I have been investigating this one today, and I cant cry too much as I only lost a small amount. But I saw one transaction where the liquidation fee was $10k. Goes to show you having good knowledge of how these popular smart contracts works is important.

The transaction screen shot here shows $114k was liquidated, and $10k when to the liquidator (second last line), who ran a bot taking advantage of the situation.

Lessons learned

Well, the lesson here is you need to really understand the mechanics of your investments particularly when it crashes. I didn't expect to be exposed to ETH price volatility, but in the end that's what liquidated me. As I said before only 50% of my position was closed out, I think of it as a cheap lesson.

I've learned my lesson, now time to earn it back!

Posted Using LeoFinance Beta