Skip to content
We manage your security to weather the AI storm →

Security review · September 2025

Token OFT Adapter for GMX

Guardian's review of Token OFT Adapter for GMX, published September 2025. The report records 9 findings across 2 review rounds, including 6 medium and 3 informational.

See how Guardian runs a perp DEX smart contract audit.

Published
Review window
August 14 to September 18, 2025
Rounds
Main Review, Remediation Review
Language
Solidity
Chains
Arbitrum
  • 0 Critical
  • 0 High
  • 6 Medium
  • 0 Low
  • 3 Informational

6 resolved · 3 acknowledged

Scope

2 files in scope · 124 nSLOC
FilenSLOCLines
contracts/GMX_Adapter.sol52116
layerzero.config.ts7289

Findings 9

Main Review

7 findings · August 14 to 18, 2025
  1. M-01 Medium Incorrect Enforced Options In layerzero.config.ts File Configuration Resolved
    Location
    layerzero.config.ts
    Round
    Main Review

    Description

    In layerzero.config.ts the enforcedOptions tuple for some connections does not match the target chain type. The 5th element that generateConnectionsConfig([...]) expects (per your sample) is ordered as:

    [ /* Chain B enforcedOptions */, /* Chain A enforcedOptions */ ]
    

    However, the current file mixes up Solana/EVM option sets and also uses a misleading comment (“Chain A enforcedOptions, Chain B enforcedOptions”), causing EVM chains to receive SOLANA_ENFORCED_OPTIONS and/or Solana to receive EVM_ENFORCED_OPTIONS. This miswiring makes the executor run with the wrong units (EVM: gas/wei vs. Solana: compute units/lamports), leading to under‑provisioned execution, reverts, or stuck messages. Examples (current vs. fixed) Arbitrum (A, EVM) ↔ Avalanche (B, EVM) — must be EVM on both sides. Current (wrong — A gets Solana options):

    [EVM_ENFORCED_OPTIONS, SOLANA_ENFORCED_OPTIONS]
    

    Fixed (both sides EVM):

    [EVM_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS]
    

    Solana (A) ↔ Arbitrum (B, EVM) — B must get EVM, A must get Solana. Current (wrong — B gets Solana, A gets EVM):

    [SOLANA_ENFORCED_OPTIONS, EVM_ENFORCED_OPTIONS]
    

    Fixed (match sample order [B, A]):

    [EVM_ENFORCED_OPTIONS, SOLANA_ENFORCED_OPTIONS]
    

    Solana (A) ↔ Avalanche (B, EVM) — already correct if using [B, A] order:

    [ EVM_ENFORCED_OPTIONS, SOLANA_ENFORCED_OPTIONS ]
    

    Reference: https://docs.layerzero.network/v2/developers/evm/technical-reference/simple-config

    Recommendation

    Correct the tuples to match the sample’s order [Chain B, Chain A] and to use Solana options for Solana and EVM options for EVM.

  2. M-02 Medium SOLANA_V2_TESTNET Instead Of SOLANA_V2_MAINNET Configuration Resolved
    Location
    layerzero.config.ts
    Round
    Main Review

    Description

    In layerzero.config.ts the Solana contract entry is wired to testnet while the EVM peers are on mainnet. This mixes environments inside the same connection matrix and will cause wiring failures, message delivery errors, or accidental testnet minting when operating from mainnet.

    Recommendation

    Point Solana to mainnet and load the mainnet OFT Store address:

    const solanaContract: OmniPointHardhat = {
      eid: EndpointId.SOLANA_V2_MAINNET, // ✅ mainnet EID
      address: getOftStoreAddress(EndpointId.SOLANA_V2_MAINNET), // ✅ mainnet OFT Store
    }
    
  3. M-03 Medium Non‑normalized Send Accounting Inflate Rate‑limit Rounding Resolved
    Location
    GMX_Adapter.sol
    Round
    Main Review

    Description

    The adapter counts inbound and outbound volume using different units/rounding. On receive, the limiter charges the normalized amount in local denomination (LD) derived from the packet’s shared‑decimals (SD) payload:

    super._outflow(_origin.srcEid, _toLD(_message.amountSD()));
    

    but on send it credits the limiter with the raw _amountLD:

    super._inflow(_dstEid, _amountLD);
    

    In OFT, packets carry amounts in SD. Conversions are:

    _toSD(_amountLD) = floor(_amountLD / 10^(LD−SD))
    _toLD(_amountSD) = _amountSD * 10^(LD−SD)
    

    Every inbound charge is therefore an exact multiple of the conversion rate, while outbound credits can include a remainder (“dust”) < 10^(LD−SD). For example, with LD=18, SD=8, cv=10^10: sending _amountLD = cv + (cv−1) = 19,999,999,999 transmits only 1 SD, yet the limiter credits 19,999,999,999 on send but charges only 10,000,000,000 per matching receive. Repeating this with high‑dust amounts accumulates extra headroom inside the window, allowing more inbound packets than intended under a net‑flow limiter.

    Recommendation

    Normalize send‑side accounting to the same basis used on receive so both directions use identical units and rounding:

    super._inflow(_dstEid, _toLD(_toSD(_amountLD)));
    
  4. M-04 Medium Unsafe Layer Zero Configuration Configuration Resolved
    Location
    layerzero.config.ts
    Round
    Main Review

    Description

    The current confirmation settings defined in the layerzero.config.ts file for Solana - Arbitrum are 32 for sending and 20 for receiving: [32, 20], // [A to B confirmations, B to A confirmations]. Given the default values used by LayerZero, defined here https://layerzeroscan.com/tools/defaults?version=V2, this is correct: (Figure. See the PDF report.) However for Solana - Avalanche, sending confirmations are set to 10 for sending and 12 for receiving: [10, 12], // [A to B confirmations, B to A confirmations] The recommended defaults by LayerZero are 32 for sending and 12 for receiving: (Figure. See the PDF report.) Finally, for Arbitrum - Avalanche, sending confirmations are set to 20 while receiving confirmations are set to 12. These are exactly the recommended default values by LayerZero.

    Recommendation

    Update the Solana - Avalanche configuration and use the LayerZero default values: 32 confirmations for sending and 12 for receiving.

  5. M-05 Medium Asymmetric Capacity Accounting Configuration Resolved
    Location
    GMX_Adapter.sol
    Round
    Main Review

    Description

    GMX_Adapter._debit reduces the rate‑limiter’s in‑flight amount on send unconditionally, even if the _from address is part of the exemptAddresses:

    super._inflow(_dstEid, _amountLD);
    

    while _lzReceive skips increasing in‑flight for exempt recipients (and overridable GUIDs):

    if (!exemptAddresses[toAddress] && !guidOverrides[_guid]) {
        super._outflow(_origin.srcEid, _toLD(_message.amountSD()));
    }
    

    This breaks symmetry. Any transfer whose destination toAddress is exempt will not add to in‑flight on receive, yet it does decrease in‑flight on send. While it makes sense to not apply the rate limit on certain addresses when they receive tokens, these same addresses should, at the same time, not decrease the rate limit when they send tokens.

    Recommendation

    Consider updating the _debit function to not call super._inflow when the _from address is part of the exemptAddresses mapping in the destination chain.

  6. I-01 Informational Rate Limits Are Not Applied Correctly Validation Acknowledged
    Location
    RateLimiter.sol
    Round
    Main Review

    Description

    The _inflow() function is designed to reduce the amountInFlight by the _amount passed to it (inflowAmount), with a lower bound of zero:

    function _inflow(uint32 _srcEid, uint256 _amount) internal virtual {
        RateLimit storage rl = rateLimits[_srcEid];
        rl.amountInFlight = _amount >= rl.amountInFlight ? 0 : rl.amountInFlight - _amount;
    }
    

    However, let's imagine the following two scenarios:

    • RateLimiter.RateLimitConfig(1337, 1000, 100);
    Scenario 1

    <table header-row="true"> <tr> <td>Step</td> <td>Action</td> <td>amountInFlight</td> <td>amountCanBeSent</td> </tr> <tr> <td>0</td> <td>Initial State</td> <td>0</td> <td>1000</td> </tr> <tr> <td>1</td> <td>outflow(500)</td> <td>500</td> <td>500</td> </tr> <tr> <td>2</td> <td>inflow(1000)</td> <td>0</td> <td>1000</td> </tr> <tr> <td>3</td> <td>outflow(500)</td> <td>500</td> <td>500</td> </tr> </table>

    Scenario 2

    <table header-row="true"> <tr> <td>Step</td> <td>Action</td> <td>amountInFlight</td> <td>amountCanBeSent</td> </tr> <tr> <td>0</td> <td>Initial State</td> <td>0</td> <td>1000</td> </tr> <tr> <td>1</td> <td>outflow(500)</td> <td>500</td> <td>500</td> </tr> <tr> <td>2</td> <td>outflow(500)</td> <td>1000</td> <td>0</td> </tr> <tr> <td>3</td> <td>inflow(1000)</td> <td>0</td> <td>1000</td> </tr> </table> Despite both scenarios involving a total of 1000 units of outflow and 1000 units of inflow processed in the same timestamp, the remaining rate limit differs based on the order of operations. This inconsistency proves that the rate limiter behaves differently when the sequence of inflow and outflow operations changes, even though the net effect is the same. Users performing the same net actions will experience different rate limits based solely on the sequence of their operations. Moreover, it is expected that users will deliberately arrange operations to maximize their rate limits. A rate limiter should apply limits consistently, regardless of the order of operations, as long as the net effect is the same.

    Recommendation

    Instead of simply setting to 0 the rl.amountInFlight when _amount >= rl.amountInFlight consider declaring rl.amountInFlight as an int256. This allows the rate limiter to accurately track the net balance of inflows and outflows, ensuring that the rate limit is applied consistently regardless of the order of operations. By allowing amountInFlight to become negative, it is possible to account for scenarios where inflows exceed outflows within the rate limiting window. This approach ensures that the remaining rate limit (amountCanBeSent) reflects the true net activity over time, eliminating discrepancies caused by the sequence of inflow and outflow operations.

  7. I-02 Informational Inbound Rate Limit Is Effectively “Net‑Flow” Warning Acknowledged
    Location
    GMX_Adapter.sol
    Round
    Main Review

    Description

    GMX_Adapter tries to enforce an inbound throttle by swapping LayerZero’s rate‑limiter calls:

    // On SEND (outbound)
    function _debit(...) internal override returns (...) {
        super._inflow(_dstEid, _amountLD); // returns capacity
        return super._debit(_from, _amountLD, _minAmountLD, _dstEid);
    }
    
    // On RECEIVE (inbound)
    function _lzReceive(Origin calldata _origin, bytes32 _guid, bytes calldata _message, ...)
        internal override
    {
        address toAddress = _message.sendTo().bytes32ToAddress();
        if (!exemptAddresses[toAddress] && !guidOverrides[_guid]) {
            super._outflow(_origin.srcEid, _toLD(_message.amountSD())); // consumes capacity
        }
        super._lzReceive(_origin, _guid, _message, _executor, _extraData);
    }
    

    LayerZero’s limiter uses a single bucket per EID (amountInFlight). _outflow(amount) increases the bucket. _inflow(amount) decreases it but floors at zero (returns headroom). Because the adapter calls _inflow on sends and _outflow on receives, the bucket measures net = inbound − outbound within the window, not inbound alone. As a consequence an actor can alternate receive→send→receive to keep the bucket ≤ limit while pulling in more than the intended inbound cap. Concrete example (window limit L = 1000 from chain A; start bucket = 0):

    1. Receive 1000 from A → _outflow(+1000) → bucket = 1000
    2. Send 1000 to A → _inflow(−1000) floors to 0 → bucket = 0
    3. Receive 1000 from A → bucket = 1000
    4. Send 1000 to A → bucket = 0
    5. Receive 1000 from A → bucket = 1000 Within one window, the adapter received 3000, yet the bucket never exceeded 1000. This defeats an “inbound‑only” throttle: total inbound allowed becomes L + outbound_in_same_window.
    • If your policy goal is “throttle inbound mint/credit pressure regardless of outbound”, the current scheme fails: an actor can exceed the inbound cap as long as they also send roughly the same amount back out during the window.
    • If your policy goal is “limit net bandwidth”, then the behavior is expected, but then it’s not an “inbound cap.”

    Recommendation

    Enforce a true inbound‑only limit by not returning capacity on outbound sends. In practice, remove the _inflow call from _debit and keep the _outflow on _lzReceive only. This uses the limiter as an inbound‑only bucket per srcEid.

