```\nfunction deposit(\n  address asset,\n  uint256 amount,\n  address onBehalfOf,\n  uint16 referralCode\n) external override {\n  \_whenNotPaused();\n  ReserveLogic.ReserveData storage reserve = \_reserves[asset];\n\n  ValidationLogic.validateDeposit(reserve, amount);\n\n  address aToken = reserve.aTokenAddress;\n\n  reserve.updateState();\n  reserve.updateInterestRates(asset, aToken, amount, 0);\n\n  bool isFirstDeposit = IAToken(aToken).balanceOf(onBehalfOf) == 0;\n  if (isFirstDeposit) {\n    \_usersConfig[onBehalfOf].setUsingAsCollateral(reserve.id, true);\n  }\n\n  IAToken(aToken).mint(onBehalfOf, amount, reserve.liquidityIndex);\n\n  //transfer to the aToken contract\n  IERC20(asset).safeTransferFrom(msg.sender, aToken, amount);\n\n  emit Deposit(asset, msg.sender, onBehalfOf, amount, referralCode);\n}\n```\n