Security Audit
Oct 3, 2025
Version 1.0.0
Presented by 0xMacro
This document includes the results of the security audit for Polynomial's smart contract code as found in the section titled ‘Source Code’. The security audit was performed by the Macro security team on September 24-26th 2025.
The purpose of this audit is to review the source code of certain Polynomial Solidity contracts, and provide feedback on the design, architecture, and quality of the source code with an emphasis on validating the correctness and security of the software in its entirety.
Disclaimer: While Macro’s review is comprehensive and has surfaced some changes that should be made to the source code, this audit should not solely be relied upon for security, as no single audit is guaranteed to catch all possible bugs.
The following is an aggregation of issues found by the Macro Audit team:
| Severity | Count | Acknowledged | Won't Do | Addressed |
|---|---|---|---|---|
| Critical | 1 | - | - | 1 |
| High | 2 | - | - | 2 |
| Medium | 1 | 1 | - | - |
| Informational | 1 | - | - | - |
Polynomial was quick to respond to these issues.
Our understanding of the specification was based on the following sources:
The following source code was reviewed during the audit:
4d7e3512dfcbe3b2d009252f846fd64dc5d3b722
Specifically, we audited the following contracts within this repository.
| Source Code | SHA256 |
|---|---|
| markets/perps-market/contracts/interfaces/IMarketCloseModule.sol |
|
| markets/perps-market/contracts/modules/LimitOrderModule.sol |
|
| markets/perps-market/contracts/modules/LiquidationModule.sol |
|
| markets/perps-market/contracts/modules/MarketCloseModule.sol |
|
| markets/perps-market/contracts/modules/MarketConfigurationModule.sol |
|
| markets/perps-market/contracts/modules/OffchainLimitOrderModule.sol |
|
| markets/perps-market/contracts/modules/PythLazer/OffchainLimitOrderPythLazerModule.sol |
|
| markets/perps-market/contracts/storage/AsyncOrder.sol |
|
| markets/perps-market/contracts/storage/MarketClose.sol |
|
| markets/perps-market/contracts/storage/PerpsAccount.sol |
|
| markets/perps-market/contracts/storage/PerpsPrice.sol |
|
| markets/perps-market/contracts/storage/Position.sol |
|
Note: This document contains an audit solely of the Solidity contracts listed above. Specifically, the audit pertains only to the contracts themselves, and does not pertain to any other programs or scripts, including deployment scripts.
Click on an issue to jump to it, or scroll down to see them all.
We quantify issues in three parts:
This third part – the severity level – is a summary of how much consideration the client should give to fixing the issue. We assign severity according to the table of guidelines below:
| Severity | Description |
|---|---|
|
(C-x) Critical |
We recommend the client must fix the issue, no matter what, because not fixing would mean significant funds/assets WILL be lost. |
|
(H-x) High |
We recommend the client must address the issue, no matter what, because not fixing would be very bad, or some funds/assets will be lost, or the code’s behavior is against the provided spec. |
|
(M-x) Medium |
We recommend the client to seriously consider fixing the issue, as the implications of not fixing the issue are severe enough to impact the project significantly, albiet not in an existential manner. |
|
(L-x) Low |
The risk is small, unlikely, or may not relevant to the project in a meaningful way. Whether or not the project wants to develop a fix is up to the goals and needs of the project. |
|
(Q-x) Code Quality |
The issue identified does not pose any obvious risk, but fixing could improve overall code quality, on-chain composability, developer ergonomics, or even certain aspects of protocol design. |
|
(I-x) Informational |
Warnings and things to keep in mind when operating the protocol. No immediate action required. |
|
(G-x) Gas Optimizations |
The presented optimization suggestion would save an amount of gas significant enough, in our opinion, to be worth the development cost of implementing it. |
This update is intended to allow for markets that use assets outside of crypto, that are not traded and thus priced 24/7, and instead have market operating hours, like US stocks. This results in the oracle no longer updating the price once the markets have closed, resulting in stale data errors when querying the prices normally. In order to allow for important functionality like liquidations of accounts that contain positions in these markets while they are closed, the function getCurrentPricesWithClosedMarkets() is used, where the owner can close markets via closeMarkets() which stores the current price as the price at market close and closes the market. This allows for position value to still be calculated when markets close and allows liquidations to occur. However other important functionality like reportedDebt(), used by the core protocol to determine markets it supports debt, would revert if any market that is closed, locking key functionality for the protocol.
Remediations to Consider
Allow for closed market handling in getCurrentPrices() rather then use custom handling for liquidations via getCurrentPricesWithClosedMarkets().
For the reasons described in C-1, once markets are closed the oracle will no longer update the price and would resulting stale pricing which effects core functionality. closeMarkets() is intended to be called at market close to store the last price and mark as close to allow for custom handling via getCurrentPricesWithClosedMarkets(). However, if for whatever reason the owner does not manage to call to close a market within 60 seconds of the market close price being updated, then they will be prevent from doing so, as it will revert due to the stale closing price. This would then result in the same issues described in C-1, even if resolved as suggested, until the market is able to be opened.
Remediations to Consider
Allow for a market to be closed even if the data is stale to prevent locking the protocol if a market is missed.
getCurrentPricesWithClosedMarkets() is intended to be the same as getCurrentPrices(), with the exception of handling closed markets and use of strict tolerance as it is supposed to be used for liquidations which only use strict price tolerance:
bytes32[] memory runtimeKeys = new bytes32[](0);
// tolerance is STRICT (no runtime keys supplied here; mirrors previous behavior)
NodeOutput.Data[] memory outputs = oracleManager.processManyWithRuntime(
feedIds,
runtimeKeys,
runtimeKeys
);
Reference: PerpsPrice.sol#L118-124
However, it is using the logic for default tolerance, as the logic for anything other than Tolerance.DEFAULT uses non-zero keys and values:
if (priceTolerance != Tolerance.DEFAULT) {
bytes32[] memory sharedRuntimeKeys = new bytes32[](1);
sharedRuntimeKeys[0] = bytes32("stalenessTolerance");
bytes32[][] memory runtimeKeys = new bytes32[][](marketIds.length);
bytes32[][] memory runtimeValues = new bytes32[][](marketIds.length);
for (uint256 i = 0; i < marketIds.length; i++) {
bytes32[] memory newRuntimeValues = new bytes32[](1);
newRuntimeValues[0] = toleranceBytes(load(marketIds[i].to128()), priceTolerance);
runtimeKeys[i] = sharedRuntimeKeys;
runtimeValues[i] = newRuntimeValues;
}
outputs = oracleManager.processManyWithManyRuntime(feedIds, runtimeKeys, runtimeValues);
} else {
bytes32[] memory runtimeKeys = new bytes32[](0);
// do the process call
outputs = oracleManager.processManyWithRuntime(feedIds, runtimeKeys, runtimeKeys);
}
Reference: PerpsPrice#L57-76
This can result in inaccurate pricing for liquidations, and wrong determinations if an account should be liquidated or not.
Remediations to Consider
Use the strict tolerance logic of getCurrentPrice(), or alternatively adjust getCurrentPrice() to handle closed markets and remove getCurrentPricesWithClosedMarkets().
Currently rollover fees are only applied when an account is updated, using the value of the markets rollover fees at the time of update. This is fine if the rollover fee does not change since the last position update, however if it does change potentially to incentivize LPs during high volatility, then the user would be charged the new fee, be it higher or lower than the last, when they next update their position. This leads to potential over or under charging of fees, and inconsistent rewards for LP providers. It could also result in cases where if the rollover fee is increased temporarily, for high volatility, then a user may delay updating their position until the rollover fee is reduced in order to reduce the fees charged to them.
Remediations to Consider
Consider keeping tabs of a cumulative fee rather than just a last updated timestamp, if the account and market each has a cumulative fee of time * current rolloverFee, then after a fee change the new fee would only be applied for time after the update, and not used for the entire time since an account was last updated, resulting in accurate fees. Additionally, you could consider adding a public method that allows charging fees owed by an account, since fees to the protocol are only applied on update which could never occur. Allowing for inactive accounts with large fees to be collected.
rolloverFee is operated as static for now and we do not expect changes soon. Interim: We will not modify rolloverFee until the cumulative accounting fix is live. If an urgent change is required, we will announce the effective block in advance. Planned fix: Add a cumulative rolloverFeeIndex with per-account lastIndex, and a keeper method to charge inactive accounts. Targeted for the next upgrade window.
The intended behaviour of handling closed markets is that positions cannot be modified while they are closed, acting similarly to traditional stock markets the underlying assets are traded on. This is to prevent trading on information that would effect price but is not tracked by the oracle, leading to an unfair edge. Although this behaviour is not explicitly handled, when querying the price of the asset will revert due to stale data, preventing updating the position as intended.
Users should be aware that these positions are limited to the hours of the traditional markets they are traded on, unlike other markets on polynomial.
This is intended. During off-market hours the oracle is stale. The app will display data based on the last official close price and clearly indicate “Market closed.” Users cannot modify positions during this period. Planned: Add explicit market-hours checks with clear errors and a read API for next open and close times.
Macro makes no warranties, either express, implied, statutory, or otherwise, with respect to the services or deliverables provided in this report, and Macro specifically disclaims all implied warranties of merchantability, fitness for a particular purpose, noninfringement and those arising from a course of dealing, usage or trade with respect thereto, and all such warranties are hereby excluded to the fullest extent permitted by law.
Macro will not be liable for any lost profits, business, contracts, revenue, goodwill, production, anticipated savings, loss of data, or costs of procurement of substitute goods or services or for any claim or demand by any other party. In no event will Macro be liable for consequential, incidental, special, indirect, or exemplary damages arising out of this agreement or any work statement, however caused and (to the fullest extent permitted by law) under any theory of liability (including negligence), even if Macro has been advised of the possibility of such damages.
The scope of this report and review is limited to a review of only the code presented by the Polynomial team and only the source code Macro notes as being within the scope of Macro’s review within this report. This report does not include an audit of the deployment scripts used to deploy the Solidity contracts in the repository corresponding to this audit. Specifically, for the avoidance of doubt, this report does not constitute investment advice, is not intended to be relied upon as investment advice, is not an endorsement of this project or team, and it is not a guarantee as to the absolute security of the project. In this report you may through hypertext or other computer links, gain access to websites operated by persons other than Macro. Such hyperlinks are provided for your reference and convenience only, and are the exclusive responsibility of such websites’ owners. You agree that Macro is not responsible for the content or operation of such websites, and that Macro shall have no liability to your or any other person or entity for the use of third party websites. Macro assumes no responsibility for the use of third party software and shall have no liability whatsoever to any person or entity for the accuracy or completeness of any outcome generated by such software.