MEDIUM severity: `PrincipalShareDeposited` is being increased without actual transfer/minting of shares. **Severity**: Medium

**Status**: Resolved

**Description**

In Contract Tranche.sol, the method _withdraw(...) has the following logic:

Here, when receiver != owner, the mapping principalShareDeposited and principalAssetsDeposited are being increased for the receiver address after the shares of...

Vulnerable code:
function _withdraw(
       address caller,
       address receiver,
       address owner,
       uint256 assets,
       uint256 shares
   ) internal virtual override {
     . . .
       super._withdraw(caller, receiver, owner, assets, shares);


       if (fee > 0) {
           SafeERC20.safeTransfer(ERC20(asset()), address(vaultManager), fee);
           vaultManager.allocateRewards(fee);
       }


       // use original asset / share ratio and subject the relative asset amount
       if (receiver != owner) {
           _updateNegativePrincipal(owner, shares);


           // gifts are treated as deposits
           principalAssetsDeposited[receiver] += (assets - fee) * _PRECISION;
           totalPrincipalDeposited += (assets - fee) * _PRECISION;
           principalSharesDeposited[receiver] += shares;
       } else if (principalSharesDeposited[receiver] > 0) {
           _updateNegativePrincipal(receiver, shares);
       }
   }

function testReedem() public {
       uint rand = uint(keccak256(abi.encodePacked(block.timestamp))) %
           numTraders;
       address ownerTrader = traders[rand];
       vm.startPrank(ownerTrader);
       uint amount = usdc.balanceOf(ownerTrader);
       usdc.approve(address(juniorTranche), amount);


       emit log_named_uint("usdc amount deposited", amount);
       juniorTranche.deposit(amount, ownerTrader);


       emit log_named_uint(
           "minted shares",
           juniorTranche.balanceOf(ownerTrader)
       );


       address receiverTrader = makeAddr("receiver");
       uint redeemB = juniorTranche.redeem(
           juniorTranche.balanceOf(ownerTrader),
           receiverTrader,
           ownerTrader
       );


       emit log_named_uint("redeem return assets", redeemB);


       emit log_named_uint(
           "usdc balance after redeem for owner",
           usdc.balanceOf(ownerTrader)
       );


       emit log_named_uint(
           "lp shares for owner",
           juniorTranche.balanceOf(ownerTrader)
       );


       emit log_named_uint(
           "asset deposited  for owner",
           juniorTranche.principalAssetsDeposited((ownerTrader))
       );


       emit log_named_uint(
           "shares deposited for owner",
           juniorTranche.principalSharesDeposited((ownerTrader))
       );


       emit log_named_uint(
           "usdc balance after redeem for receiver",
           usdc.balanceOf(receiverTrader)
       );


       emit log_named_uint(
           "lp shares for receiver",
           (juniorTranche.balanceOf(receiverTrader))
       );


       emit log_named_uint(
           "asset deposited  for receiver",
           juniorTranche.principalAssetsDeposited((receiverTrader))
       );


       emit log_named_uint(
           "shares deposited for receiver",
           juniorTranche.principalSharesDeposited((receiverTrader))
       );


       }