I use this formula for calculating borrow rates according to aave docs:
U_new = borrow_amount / supply_aave
if (U_new + U_initial) <= U_kink:
apr = r_base + (U_new + U_initial) * (s1/U_kink)
else:
apr = r_base + s1 + (U_new + U_initial - U_kink)/(1 - U_kink)s2
interest_paid = round(borrow_amount apr, 17)
return interest_paid, apr
But the answer is vastly different than mentioned in the docs. I queried all the variable data from the subgraphs