compound-finance / compound-protocol

The Compound On-Chain Protocol
https://compound.finance/developers
BSD 3-Clause "New" or "Revised" License
1.89k stars 1.21k forks source link

Is the calculation formula correct or not? #178

Open Stevewu1234 opened 2 years ago

Stevewu1234 commented 2 years ago

Regarding to the function of distributeBorrowerComp() in https://github.com/compound-finance/compound-protocol/blob/master/contracts/Comptroller.sol, the formula of calculating account borrow amount is: uint borrowerAmount = div_(CToken(cToken).borrowBalanceStored(borrower), marketBorrowIndex);

I saw the borrowAmount calculation in cToken is: recentBorrowBalance = borrower.borrowBalance * market.borrowIndex / borrower.borrowIndex

Is the borrowerAmount in distributeBorrowerComp() correct or not?

StillFantastic commented 2 years ago

Hi @Stevewu1234, did you figure this out at the end? I also have the same question and just came across this issue.