Closed ueco-jb closed 2 years ago
Actually it's not 100% ready for review. In some test I stumbled upon error: if there's no ltokens minted (so no one deposited tokens), charge interests function will fail on this formula:
l_ratio = b_supply() * ratio / l_supply()
because of lack of ltokens supply.
@ethanfrey how should this case be handled? Just return an error and cancel operation? This is bit weird, because: 1) I create Market contracts with some tokens in proper denom. 2) Borrower borrows some tokens 3) Move time forward 4) Only next operation that requires mint/burn will trigger counting interest charges, which will fail.
So I guess we probably should forbid borrow when no ltokens are minted?
Actually that might be a first bit of can_borrow
implementation? https://github.com/confio/lendex/blob/main/contracts/lendex-market/src/contract.rs#L218
You should never be able to have more broken than ltokens. how could you have funds to borrow ?
but yeah, good to protect against divide by zero stuff. If there are no ltokens, then just don't give out interest payments.
We will need some follow up issues here
We will need some follow up issues here
The conflicts are probably because I moved Interest
from lendex-market
to utils
in the last PR.
closes https://github.com/confio/lendex/issues/9
A lot of TODOs. Most (if not all) are related to precision. Ethan suggested changing default
MULTIPLIER
in lendex-token from 1% to 1 permille, but it breakes a lot of tests in token so probably better do this in separate PR.