Price disparities between spot and perpetual pricing can heavily destabilize UXD
When minting UXD using PerpDepository.sol the amount of UXD minted corresponds to the amount of vUSD gained from selling the deposited ETH. This is problematic given that Perp Protocol is a derivative rather than a spot market, which means that price differences cannot be directly arbitraged with spot markets. The result is that derivative markets frequently trade at a price higher or lower than the spot price. The result of this is that UXD is actually pegged to vUSD rather than USD. This key difference can cause huge strain on a USD peg and likely depegging.\\n```\\nfunction deposit(\\n    address asset,\\n    uint256 amount\\n) external onlyController returns (uint256) {\\n    if (asset == assetToken) {\\n        _depositAsset(amount);\\n        (, uint256 quoteAmount) = _openShort(amount);\\n        return quoteAmount; // @audit this mint UXD equivalent to the amount of vUSD gained\\n    } else if (asset == quoteToken) {\\n        return _processQuoteMint(amount);\\n    } else {\\n        revert UnsupportedAsset(asset);\\n    }\\n}\\n```\\n\\nPerpDepository#deposit shorts the deposit amount and returns the amount of vUSD resulting from the swap, which effectively pegs it to vUSD rather than USD. When the perpetual is trading at a premium arbitrage will begin happening between the spot and perpetual asset and the profit will be taken at the expense of the UXD peg.\\nExample: Imagine markets are heavily trending with a spot price of $1500 and a perpetual price of $1530. A user can now buy 1 ETH for $1500 and deposit it to mint 1530 UXD. They can then swap the UXD for 1530 USDC (or other stablecoin) for a profit of $30. The user can continue to do this until either the perpetual price is arbitraged down to $1500 or the price of UXD is $0.98.
I recommend integrating with a chainlink oracle and using its price to determine the true spot price of ETH. When a user mints make sure that the amount minted is never greater than the spot price of ETH which will prevent the negative pressure on the peg:\\n```\\nfunction deposit(\\n    address asset,\\n    uint256 amount\\n) external onlyController returns (uint256) {\\n    if (asset == assetToken) {\\n        _depositAsset(amount);\\n        (, uint256 quoteAmount) = _openShort(amount);\\n\\n+       spotPrice = assetOracle.getPrice();\\n+       assetSpotValue = amount.mulwad(spotPrice);\\n\\n-       return quoteAmount;\\n+       return quoteAmount <= assetSpotValue ? quoteAmount: assetSpotValue;\\n    } else if (asset == quoteToken) {\\n        return _processQuoteMint(amount);\\n    } else {\\n        revert UnsupportedAsset(asset);\\n    }\\n}\\n```\\n
UXD is pegged to vUSD rather than USD which can cause instability and loss of peg
```\\nfunction deposit(\\n    address asset,\\n    uint256 amount\\n) external onlyController returns (uint256) {\\n    if (asset == assetToken) {\\n        _depositAsset(amount);\\n        (, uint256 quoteAmount) = _openShort(amount);\\n        return quoteAmount; // @audit this mint UXD equivalent to the amount of vUSD gained\\n    } else if (asset == quoteToken) {\\n        return _processQuoteMint(amount);\\n    } else {\\n        revert UnsupportedAsset(asset);\\n    }\\n}\\n```\\n