1/ If, after reading https://t.co/IzzATArtZl you are still confused how Alpha Homora and IronBank were hacked, here's how the hack was conceived

2/ Normally when you borrow funds from AH bank, your debtShare and totalDebt increases. Specifically if you want to borrow x tokens, your debt share will be calculated as:

share = x * totalShare / totalDebt

and it is added to totalShare
3/ All these numbers are very big integers (as token precisions are 18 digits) and the calculation is correct, but when totalShare = 1 (think 1 wei) and x < totalDebt, new debt share will be 0 (integer division)
4/ So if you manage to have AH bank with totalShare = 1, and some totalDebt you can repeatedly borrow less than the totalDebt (ideally totalDebt - 1) effectively doubling totalDebt in each iteration. You can do it as many times as you want, while totalShare will remain 1
5/ Eventually Iron Bank that supplies funds to AH will run out of funds, so when amounts get big enough (you are doubling each time), also make sure to replenish it with flash loan
6/ But first you need to make sure that there is a AH bank with totalShare = 1 in the first place. To do that you need to start with an empty bank, i.e. token that has been approved but not used yet. In this case - sUSD
7/ Then you need to do some initial setup which involves putting some collateral, taking small loan and repaying almost all of it - almost, leaving exactly 1 wei. Now you have a bank with totalShare and totalDebt = 1. Almost done, need to increase totalDebt
8/ To do that you call resolveReserve() method on this bank which will increase totalDebt without increasing totalShare and your setup is finished. Now you can extract funds doubling totalDebt at each step.
9/ Notice the state of the initial setup just before a sequence of borrows
https://t.co/267VbLXVUF

More from Finance

1/18 After 3 months, @saffronfinance_ is no longer new on the scene. Now that the kid has climbed the ranks, it's time to see if he can hang with the big boys.

Below are some updated thoughts on potential integrations, improvements, and innovations for Saffron moving forward. ⬇️


2/18 First, if you haven't seen @Privatechad_'s alpha-leaking introductory thread, you should check it out.

I agree that @AlphaFinanceLab and @CreamdotFinance, specifically the Iron Bank, would be ideal targets for SFI risk tranches.


3/18 Speaking more broadly, Saffron is primarily integrated with @compoundfinance, which has served as a MVP of sorts.

The thing is, Compound is one of the safest (but also lowest yield) protocols in DeFi, so it's not surprising that there isn't much demand for the sen. tranche.


4/18 Expanding beyond Compound to higher-risk/higher-return protocols has always been key.

These protocols are the bread-and-butter target market for Saffron, and I would expect to see a surge in demand for senior tranche staking in these


5/18 Additionally, @DeFiGod1 convinced me that Senior Tranche pools would be more appealing if they offered fixed yield.

Essentially, Saffron would augment the product offerings of @Barn_Bridge by also offering senior stakers insurance in the form of junior tranche collateral.

You May Also Like