getTargetExternalLendingAmount() targetAmount may far less than the correct value
When calculating `ExternalLending.getTargetExternalLendingAmount()`, it restricts `targetAmount` greater than `oracleData.maxExternalDeposit`. However, it does not take into account that `oracleData.maxExternalDeposit` includes the protocol deposit `currentExternalUnderlyingLend` This may result in the returned quantity being far less than the correct quantity.\\nin `getTargetExternalLendingAmount()` It restricts `targetAmount` greater than `oracleData.maxExternalDeposit`.\\n```\\n    function getTargetExternalLendingAmount(\\n        Token memory underlyingToken,\\n        PrimeCashFactors memory factors,\\n        RebalancingTargetData memory rebalancingTargetData,\\n        OracleData memory oracleData,\\n        PrimeRate memory pr\\n    ) internal pure returns (uint256 targetAmount) {\\n// rest of code\\n\\n        targetAmount = SafeUint256.min(\\n            // totalPrimeCashInUnderlying and totalPrimeDebtInUnderlying are in 8 decimals, convert it to native\\n            // token precision here for accurate comparison. No underflow possible since targetExternalUnderlyingLend\\n            // is floored at zero.\\n            uint256(underlyingToken.convertToExternal(targetExternalUnderlyingLend)),\\n            // maxExternalUnderlyingLend is limit enforced by setting externalWithdrawThreshold\\n            // maxExternalDeposit is limit due to the supply cap on external pools\\n          SafeUint256.min(maxExternalUnderlyingLend, oracleData.maxExternalDeposit)\\n        );\\n```\\n\\nthis is : `targetAmount = min(targetExternalUnderlyingLend, maxExternalUnderlyingLend, oracleData.maxExternalDeposit)`\\nThe problem is that when calculating `oracleData.maxExternalDeposit`, it does not exclude the existing deposit `currentExternalUnderlyingLend` of the current protocol.\\nFor example: `currentExternalUnderlyingLend = 100` `targetExternalUnderlyingLend = 100` `maxExternalUnderlyingLend = 10000` `oracleData.maxExternalDeposit = 0` (All AAVE deposits include the current deposit currentExternalUnderlyingLend)\\nIf according to the current calculation result: `targetAmount=0`, this will result in needing to withdraw `100`. (currentExternalUnderlyingLend - targetAmount)\\nIn fact, only when the calculation result needs to increase the `deposit` (targetAmount > currentExternalUnderlyingLend), it needs to be restricted by `maxExternalDeposit`.\\nThe correct one should be neither deposit nor withdraw, that is, `targetAmount=currentExternalUnderlyingLend = 100`.
Only when `targetAmount > currentExternalUnderlyingLend` is a deposit needed, it should be considered that it cannot exceed `oracleData.maxExternalDeposit`\\n```\\n    function getTargetExternalLendingAmount(\\n        Token memory underlyingToken,\\n        PrimeCashFactors memory factors,\\n        RebalancingTargetData memory rebalancingTargetData,\\n        OracleData memory oracleData,\\n        PrimeRate memory pr\\n    ) internal pure returns (uint256 targetAmount) {\\n// rest of code\\n\\n// Remove the line below\\n        targetAmount = SafeUint256.min(\\n// Remove the line below\\n            // totalPrimeCashInUnderlying and totalPrimeDebtInUnderlying are in 8 decimals, convert it to native\\n// Remove the line below\\n            // token precision here for accurate comparison. No underflow possible since targetExternalUnderlyingLend\\n// Remove the line below\\n            // is floored at zero.\\n// Remove the line below\\n            uint256(underlyingToken.convertToExternal(targetExternalUnderlyingLend)),\\n// Remove the line below\\n            // maxExternalUnderlyingLend is limit enforced by setting externalWithdrawThreshold\\n// Remove the line below\\n            // maxExternalDeposit is limit due to the supply cap on external pools\\n// Remove the line below\\n            SafeUint256.min(maxExternalUnderlyingLend, oracleData.maxExternalDeposit)\\n// Remove the line below\\n        );\\n\\n// Add the line below\\n       targetAmount = SafeUint256.min(uint256(underlyingToken.convertToExternal(targetExternalUnderlyingLend)),maxExternalUnderlyingLend);\\n// Add the line below\\n       if (targetAmount > oracleData.currentExternalUnderlyingLend) { //when deposit ,  must check maxExternalDeposit\\n// Add the line below\\n            uint256 forDeposit = targetAmount // Remove the line below\\n oracleData.currentExternalUnderlyingLend;\\n// Add the line below\\n            if (forDeposit > oracleData.maxExternalDeposit) {\\n// Add the line below\\n                targetAmount = targetAmount.sub(\\n// Add the line below\\n                    forDeposit // Remove the line below\\n oracleData.maxExternalDeposit\\n// Add the line below\\n                );                \\n// Add the line below\\n            }\\n// Add the line below\\n        }\\n```\\n
A too small `targetAmount` will cause the withdrawal of deposits that should not be withdrawn, damaging the interests of the protocol.
```\\n    function getTargetExternalLendingAmount(\\n        Token memory underlyingToken,\\n        PrimeCashFactors memory factors,\\n        RebalancingTargetData memory rebalancingTargetData,\\n        OracleData memory oracleData,\\n        PrimeRate memory pr\\n    ) internal pure returns (uint256 targetAmount) {\\n// rest of code\\n\\n        targetAmount = SafeUint256.min(\\n            // totalPrimeCashInUnderlying and totalPrimeDebtInUnderlying are in 8 decimals, convert it to native\\n            // token precision here for accurate comparison. No underflow possible since targetExternalUnderlyingLend\\n            // is floored at zero.\\n            uint256(underlyingToken.convertToExternal(targetExternalUnderlyingLend)),\\n            // maxExternalUnderlyingLend is limit enforced by setting externalWithdrawThreshold\\n            // maxExternalDeposit is limit due to the supply cap on external pools\\n          SafeUint256.min(maxExternalUnderlyingLend, oracleData.maxExternalDeposit)\\n        );\\n```\\n