Pool's Best Leverage

The pool's best leverage is calculated by borrowing each token to the maximum borrowing amount and check that which one gives the best APY, then use that leverage as the pool's max leverage. *Please note that the pool best leverage showing in the Homora V2's UI aren't always the pool max leverage because in some situation, the borrow APY is quite high from high utilization of the lending pool so the UI won't suggest that leverage.
tokenMaxLeverage or the max leverage of each borrowing token is calculated as:
tokenMaxLeverage = borrowFactor / (borrowFactor - (collateralFactor * cappedDebtRatio))
Note: Default cappedDebtRatio is set to 0.95
Read more about collateral and borrow credit here
The total APY of that tokenMaxLeverage is calculated as:
totalAPY = ((farmingAPR + tradingFeeAPY) * tokenMaxLeverage) + (totalRewardAPY * (tokenMaxLeverage - 1)) - (tokenBorrowApy * (tokenMaxLeverage - 1))
*The rewardAPY and borrowAPY is multiplied by (maxLeverage-1) because the interest only happens when the leverage is >1
Then compared totalAPY of each borrowing token (also with the totalAPY if has no leverage) to see which one gives the best APY.