Remediation Review

2 findings · September 18, 2025
  1. M-01 Medium amountReceivedLD Burnt Instead Of amountSentLD Logical Error Resolved
    Location
    GMX_MintBurnAdapter.sol
    Round
    Remediation Review

    Description

    The GMX_MintBurnAdapter’s _debit implementation burns amountReceivedLD even though the OFT core deliberately splits _debitView’s output into two values: amountSentLD (the amount actually deducted on the source chain) and amountReceivedLD (the post-adjustment amount that should be minted/unlocked on the destination). Right now _debitView returns identical numbers for both slots, but the API is designed so custom adapters can diverge them, for example to apply protocol fees, handle fee-on-transfer tokens, tweak dust rounding, or refund rate-limit penalties. Once such a customization makes amountSentLD greater than amountReceivedLD, burning only amountReceivedLD leaves the excess tokens on the source chain while the remote side still mints the lower amount. Over time that silently inflates the global supply relative to what is minted elsewhere, breaking the accounting guarantees of the OFT mesh.

    Recommendation

    Burn amountSentLD, in line with the upstream MintBurnOFTAdapter, so every unit deducted on the source chain is destroyed regardless of downstream adjustments. If you want to keep the current behaviour until divergence is formally supported, enforce require(amountSentLD == amountReceivedLD) before burning to fail fast instead of letting inflation slip through silently.

  2. I-01 Informational Lack Of A Double Step Transfer Ownership Pattern Best Practices Acknowledged
    Location
    OverridableInboundRateLimiter.sol
    Round
    Remediation Review

    Description

    The current ownership transfer process for the OverridableInboundRateLimiter which is inheriting from the Ownable contract involves the current owner calling the transferOwnership function:

    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }
    

    If the nominated EOA account is not a valid account, it is entirely possible that the owner may accidentally transfer ownership to an uncontrolled account, losing the access to all functions with the onlyOwner modifier.

    Recommendation

    It is recommended to implement a two-step process transfer ownership process where the owner nominates an account and the nominated account needs to call an acceptOwnership function for the transfer of the ownership to fully succeed. This ensures the nominated EOA account is a valid and active account. This can be easily achieved by using OpenZeppelin’s Ownable2Step contract.

More from GMX

All 60 reports
  1. Morpho Liquidation Module

    3 findings 3 findings: 3 informational
  2. RewardRouterV3 & RewardRouterUtils

    20 findings1 high 20 findings: 1 high, 8 low, 11 informational
  3. V2.2.1 Review

    102 findings8 high 102 findings: 8 high, 37 medium, 49 low, 8 informational
  4. Incentives Contracts

    17 findings 17 findings: 3 medium, 3 low, 11 informational

Put your code through the same review.

This review started with a conversation about scope. Tell us what you are building and we will plan yours with you.

Get a quote