Uasu-Finance / uasu-clar

0 stars 0 forks source link

set-status-funded doesn-t verify btc-tx-id in the clarity code (uasu / dlc-manager) #9

Open Rapha-btc opened 9 months ago

Rapha-btc commented 9 months ago

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

Rapha-btc commented 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

Rapha-btc commented 9 months ago
Rapha-btc commented 9 months ago

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

Rapha-btc commented 9 months ago
Rapha-btc commented 9 months ago

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:

image

radicleart commented 9 months ago
  • 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.

radicleart commented 9 months ago

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.