Skip to main content
Decentralized perpetual exchange with multi-asset liquidity pool (GLP). Supports leverage trading up to 50x.

What it offers

  • openPosition: Open/increase leveraged position via PositionRouter
  • closePosition: Close/decrease leveraged position
  • swap: Swap tokens via GMX Router

Notes

  • Execution fee: each request’s msg.value must equal its _executionFee, which must be at least the PositionRouter’s minExecutionFee() (read it). The fee goes to whoever executes or cancels the request
  • Must call router.approvePlugin(positionRouter) once before using position operations
  • Path: for longs, path=[collateral]. For shorts, path=[stablecoin]. For swaps, path=[tokenIn, tokenOut]
  • sizeDelta is position size in USD with 30 decimals
  • acceptablePrice (USD, 30 decimals) bounds the mark price at execution, and its direction depends on the request; there is no market-price sentinel, and 0 is not one. A long increase or a short decrease executes only while the mark price is at most acceptablePrice (pass the highest price you accept); a short increase or a long decrease only while it is at least acceptablePrice (pass the lowest). When the mark price is outside the bound, the execution reverts and the keeper cancels the request, so 0 never executes a long increase or a short decrease

Its names in a program

On Arbitrum One, GmxV1 is a namespace: its contracts need no import.

Deployments

ABI

PositionRouterABI

import PositionRouterABI from "./protocols/gmx-v1/PositionRouterABI.json"; Speaks for: positionRouter.
  • createIncreasePosition(address[] _path, address _indexToken, uint256 _amountIn, uint256 _minOut, uint256 _sizeDelta, bool _isLong, uint256 _acceptablePrice, uint256 _executionFee, bytes32 _referralCode, address _callbackTarget) payable returns (bytes32 requestKey)
  • createDecreasePosition(address[] _path, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver, uint256 _acceptablePrice, uint256 _minOut, uint256 _executionFee, bool _withdrawETH, address _callbackTarget) payable returns (bytes32 requestKey)

RouterABI

import RouterABI from "./protocols/gmx-v1/RouterABI.json"; Speaks for: router.
  • approvePlugin(address _plugin)
  • swap(address[] _path, uint256 _amountIn, uint256 _minOut, address _receiver)

VaultABI

import VaultABI from "./protocols/gmx-v1/VaultABI.json"; Speaks for: vault.
  • swap(address _tokenIn, address _tokenOut, address _receiver) returns (uint256)
  • increasePosition(address _account, address _collateralToken, address _indexToken, uint256 _sizeDelta, bool _isLong)
  • decreasePosition(address _account, address _collateralToken, address _indexToken, uint256 _collateralDelta, uint256 _sizeDelta, bool _isLong, address _receiver) returns (uint256)

Next steps