MEDIUM severity: The `swapUnderlyingForYt` function in the Router is prone to reverting due to rounding issues when c. The `swapUnderlyingForYt` function in the Router is prone to reverting due to rounding issues when calculating the underlying assets to be deposited to issue PT and YT tokens. The function attempts to add a buffer to prevent rounding errors, but this buffer is ineffective in achieving its purpose.\n...

Vulnerable code:
```\nFile: NapierRouter.sol\n\nfunction swapUnderlyingForYt(\n    address pool,\n    uint256 index,\n    uint256 ytOutDesired,\n    uint256 underlyingInMax,\n    address recipient,\n    uint256 deadline\n) external payable override nonReentrant checkDeadline(deadline) returns (uint256) {\n    // Variable Definitions:\n    // - `uDeposit`: The amount of underlying asset that needs to be deposited to issue PT and YT.\n    // - `ytOutDesired`: The desired amount of PT and YT to be issued.\n    // - `cscale`: Current scale of the Tranche.\n    // - `maxscale`: Maximum scale of the Tranche (denoted as 'S' in the formula).\n    // - `issuanceFee`: Issuance fee in basis points. (10000 =100%).\n\n    // Formula for `Tranche.issue`:\n    // shares = uDeposit / s\n    // fee = shares * issuanceFeeBps / 10000\n    // pyIssue = (shares - fee) * S\n\n    // Solving for `uDeposit`:\n    // uDeposit = (pyIssue * s / S) / (1 - issuanceFeeBps / 10000)\n    // Hack:\n    // Buffer is added to the denominator.\n    // This ensures that at least `ytOutDesired` amount of PT and YT are issued.\n    // If maximum scale and current scale are significantly different or `ytOutDesired` is small, the function might fail.\n    // Without this buffer, any rounding errors that reduce the issued PT and YT could lead to an insufficient amount of PT to be repaid to the pool.\n    uint256 uDepositNoFee = cscale * ytOutDesired / maxscale;\n    uDeposit = uDepositNoFee * 10000 / (10000 - (series.issuanceFee + 1)); // 0.01 bps buffer\n```\n```\nuDepositNoFee = cscale * ytOutDesired / maxscale;\nuDepositNoFee = 1.2e18 * 123 / 1.25e18 = 118.08\nuDepositNoFee = 118\n\nuDeposit = uDepositNoFee * MAX_BPS / (MAX_BPS - (series.issuanceFee + 1))\nuDeposit = 118 * 10000 / (10000 - (0 + 1)) = 118.0118012\nuDeposit = 118\n```\n```\nshares = assets * (total_supply / total_assets)\nshares = 118 * (100e18 / 120e18) = 98.33333333 = 98\n```\n```\nissued = (sharesUsed - fee).mulWadDown(_maxscale)\nissued = (sharesUsed - 0).mulWadDown(_maxscale)\nissued = sharesUsed.mulWadDown(_maxscale)\n\nissued = sharesUsed * _maxscale / WAD\n```\n```\nfunction issue(\n    address to,\n    uint256 underlyingAmount\n) external nonReentrant whenNotPaused notExpired returns (uint256 issued) {\n    uint256 sharesUsed = sharesMinted + accruedInTarget;\n    uint256 fee = sharesUsed.mulDivUp(issuanceFeeBps, MAX_BPS);\n    issued = (sharesUsed - fee).mulWadDown(_maxscale);\n}\n```\n```\nFile: NapierRouter.sol\n\nfunction swapCallback(int256 underlyingDelta, int256 ptDelta, bytes calldata data) external override {\n    uint256 pyIssued = params.pt.issue({to: address(this), underlyingAmount: params.underlyingDeposit});\n\n    // Repay the PT to Napier pool\n    if (pyIssued < pyDesired) {\n        revert Errors.RouterInsufficientPtRepay();\n    }\n```