Reach out for an audit or to learn more about Macro
or Message on Telegram

Polynomial A-7

Security Audit

Oct 3, 2025

Version 1.0.0

Presented by 0xMacro

Table of Contents

Introduction

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.

Overall Assessment

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.

Specification

Our understanding of the specification was based on the following sources:

Source Code

The following source code was reviewed during the audit:

Specifically, we audited the following contracts within this repository.

Source Code SHA256
markets/perps-market/contracts/interfaces/IMarketCloseModule.sol

627b85eb428a0a12ecbe4cd76df4f075eb73fc0c1d34dba21cadeb25e301109f

markets/perps-market/contracts/modules/LimitOrderModule.sol

3e52757af1bfbe6ed8b22def142f1d9a682216d7b3a36ac9ffb840bb7b1447f6

markets/perps-market/contracts/modules/LiquidationModule.sol

179092881e60907fbdb90ed42d1b1a2df16ed115ecb17fd9f9fffbbd069213df

markets/perps-market/contracts/modules/MarketCloseModule.sol

b1151e40518b3772915c7289581484b013d43456b8a17bff507593ccedb0bfa8

markets/perps-market/contracts/modules/MarketConfigurationModule.sol

b04ee7f619c7f072e2c88cf2af23dae296f2a9572ffb5e10a92569f9140133ae

markets/perps-market/contracts/modules/OffchainLimitOrderModule.sol

5d17eff7c642d062bf117bb78cdf6f73093c642c2e2740259aa87d91b9aa906f

markets/perps-market/contracts/modules/PythLazer/OffchainLimitOrderPythLazerModule.sol

5864c6ce51f838a09fa16b917cee963673adc899934cbcd8c7b949edb9111405

markets/perps-market/contracts/storage/AsyncOrder.sol

d596fe427d98f67a80eb74df862f3518353d69c89b611bc82052ce5e8554139b

markets/perps-market/contracts/storage/MarketClose.sol

9f83bee8743cd449fb8f71c0d934f3839a12c7a4e0be966c9cc6073e953794c0

markets/perps-market/contracts/storage/PerpsAccount.sol

01b3fd9163b25e8c20aae672fe3b2866c172988baaa4a9c79c33a0e22f80f7b8

markets/perps-market/contracts/storage/PerpsPrice.sol

09f2de3b69d341f7924bc2008c67c9b2d7b86591b8018004683608d4aaaabc07

markets/perps-market/contracts/storage/Position.sol

97d81e4aef63df64b6d36399aca3ea037195c620ff7d74f46027107003eaaf81

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.

Issue Descriptions and Recommendations

Click on an issue to jump to it, or scroll down to see them all.

Security Level Reference

We quantify issues in three parts:

  1. The high/medium/low/spec-breaking impact of the issue:
    • How bad things can get (for a vulnerability)
    • The significance of an improvement (for a code quality issue)
    • The amount of gas saved (for a gas optimization)
  2. The high/medium/low likelihood of the issue:
    • How likely is the issue to occur (for a vulnerability)
  3. The overall critical/high/medium/low severity of the issue.

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.

Issue Details

C-1

Stale price of closed markets results in breaking core protocol functionality

Topic
Protocol design
Status
Impact
Critical
Likelihood
High

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().

H-1

Not closing markets in time can lock key protocol functionality

Topic
Error Recovery
Status
Impact
Critical
Likelihood
Low

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.

H-2

Wrong pricing tolerance

Topic
pricing
Status
Impact
High
Likelihood
High

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().

M-1

Potentially inconsistent rollover fees

Topic
Inconsistency
Status
Acknowledged
Impact
Medium
Likelihood
Low

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.

Response by Polynomial

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.

I-1

Positions in closed markets cannot be modified until the market is reopened

Topic
Informational
Impact
Informational

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.

Response by 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.

Disclaimer

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.