IAGmxV2
IAGmxV2
DirectCallNotAllowed
error DirectCallNotAllowed()Thrown when the adapter is called directly instead of via delegatecall.
NotArbitrum
error NotArbitrum()Thrown when deploying on a chain other than Arbitrum.
InvalidIncreaseOrderType
error InvalidIncreaseOrderType()Thrown when the caller passes an order type that is not MarketIncrease.
InvalidDecreaseOrderType
error InvalidDecreaseOrderType()Thrown when the caller passes an order type that is not a valid decrease type.
ExecutionFeeExceedsMax
Thrown when the requested execution fee exceeds the protocol maximum (0.05 ETH). Prevents pool operators from accidentally (or maliciously) draining the pool's WETH balance.
InsufficientNativeBalance
Emitted when the pool's combined WETH + native ETH balance is insufficient to cover the execution fee.
createIncreaseOrder
Opens or increases a leveraged position via a GMX v2 market increase order.
Uses GMX's own CreateOrderParams. The adapter enforces safe values for receiver, cancellationReceiver, callbackContract, uiFeeReceiver, swapPath, executionFee, callbackGasLimit, shouldUnwrapNativeToken, referralCode, dataList, and orderType (always MarketIncrease) — caller-supplied values for these fields are ignored. Only addresses.market, addresses.initialCollateralToken, numbers.initialCollateralDeltaAmount, numbers.sizeDeltaUsd, numbers.acceptablePrice, and isLong are used from the caller.
Parameters
params
struct IBaseOrderUtils.CreateOrderParams
GMX CreateOrderParams (security-critical fields are overridden by the adapter).
Return Values
orderKey
bytes32
The unique key of the created GMX order.
createDecreaseOrder
Decreases or closes a leveraged position via a GMX v2 decrease order.
Uses GMX's own CreateOrderParams. The adapter enforces safe values for receiver, cancellationReceiver, callbackContract, uiFeeReceiver, swapPath, executionFee, callbackGasLimit, shouldUnwrapNativeToken, referralCode, dataList, and decreasePositionSwapType (always NoSwap) — caller-supplied values for these fields are ignored. Forcing NoSwap keeps the returned collateral in the already-tracked collateral token. The market's directional PnL token (longToken for longs, shortToken for shorts) is proactively tracked at increase time, so profits returned in that token are visible to NAV computation even for keeper-driven closes and liquidations. orderType must be one of MarketDecrease, LimitDecrease, or StopLossDecrease, otherwise the call reverts.
Parameters
params
struct IBaseOrderUtils.CreateOrderParams
GMX CreateOrderParams (security-critical fields are overridden by the adapter).
Return Values
orderKey
bytes32
The unique key of the created GMX order.
updateOrder
Updates size, price or fee of an existing pending GMX order.
Matches the GMX ExchangeRouter selector exactly. Tops up the execution fee automatically (same on-chain formula as createOrder). Only limit-type orders are updatable; calling on MarketIncrease/Decrease reverts at GMX level.
Parameters
key
bytes32
The unique order key to update.
sizeDeltaUsd
uint256
New size delta in USD (GMX 10^30 precision).
acceptablePrice
uint256
New acceptable execution price.
triggerPrice
uint256
New trigger price for limit/stop-loss orders.
minOutputAmount
uint256
New minimum output amount.
validFromTime
uint256
New valid-from timestamp.
autoCancel
bool
New auto-cancel flag.
cancelOrder
Cancels a pending GMX order and recovers collateral / execution fees back to the pool.
Parameters
key
bytes32
The order key to cancel.
claimFundingFees
Claims accumulated funding fees for one or more market/token pairs.
Matches the GMX ExchangeRouter selector exactly. Claimed tokens are always sent to the pool (address(this) in delegatecall context) regardless of the receiver argument. Claimed tokens are registered in the active tokens set when they have a valid price feed.
Parameters
markets
address[]
Array of GMX market addresses to claim from.
tokens
address[]
Array of token addresses corresponding to each market.
receiver
address
Ignored — overridden to address(this) to ensure funds stay in the pool.
claimCollateral
Claims collateral freed from positions where the negative price impact threshold was exceeded.
Matches the GMX ExchangeRouter selector exactly. Claimed tokens are always sent to the pool (address(this) in delegatecall context) regardless of the receiver argument. Claimed tokens are registered in the active tokens set when they have a valid price feed. Note: the deployed GMX ExchangeRouter reverts with an arithmetic underflow when claimable amount is zero — callers must only invoke this when collateral is claimable.
Parameters
markets
address[]
Array of GMX market addresses to claim from.
tokens
address[]
Array of token addresses corresponding to each market.
timeKeys
uint256[]
Array of time bucket keys identifying each claimable collateral batch.
receiver
address
Ignored — overridden to address(this) to ensure funds stay in the pool.
Last updated