BTB Finance for agents

Protocols / Derivatives

GMX

Decentralized perpetuals and spot-style swaps on GMX V2. An agent can supply liquidity to GM and GLV pools, withdraw them, and open, change or close leveraged positions through the ExchangeRouter. Orders are executed later by keepers, not in the same transaction.

On-chainEVM12 contractsWebsite · Docs

get_protocol({ "protocol": "gmx" })

Risks an agent should know

What an agent can do

add-liquidity-gmDeposit tokens into a GM market pool and receive GM tokens
approve the Router for the long or short token, then ExchangeRouter.multicall([sendWnt(DepositVault, executionFee), sendTokens(token, DepositVault, amount), createDeposit(params)]) with msg.value = executionFee. A keeper executes the deposit and mints GM to receiver. Check getDeposit or the order status later. minMarketTokens protects against slippage.
remove-liquidity-gmRedeem GM tokens for the pool's underlying tokens
approve the Router for GM, then ExchangeRouter.multicall([sendWnt(WithdrawalVault, executionFee), sendTokens(gmToken, WithdrawalVault, amount), createWithdrawal(params)]). A keeper pays out the underlying tokens to receiver.
add-liquidity-glvDeposit GM or market tokens into a GLV vault
approve the Router for the token, then GlvRouter.multicall([sendWnt(GlvVault, executionFee), sendTokens(token, GlvVault, amount), createGlvDeposit(params)]) with msg.value = executionFee.
remove-liquidity-glvRedeem GLV tokens
approve the Router for the GLV token, then GlvRouter.multicall([sendWnt(GlvVault, executionFee), sendTokens(glv, GlvVault, amount), createGlvWithdrawal(params)]).
open-or-change-positionOpen, increase, decrease or close a leveraged position, or make a limit or stop order
transfer collateral to the OrderVault with sendTokens and the execution fee with sendWnt, then createOrder(params) in the same multicall. Use orderType and isLong to set the direction. Size is in USD with 30 decimals. Read the market and prices from the REST API or Reader before sizing.
cancel-orderCancel a pending order or deposit
ExchangeRouter.cancelOrder(key), cancelDeposit(key) or cancelWithdrawal(key) with the bytes32 key from the creation event
check-positionsRead open positions and pool markets
Reader.getAccountPositions(DataStore, account, 0, n) and Reader.getMarkets(DataStore, 0, n) on the chain's Reader address

Contracts

arbitrum · chain id 42161

ContractAddressKey functionsTry
ExchangeRouter
router
0x1C3fa76e6E1088bCE750f23a5BFcffa1efEF6A41
source
writemulticall(bytes[])
writesendTokens(address,address,uint256)
writesendWnt(address,uint256)
writecreateDeposit(((address,address,address,address,address,address,address[],address[]),uint256,bool,uint256,uint256,bytes32[]))
writecreateWithdrawal(((address,address,address,address,address[],address[]),uint256,uint256,bool,uint256,uint256,bytes32[]))
writecreateOrder(((address,address,address,address,address,address,address[]),(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256),uint8,uint8,bool,bool,bool,bytes32,bytes32[]))
writeupdateOrder(bytes32,uint256,uint256,uint256,uint256,uint256,bool)
writecancelOrder(bytes32)
+3 more via get_protocol
Full ABI
Router (token approval target)
router
0x7452c558d45f8afC8c83dAe62C3f8A5BE19c71f6
source
Full ABI
GlvRouter
router
0x7EAdEE2ca1b4D06a0d82fDF03D715550c26AA12F
source
writecreateGlvDeposit(((address,address,address,address,address,address,address,address[],address[]),uint256,uint256,uint256,bool,bool,bytes32[]))
writecreateGlvWithdrawal(((address,address,address,address,address,address[],address[]),uint256,uint256,bool,uint256,uint256,bytes32[]))
writemulticall(bytes[])
writecancelGlvDeposit(bytes32)
writecancelGlvWithdrawal(bytes32)
Full ABI
Reader
other
0x470fbC46bcC0f16532691Df360A07d8Bf5ee0789
source
readgetMarkets(address,uint256,uint256)
readgetAccountPositions(address,address,uint256,uint256)
readgetPositionInfo(address,address,bytes32,((uint256,uint256),(uint256,uint256),(uint256,uint256)),uint256,address,bool)
readgetPosition(address,bytes32)
readgetDeposit(address,bytes32)
readgetWithdrawal(address,bytes32)
Full ABI
GlvReader
other
0x2C670A23f1E798184647288072e84054938B5497
source
readgetGlvs(address,uint256,uint256)
readgetGlvInfo(address,address)
Full ABI
DataStore
other
0xFD70de6b91282D8017aA4E741e9Ae325CAb992d8
source
Full ABI

