UD60x18 is unsigned interger in prb math newCreditDelegationUsdX18 is credit given to market and previousCreditDelegationUsdX18 is previously provided credit to the market both are UD60x18 means unsigned interger. Protocol assumes that newCreditDelegationUsdX18 is always bigger than previous one so it will give runtime error panic code 11 which disturbs the normal flow of the code.
function _updateCreditDelegation will be called in function recalculateCreditCapacity() . to update the vualt's credit delegation so here it may possible that new credit delegated will be less than the previous one. Without type casting to signed interger credit delta is calculated leads to panic error.
newCreditDelegation depend on factor total index assets weight and totalCreditDelegationWeight and previousCreditDelegation based on values of credit in usd ,so this may be possible that new credit delegation is less than previous one.
This below code is PRB library func of two UD60x18
POC
Runtime error which disturbs the normal flow of execution.
Manual View
Add check before subtract
Type Cast before the subtract
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.