Open Rapha-btc opened 9 months ago
Tested in clarinet console: dlc-manager-v1-1 and uasu-sbtc-loan-v2 as followed:
I'd love also to understand from there how they take outcome u0 and unlock DLC 100% to Alice @radicleart
problem: anyone can call this public function but it should be restricted to dlc-manager-v1-1
-> add this (asserts! (is-eq dlc-manager-address contract-caller) err-unauthorised)
@radicleart Loan Ratio of 140% means that Collateral / Loan must be greater than 140%, else loan is eligible for liquidation
C/L >= LR then does-not-need-liquidation
if (<= C / L LR) then eligible for liquidation if (<= C LR * L) then eligible for liquidation
therefore on line 317 of uasu-sbtc-loan-v2 it's the other way around:
(ok (>= loan-amount (/ (* collateral u10000) (get liquidation-ratio loan))))
for sBTC you can set this at u10500 rather than u14000 because it's not like borrowing dollar stablecoins @radicleart
I made 27 tests using clarinet console (https://github.com/Uasu-Finance/uasu-clar/issues/9) but got rid of the attestators in the setup-loan because I didn't know how to pass this in clarinet console:
TL;DR:
[optional] on line 169 of uasu-sbtc-loan-v2, probably more logical to print new-status (rather than old): (print { loan-id: loan-id, uuid: (get dlc_uuid loan), status: new-status })
;;
[critical] on line 293 add the following: can only be called by dlc-manager-address (asserts! (is-eq dlc-manager-address contract-caller) err-unauthorised)
[critical] on line 317 of uasu-sbtc-loan-v2 it's the other way around:
(ok (>= loan-amount (/ (* collateral u10000) (get liquidation-ratio loan))))
[unsure] when setup-loan using the same inputs, I sometimes get (err u1001) but unable to see the dlc-manager-v1-1 exact error, and is it because the same uuid cannot be created? @radicleart
- post-close-dlc-handler
this is fine as is. anyone can call it because the user has already closed the loan - see check on status.
therefore on line 317 of uasu-sbtc-loan-v2 it's the other way around:
trying to remove the possiblity of underflow here...
check-liquidation returns true if
(amount borrowed/collateral)*100 >= ratio
Do you agree with this ?
Then multiplying through by collateral
amount borrowed * 100 >= collateral * ratio
no danger of 0 rounding in the divisor. leavng as is in v2.
I'd love to understand where the verification of the btc-tx-id is handled and how? @radicleart
also this function can only be called by the protocol-wallet-address which can be reset by the owner of uasu contract