avalanche · chain id 43114

ContractAddressKey functionsTry
ExchangeRouter
router
0x8f550E53DFe96C055D5Bdb267c21F268fCAF63B2
source
writemulticall(bytes[])
writesendTokens(address,address,uint256)
writesendWnt(address,uint256)
writecreateDeposit(((address,address,address,address,address,address,address[],address[]),uint256,bool,uint256,uint256,bytes32[]))
writecreateWithdrawal(((address,address,address,address,address[],address[]),uint256,uint256,bool,uint256,uint256,bytes32[]))
writecreateOrder(((address,address,address,address,address,address,address[]),(uint256,uint256,uint256,uint256,uint256,uint256,uint256,uint256),uint8,uint8,bool,bool,bool,bytes32,bytes32[]))
writecancelOrder(bytes32)
writeupdateOrder(bytes32,uint256,uint256,uint256,uint256,uint256,bool)
Full ABI
Router (token approval target)
router
0x820F5FfC5b525cD4d88Cd91aCf2c28F16530Cc68
source
Full ABI
GlvRouter
router
0x7E425c47b2Ff0bE67228c842B9C792D0BCe58ae6
source
writecreateGlvDeposit(((address,address,address,address,address,address,address,address[],address[]),uint256,uint256,uint256,bool,bool,bytes32[]))
writecreateGlvWithdrawal(((address,address,address,address,address,address[],address[]),uint256,uint256,bool,uint256,uint256,bytes32[]))
Full ABI
Reader
other
0x62Cb8740E6986B29dC671B2EB596676f60590A5B
source
readgetMarkets(address,uint256,uint256)
readgetAccountPositions(address,address,uint256,uint256)
readgetPosition(address,bytes32)
Full ABI
GlvReader
other
0x5C6905A3002f989E1625910ba1793d40a031f947
source
readgetGlvs(address,uint256,uint256)
Full ABI
DataStore
other
0x2F0b22339414ADeD7D5F06f9D604c7fF5b2fe3f6
source
Full ABI

APIs

GMX REST API (Arbitrum)
auth: none
https://arbitrum-api.gmxinfra.io
Read prices and tickers for quoting. Public GET endpoints; see the REST docs for the full list and the Avalanche base URL.

Notes

Addresses come from the official gmx-synthetics deployments folder (deployments/arbitrum and deployments/avalanche on the main branch). Function signatures were checked against the verified ExchangeRouter, GlvRouter and Reader ABIs on Sourcify; Arbitrum and Avalanche ExchangeRouter ABIs have the same function list. Struct layouts are written from the ABI tuples, so read the exact field names from the ABI before encoding. Vault contracts (DepositVault, WithdrawalVault, OrderVault, GlvVault) are not listed as contracts; their addresses are in the same deployment folder. Botanix and MegaETH, which DefiLlama also lists for GMX, are not covered. GM and GLV market token addresses are not in this file; get them from the Reader or the REST API.

Sources

Researched 2026-11-28. Addresses are copied from the official sources above; check them before moving large amounts.