The ShortsTracker contract is a specialized component of the Satoshi Perps protocol that tracks global short positions. It maintains an accurate record of short position sizes and average prices, which is essential for funding rate calculations and protocol health monitoring.
function globalShortSizes(address _token) external view returns (uint256);
Returns the total size of all short positions for a token. This function accesses data stored in the Vault contract rather than maintaining a separate copy.
Copy
function globalShortAveragePrices(address _token) external view returns (uint256);
Returns the average entry price of all short positions for a token.
The ShortsTracker implements several security features:
Access Control: Only authorized handlers can update the global short data
Data Validation: Validates that size deltas and prices are reasonable
Global State Management: Provides a centralized source of truth for short position data
Accurate short position tracking is critical for proper funding rate calculations. Inaccuracies could lead to incorrect funding payments between longs and shorts.
The ShortsTracker includes features for data migration and readiness:
Copy
function setIsGlobalShortDataReady(bool _value) external;
This function allows governance to signal when the global short data is ready to be used for calculations. This is particularly useful during protocol upgrades or when recovering from emergency situations.
Copy
function setInitData( address[] memory _tokens, uint256[] memory _averagePrices) external;
This function allows initializing global short data during contract deployment or migration from a previous version.