PerpDepository#getPositionValue uses incorrect value for TWAP interval allowing more than intended funds to be extracted
PerpDepository#getPositionValue queries the exchange for the mark price to calculate the unrealized PNL. Mark price is defined as the 15 minute TWAP of the market. The issue is that it uses the 15 second TWAP instead of the 15 minute TWAP\\nAs stated in the docs and as implemented in the ClearHouseConfig contract, the mark price is a 15 minute / 900 second TWAP.\\n```\\nfunction getPositionValue() public view returns (uint256) {\\n    uint256 markPrice = getMarkPriceTwap(15);\\n    int256 positionSize = IAccountBalance(clearingHouse.getAccountBalance())\\n        .getTakerPositionSize(address(this), market);\\n    return markPrice.mulWadUp(_abs(positionSize));\\n}\\n\\nfunction getMarkPriceTwap(uint32 twapInterval)\\n    public\\n    view\\n    returns (uint256)\\n{\\n    IExchange exchange = IExchange(clearingHouse.getExchange());\\n    uint256 markPrice = exchange\\n        .getSqrtMarkTwapX96(market, twapInterval)\\n        .formatSqrtPriceX96ToPriceX96()\\n        .formatX96ToX10_18();\\n    return markPrice;\\n}\\n```\\n\\nAs seen in the code above getPositionValue uses 15 as the TWAP interval. This means it is pulling a 15 second TWAP rather than a 15 minute TWAP as intended.
I recommend pulling pulling the TWAP fresh each time from ClearingHouseConfig, because the TWAP can be changed at anytime. If it is desired to make it a constant then it should at least be changed from 15 to 900.
The mark price and by extension the position value will frequently be different from true mark price of the market allowing for larger rebalances than should be possible.
```\\nfunction getPositionValue() public view returns (uint256) {\\n    uint256 markPrice = getMarkPriceTwap(15);\\n    int256 positionSize = IAccountBalance(clearingHouse.getAccountBalance())\\n        .getTakerPositionSize(address(this), market);\\n    return markPrice.mulWadUp(_abs(positionSize));\\n}\\n\\nfunction getMarkPriceTwap(uint32 twapInterval)\\n    public\\n    view\\n    returns (uint256)\\n{\\n    IExchange exchange = IExchange(clearingHouse.getExchange());\\n    uint256 markPrice = exchange\\n        .getSqrtMarkTwapX96(market, twapInterval)\\n        .formatSqrtPriceX96ToPriceX96()\\n        .formatX96ToX10_18();\\n    return markPrice;\\n}\\n```\\n