Depositing to the GMX POOl will return sub-optimal return if the Pool is imbalanced
Whenever A user deposits tokens to vault, vault create a leverage position depending[delta or delta neutral] in the GMX POOl. performing a proportional deposit is not optimal in every case and depositng tokens in such case will result in fewer LP tokens due to sub optimal trade. Eventually leading to a loss of gain for the strategy vault\\nAlice deposits token A() into the vault to make Delta.Neutral position\\n```\\nFile: GMXVault.sol\\n\\n  function deposit(GMXTypes.DepositParams memory dp) external payable nonReentrant {\\n    GMXDeposit.deposit(_store, dp, false);\\n  }\\n```\\n\\nvault refer to deposit to GMXDeposit library to execute the further logic\\n```\\nFile: GMXDeposit.sol\\n\\n  function deposit(\\n    GMXTypes.Store storage self,\\n    GMXTypes.DepositParams memory dp,\\n    bool isNative\\n  ) external {\\n[// rest of code// rest of code// rest of code// rest of code// rest of code.]\\n    // Borrow assets and create deposit in GMX\\n    (\\n      uint256 _borrowTokenAAmt,\\n      uint256 _borrowTokenBAmt\\n    ) = GMXManager.calcBorrow(self, _dc.depositValue);\\n\\n    [// rest of code// rest of code// rest of code]\\n  }\\n```\\n\\nhttps://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/strategy/gmx/GMXDeposit.sol#L54\\nwhich calls calcBorrow on GMXManager Library for borrowing assets and making the position IN GMX POOL\\n```\\nFile: GMXManager.sol\\n\\n  /**\\n    * @notice Calculate amount of tokenA and tokenB to borrow\\n    * @param self GMXTypes.Store\\n    * @param depositValue USD value in 1e18\\n  */\\n  function calcBorrow(\\n    GMXTypes.Store storage self,\\n    uint256 depositValue\\n  ) external view returns (uint256, uint256) {\\n    // Calculate final position value based on deposit value\\n    uint256 _positionValue = depositValue * self.leverage / SAFE_MULTIPLIER;\\n\\n    // Obtain the value to borrow\\n    uint256 _borrowValue = _positionValue - depositValue;\\n\\n    uint256 _tokenADecimals = IERC20Metadata(address(self.tokenA)).decimals();\\n    uint256 _tokenBDecimals = IERC20Metadata(address(self.tokenB)).decimals();\\n    uint256 _borrowLongTokenAmt;\\n    uint256 _borrowShortTokenAmt;\\n\\n [// rest of code// rest of code// rest of code// rest of code// rest of code// rest of code..]\\n\\n    // If delta is neutral, borrow appropriate amount in long token to hedge, and the rest in short token\\n    if (self.delta == GMXTypes.Delta.Neutral) {\\n      // Get token weights in LP, e.g. 50% = 5e17\\n      (uint256 _tokenAWeight,) = GMXReader.tokenWeights(self);\\n\\n      // Get value of long token (typically tokenA)\\n      uint256 _longTokenWeightedValue = _tokenAWeight * _positionValue / SAFE_MULTIPLIER;\\n\\n      // Borrow appropriate amount in long token to hedge\\n      _borrowLongTokenAmt = _longTokenWeightedValue * SAFE_MULTIPLIER\\n                            / GMXReader.convertToUsdValue(self, address(self.tokenA), 10**(_tokenADecimals))\\n                            / (10 ** (18 - _tokenADecimals));\\n\\n      // Borrow the shortfall value in short token\\n      _borrowShortTokenAmt = (_borrowValue - _longTokenWeightedValue) * SAFE_MULTIPLIER\\n                             / GMXReader.convertToUsdValue(self, address(self.tokenB), 10**(_tokenBDecimals))\\n                             / (10 ** (18 - _tokenBDecimals));\\n    }\\n[// rest of code// rest of code// rest of code// rest of code// rest of code// rest of code// rest of code]\\n  }\\n```\\n\\nhttps://github.com/Cyfrin/2023-10-SteadeFi/blob/main/contracts/strategy/gmx/GMXManager.sol#L70\\nHere it consider the current reserve ratio of the pool and deposits in the same ratio.\\nWhile GMX docs clearly state that If deposits try to create balance in the pool[depositing in such way which will make actual token weight of index Token towards the TOKEN_WEIGHT defined in the pool] will get benefit technically more LP tokens and oppose to this less LP token if current deposits imbalance the Pool reserve the ratio Reference\\nEven Curve pools work in the same way. Depositer get benefit if they try to balance the pool reserve making them optimal
Depositing to the GMX POOl will return sub-optimal return if the Pool is imbalanced\\nconsider implementing check and if the pool is imablanced depositing(making levearge position) towards balancing the Index Token's weight will give optimal returns[extra LP tokens ]
It is clear that Weight of index token will not be always near equal to the Defined Total_Weight of the Pool. So if the pool is imbalanced Depositing into GMXPool will not give optimal returns( resulting in fewer LP token), eventually leading to the loss of gain for the depositers affecting net APR
```\\nFile: GMXVault.sol\\n\\n  function deposit(GMXTypes.DepositParams memory dp) external payable nonReentrant {\\n    GMXDeposit.deposit(_store, dp, false);\\n  }\\n```\\n