Vault_Synths.sol code does not consider protocol exchange fee when evaluating the Collateral worth
Vault_Synths.sol code does not consider protocol fee.\\nIf we look into the good-written documentation:\\nI want to quote:\\nBecause the withdrawalFee of a lyra LP pool can vary we must fetch it each time it is needed to ensure we use an accurate value. LP tokens are devalued by this as a safety measure as any liquidation would include selling the collateral and so should factor in that cost to ensure it is profitable.\\nIn Vault_Lyra.sol, when calculating the collateral of the LP token, the fee is taken into consideration.\\n```\\nfunction priceCollateralToUSD(bytes32 _currencyKey, uint256 _amount) public view override returns(uint256){\\n     //The LiquidityPool associated with the LP Token is used for pricing\\n    ILiquidityPoolAvalon LiquidityPool = ILiquidityPoolAvalon(collateralBook.liquidityPoolOf(_currencyKey));\\n    //we have already checked for stale greeks so here we call the basic price function.\\n    uint256 tokenPrice = LiquidityPool.getTokenPrice();          \\n    uint256 withdrawalFee = _getWithdrawalFee(LiquidityPool);\\n    uint256 USDValue  = (_amount * tokenPrice) / LOAN_SCALE;\\n    //we remove the Liquidity Pool withdrawalFee \\n    //as there's no way to remove the LP position without paying this.\\n    uint256 USDValueAfterFee = USDValue * (LOAN_SCALE- withdrawalFee)/LOAN_SCALE;\\n    return(USDValueAfterFee);\\n}\\n```\\n\\nThis is not the case for Vault_Synths.sol, the underlying token also charge exchange fee, but this fee is not reflected when evaluating the Collateral worth.\\nExchange fees are generated whenever a user exchanges one synthetic asset (Synth) for another through Synthetix.Exchange. Fees are typically between 10-100 bps (0.1%-1%), though usually 30 bps, and when generated are sent to the fee pool, where it is available to be claimed proportionally by SNX stakers each week.\\nwe can see that the sETH token charges 0.25%, the sBTC token charges 0.25%, the sUSD charges 0% fee, but this does not ensure this fee rate will not change in the future.
We recommend the project consider protocol exchange fee when evaluating the Collateral worth in Vault_Synths.sol\\nPrecisely when the exchange fee is updated, the fee is reflected in the collateral worth.\\n```\\n    function setExchangeFeeRateForSynths(bytes32[] calldata synthKeys, uint256[] calldata exchangeFeeRates)\\n        external\\n        onlyOwner\\n    {\\n        flexibleStorage().setExchangeFeeRateForSynths(SETTING_EXCHANGE_FEE_RATE, synthKeys, exchangeFeeRates);\\n        for (uint i = 0; i < synthKeys.length; i++) {\\n            emit ExchangeFeeUpdated(synthKeys[i], exchangeFeeRates[i]);\\n        }\\n    }\\n\\n    /// @notice Set exchange dynamic fee threshold constant in decimal ratio\\n    /// @param threshold The exchange dynamic fee threshold\\n    /// @return uint threshold constant\\n    function setExchangeDynamicFeeThreshold(uint threshold) external onlyOwner {\\n        require(threshold != 0, "Threshold cannot be 0");\\n\\n        flexibleStorage().setUIntValue(SETTING_CONTRACT_NAME, SETTING_EXCHANGE_DYNAMIC_FEE_THRESHOLD, threshold);\\n\\n        emit ExchangeDynamicFeeThresholdUpdated(threshold);\\n    }\\n```\\n
The collateral may be overvalued because the exchange does not count when evaluating the Collateral worth and result in bad debt which makes the project insolvent.
```\\nfunction priceCollateralToUSD(bytes32 _currencyKey, uint256 _amount) public view override returns(uint256){\\n     //The LiquidityPool associated with the LP Token is used for pricing\\n    ILiquidityPoolAvalon LiquidityPool = ILiquidityPoolAvalon(collateralBook.liquidityPoolOf(_currencyKey));\\n    //we have already checked for stale greeks so here we call the basic price function.\\n    uint256 tokenPrice = LiquidityPool.getTokenPrice();          \\n    uint256 withdrawalFee = _getWithdrawalFee(LiquidityPool);\\n    uint256 USDValue  = (_amount * tokenPrice) / LOAN_SCALE;\\n    //we remove the Liquidity Pool withdrawalFee \\n    //as there's no way to remove the LP position without paying this.\\n    uint256 USDValueAfterFee = USDValue * (LOAN_SCALE- withdrawalFee)/LOAN_SCALE;\\n    return(USDValueAfterFee);\\n}\\n```\\n