AuraSpell openPositionFarm does not join pool
The function to open a position for the AuraSpell does not join the pool due to wrong conditional check.\\nThe function deposits collateral into the bank, borrow tokens, and attempts to join the pool:\\n```\\n    function openPositionFarm(\\n        OpenPosParam calldata param\\n    )\\n        external\\n        existingStrategy(param.strategyId)\\n        existingCollateral(param.strategyId, param.collToken)\\n    {\\n        // rest of code\\n        // 1. Deposit isolated collaterals on Blueberry Money Market\\n        _doLend(param.collToken, param.collAmount);\\n\\n        // 2. Borrow specific amounts\\n        uint256 borrowBalance = _doBorrow(\\n            param.borrowToken,\\n            param.borrowAmount\\n        );\\n\\n        // 3. Add liquidity on Balancer, get BPT\\n        {\\n            IBalancerVault vault = wAuraPools.getVault(lpToken);\\n            _ensureApprove(param.borrowToken, address(vault), borrowBalance);\\n\\n            (address[] memory tokens, uint256[] memory balances, ) = wAuraPools\\n                .getPoolTokens(lpToken);\\n            uint[] memory maxAmountsIn = new uint[](2);\\n            maxAmountsIn[0] = IERC20(tokens[0]).balanceOf(address(this));\\n            maxAmountsIn[1] = IERC20(tokens[1]).balanceOf(address(this));\\n\\n            uint totalLPSupply = IBalancerPool(lpToken).totalSupply();\\n            // compute in reverse order of how Balancer's `joinPool` computes tokenAmountIn\\n            uint poolAmountFromA = (maxAmountsIn[0] * totalLPSupply) /\\n                balances[0];\\n            uint poolAmountFromB = (maxAmountsIn[1] * totalLPSupply) /\\n                balances[1];\\n            uint poolAmountOut = poolAmountFromA > poolAmountFromB\\n                ? poolAmountFromB\\n                : poolAmountFromA;\\n\\n            bytes32 poolId = bytes32(param.farmingPoolId);\\n            if (poolAmountOut > 0) {\\n                vault.joinPool(\\n                    poolId,\\n                    address(this),\\n                    address(this),\\n                    IBalancerVault.JoinPoolRequest(\\n                        tokens,\\n                        maxAmountsIn,\\n                        "",\\n                        false\\n                    )\\n                );\\n            }\\n        }\\n        // rest of code\\n    }\\n```\\n\\nThe function only borrowed one type of tokens from the bank so the contract only owns one type of token. As a result one of the `maxAmountsIn` value is 0. Either `poolAmountFromA` or `poolAmountFromB` is 0 as a result of computation. `poolAmountOut` is the minimal value of `poolAmountFromA` and `poolAmountFromB`, it is 0. The following check `if (poolAmountOut > 0)` will always fail and the pool will never be joined.
It is hard to tell the intent of the developer from this check. Maybe the issue is simply that `poolAmountOut` should be the sum or the max value out of `poolAmountFromA` and `poolAmountFromB` instead of the min.
The rest of the function proceeds correctly without reverting. Users will think they joined the pool and are earning reward while they are not earning anything. This is a loss of funds to the user.
```\\n    function openPositionFarm(\\n        OpenPosParam calldata param\\n    )\\n        external\\n        existingStrategy(param.strategyId)\\n        existingCollateral(param.strategyId, param.collToken)\\n    {\\n        // rest of code\\n        // 1. Deposit isolated collaterals on Blueberry Money Market\\n        _doLend(param.collToken, param.collAmount);\\n\\n        // 2. Borrow specific amounts\\n        uint256 borrowBalance = _doBorrow(\\n            param.borrowToken,\\n            param.borrowAmount\\n        );\\n\\n        // 3. Add liquidity on Balancer, get BPT\\n        {\\n            IBalancerVault vault = wAuraPools.getVault(lpToken);\\n            _ensureApprove(param.borrowToken, address(vault), borrowBalance);\\n\\n            (address[] memory tokens, uint256[] memory balances, ) = wAuraPools\\n                .getPoolTokens(lpToken);\\n            uint[] memory maxAmountsIn = new uint[](2);\\n            maxAmountsIn[0] = IERC20(tokens[0]).balanceOf(address(this));\\n            maxAmountsIn[1] = IERC20(tokens[1]).balanceOf(address(this));\\n\\n            uint totalLPSupply = IBalancerPool(lpToken).totalSupply();\\n            // compute in reverse order of how Balancer's `joinPool` computes tokenAmountIn\\n            uint poolAmountFromA = (maxAmountsIn[0] * totalLPSupply) /\\n                balances[0];\\n            uint poolAmountFromB = (maxAmountsIn[1] * totalLPSupply) /\\n                balances[1];\\n            uint poolAmountOut = poolAmountFromA > poolAmountFromB\\n                ? poolAmountFromB\\n                : poolAmountFromA;\\n\\n            bytes32 poolId = bytes32(param.farmingPoolId);\\n            if (poolAmountOut > 0) {\\n                vault.joinPool(\\n                    poolId,\\n                    address(this),\\n                    address(this),\\n                    IBalancerVault.JoinPoolRequest(\\n                        tokens,\\n                        maxAmountsIn,\\n                        "",\\n                        false\\n                    )\\n                );\\n            }\\n        }\\n        // rest of code\\n    }\\n```\\n