AGmxV2
Overview
License: Apache-2.0-or-later
contract AGmxV2 is IAGmxV2, IMinimumVersion, ReentrancyGuardTransientsecurity-contact: security@rigoblock.com
Modifiers info
onlyDelegateCall
modifier onlyDelegateCall()Functions info
constructor
constructor()requiredVersion (0x2ea6c3f0)
function requiredVersion() external pure override returns (string memory)Returns the minimum implementation version to use an external application.
Adapters must implement it when modifying proxy state or storage.
Return values:
[0]
string
String of the minimum supported version.
createIncreaseOrder (0x13b4312f)
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 (0xe478512e)
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 (0xdd5baad2)
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 (0x7489ec23)
Cancels a pending GMX order and recovers collateral / execution fees back to the pool.
Parameters:
key
bytes32
The order key to cancel.
claimFundingFees (0xc41b1ab3)
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 (0xe9249b57)
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