To be able to understand the issue, we need to know that the collateral amount on the Synthetix is updated via the _settleOrder or modifyCollateral

However, if we speak about PNL, it is updated only in the _settleOrder, so, to "grap" and actually add our PNL into the collateral amount, we need to commit-settle first, and only then it will be added into the collateral amount of the account.

But what we do in the redeem and why it is an issue?

To calculate how much funds user can redeem, the _valueToRedeem is called.

function _valueToRedeem(
        uint256 shares
    ) internal view returns (uint256 valueToRedeem) {
        uint256 share = shares.div(totalSupply()); //This calculates what percentage of the total supply the user's shares represent
        uint256 assetsShare = totalAssets().mul(share); //This multiplies the total assets in the vault by the share percentage to determine how much of the assets the user is entitled to
        return assetsShare.fromDecimals(_USDC_DECIMALS); //convert it into the 1e18 decimals
    }

We see that it uses the totalAssets, however, the totalAssets includes the PNL already!

So, what we have? We haven’t officially settled the PNL into our account on Synthetix, however, we already account it during calculation.

Consequently, it will make the funds to redeem higher that in actually exists as the collateral

Secondly, during the modifyCollateral in the _removeMargin function, we work with actual collateral token amounts, not with the sUSD, which the PNL is.

So, when we try to remove margin, we’re removing actual collateral tokens, not the PnL value

Here is what can happens: