Importance Of Multicall

A critical analysis to GMX Order Creation Atomicity - Discover the essential role of atomic transactions (`multicall`) in securing GMX orders. Learn how `recordTransferIn` verifies funds within a single transaction context to prevent front-running.

Get SSCD+ certified, for free!

Cyfrin Updraft has partnered with GMX to provide SSCD+ certifications vouchers to the first 25 students who demonstrate the completion of this course and are building on top of GMX. Join the GMX Discord server to redeem your coupon, or navigate to the docs to learn more!

1. Payoffs For Positions
An analytical exploration to GMX Collateral Strategies using Payoff Diagrams - Delve into payoff diagrams to analyze the profit and loss profiles of ETH/USD positions on GMX using WETH or USDC collateral. Discover the impact of collateral choice on risk, reward, and achieving delta neutrality. Duration: 10min
2. UI Trade Fees
A thorough examination to Understanding GMX Transaction Costs - Delve into the fee structure for GMX trading and swapping, covering network, open/close, borrow, funding, and swap fees. Grasp the concept of price impact and learn about the hidden UI fee applied via the front-end. Duration: 1min
3. Purpose Of Price Impact
An insightful breakdown to Deciphering Price Impact - Uncover the mechanism balancing GMX V2 pools via rebates and fees linked to trade imbalance effects. Master the context-specific definitions of long/short for swaps versus opening/closing positions. Duration: 1min
4. Price Impacts For Different Orders
An analytical breakdown to Decoding GMX Synthetics Price Impact - Uncover the mechanics of GMX price impact, driven by pool and market imbalances. Discover how swaps, positions, and liquidity deposits receive bonuses or incur fees via specific code logic. Duration: 9min
5. Price Impact Formula
An analytical breakdown to Calculating Price Impact - Explore the core logic behind price impact, differentiating between "Same Side" and "Cross Over" conditions. Discover how initial/next imbalance and specific impact factors (`f`, `p`, `n`) are used in the distinct formulas. Duration: 2min
6. Price Impact Graph
An analytical guide to Visualizing GMX Price Impact - Explore the Desmos graph illustrating GMX price impact based on open interest imbalance. Learn how initial and next imbalances define "same side" or "crossover" scenarios and their effect on price. Duration: 5min
7. Quiz 1 Quiz
Questions: 13
8. Virtual Inventory
A technical explanation to Virtual Inventory in GMX Synthetics - Understand how GMX prevents price manipulation using virtual inventory for both swaps and perpetual positions. Learn how global token amounts and net open interest across all markets influence price impact calculations. Duration: 3min
9. Swap Fees
An in-depth analysis to From UI to Solidity: GMX Fees - Follow the path of GMX fee calculation from the frontend interface to the `getSwapFees` function in the smart contracts. Discover how `feeFactor` and `uiFeeFactor` are determined based on action type in `SwapPricingUtils.sol`. Duration: 1min
10. Position Fees
An essential breakdown to Understanding GMX Trading Fees - Explore the various costs associated with opening, closing, and holding perpetual positions on GMX. Learn about price impact, platform fees, network costs, borrowing fees, and dynamic funding rates. Duration: 1min
11. Math Borrowing Fee
An essential breakdown of Borrowing Fees - Learn why traders pay borrowing fees and how these incentivize liquidity providers. Discover the efficient cumulative sum technique used by protocols like GMX to overcome on-chain gas limitations. Duration: 4min
12. How Borrowing Fee Is Calculated In Code
A technical breakdown to Calculating GMX Borrowing Fees - Dive into the `MarketUtils.sol` contract to see how the `getBorrowingFees` function calculates costs. Understand the role of the `cumulativeBorrowingFactor` and how it's applied to position size. Duration: 1min
13. How Borrowing Fee Is Updated
A precise look to Calculating Borrowing Fees on Position Changes - Uncover the exact order of operations used to calculate and settle borrowing fees *before* a position's size is modified. Understand how market and position factors ensure accurate fee accounting during increases or decreases. Duration: 2min
14. Cumulative Borrowing Factor
A detailed breakdown to Calculating the Next Cumulative Borrowing Factor - Explore how GMX Synthetics computes the updated cumulative borrowing factor in `MarketUtils.sol`. Learn how elapsed time and the borrowing rate per second are multiplied to efficiently determine the next factor value. Duration: 1min
15. Borrowing Factor Per Second
A technical walkthrough to GMX Synthetics Borrowing Fee Calculation - Unpack the complex logic within `MarketUtils.sol` for determining the dynamic borrowing rate per second. Master key inputs like `reserved USD`, `usage factor`, and the exponential vs. kinked rate models. Duration: 4min
16. Graph Kink Borrowing Factor
A graphical exploration to Visualizing Kinked Borrowing Fees - Discover how a 'kink' model dynamically sets borrowing fees based on resource usage via a Desmos graph. Learn why costs increase gently below an optimal point but rapidly escalate beyond it to incentivize stability. Duration: 1min
17. Quiz 2 Quiz
Questions: 17
18. Purpose Of Funding Fees
A detailed guide to Funding Fees - Explore how funding fees function as payments between long and short positions to maintain market equilibrium. Learn why this mechanism protects liquidity providers and how rates impact trading decisions. Duration: 1min
19. UI Claim Funding Fee
A practical walkthrough to Claiming GMX Funding Fees - Learn how to locate your accrued funding fees within the GMX platform's Claims tab. Follow the simple steps to initiate the claim process and confirm the transaction with your connected wallet. Duration: 0min
20. Math Funding Fee
An in-depth analysis to Funding Fees - Uncover how perpetual swap funding fees are efficiently calculated using cumulative fee factors per unit size. Learn the derivation and logic behind tracking long/short payments separately, mirroring the GMX implementation. Duration: 4min
21. How Funding Fee Is Updated
A technical walkthrough to The Funding Fee Update Process - Delve into the sequence of function calls and state updates that occur when a trader modifies a position. Understand how global cumulative rates and position-specific data interact to calculate and apply funding fees. Duration: 1min
22. Funding Factor Per Second
A detailed examination to Decoding GMX Funding Factor Logic - Uncover the mechanics of `MarketUtils.getNextFundingFactorPerSecond` in GMX Synthetics, focusing on open interest skew's role. Learn how static versus adaptive funding calculations determine the rate using key parameters and bounding. Duration: 6min
23. Quiz 3 Quiz
Questions: 5
24. UI Take Profit And Stop Loss
An essential explanation to Setting Take Profit and Stop Loss Orders on GMX - Master setting automated Take Profit and Stop Loss limits for Long and Short trades on GMX. Grasp the underlying three-order system and the vital Auto Cancel feature for efficient position management. Duration: 3min
25. UI Advanced Trade Orders
An essential walkthrough to GMX Trading Orders Explained - Master GMX trading with Limit and Stop Market orders for precise entry points on swaps and leveraged trades. Learn the key differences from Market orders and the function of TP/SL for position management. Duration: 2min
26. Swap Token Flow
A step-by-step guide to GMX Swap Execution Flow - Witness how a keeper triggers a GMX swap order, moving tokens through the OrderHandler, OrderVault, and specific MarketToken contracts. See how user input tokens are exchanged and execution fees are distributed. Duration: 2min
27. Create Order For Market Swap
A step-by-step tutorial to Understanding GMX V2 Swap Transactions - Discover how to leverage Tenderly and Arbiscan to debug and trace the creation of a GMX V2 market swap. Follow the detailed contract interactions and data flow using a real transaction hash. Duration: 7min
28. Create Order For A Position
An in-depth breakdown to Creating GMX Short Positions via ExchangeRouter - Use Tenderly to trace a short ETH transaction, analyzing the `multicall` and `createOrder` functions. Understand critical parameters like `sizeDeltaUsd`, `orderType`, `isLong`, and the impact of `swapPath` on collateral. Duration: 3min
29. Create Order To Close A Position
A technical breakdown to GMX v2 `createOrder` for Market Decrease - Examine the specific parameters passed to the GMX v2 `createOrder` function when closing a position via market order. Learn how Tenderly helps decode crucial inputs like collateral, order type, and swap preferences. Duration: 2min
30. Create Orders Take Profit And Stop Loss
A detailed guide to Debugging GMX Take Profit and Stop Loss Orders - Learn to dissect `multicall` transactions using tools like Tenderly to understand how GMX Take Profit and Stop Loss orders are created. Decode `OrderType` enums and verify trigger prices by analyzing `createOrder` parameters on-chain. Duration: 3min
31. Importance Of Multicall
A critical analysis to GMX Order Creation Atomicity - Discover the essential role of atomic transactions (`multicall`) in securing GMX orders. Learn how `recordTransferIn` verifies funds within a single transaction context to prevent front-running. Duration: 3min
32. Claim Funding Fees
A technical breakdown to Claiming Funding Fees via Smart Contract Interaction - Learn how to dissect a transaction using Tenderly/Arbiscan to locate the `ExchangeRouter` contract and `claimFundingFees` function. Discover how to extract the required market addresses, token addresses (WETH, USDC), and receiver for programmatic claiming. Duration: 1min
33. Quiz 4 Quiz
Questions: 13
34. Market Swap Exercises
A practical exercise to Market Swap Exercises - Implement Solidity functions to execute GMX V2 market swaps, converting WETH to DAI. Learn to handle execution fees, token transfers, and retrieve order details via smart contract calls. Reading Time: 0min
35. Limit Swap Exercises
A hands-on exercise to Limit Swap Exercises - Implement Solidity functions to interact with GMX V2 for creating limit swap orders. Learn to handle execution fees, token transfers, and calculate minimum output amounts. Reading Time: 0min
36. Long Exercises
A hands-on exercise to Long Position Exercises - Implement Solidity functions to interact with GMX V2 for creating leveraged long ETH positions. Learn to open positions, retrieve details, calculate PnL, and close positions via smart contracts. Reading Time: 0min
37. Short Exercises
A hands-on exercise to Short Position Exercises - Implement Solidity functions to interact with GMX V2 for creating short ETH/USDC positions. Learn to manage execution fees, retrieve position data, and close positions via smart contract calls. Reading Time: 0min
38. Claim Funding Fees Exercises
A practical exercise to Claim Funding Fees Exercises - Implement Solidity functions to check claimable GMX funding fees using the `dataStore`. Learn how to execute the fee claim operation via the `exchangeRouter`. Reading Time: 0min
39. Take Profit And Stop Loss Exercises
A practical exercise to Take Profit and Stop Loss Exercises - Implement Solidity functions to create a GMX V2 long ETH position with associated risk management. Learn to set up stop loss and take profit orders via smart contract calls. Reading Time: 0min

Course Overview

About the course

What you'll learn

Mechanics and contract architecture of the GMX protocol

Token pricing and fees

Liquidity: GM pools and GLV vaults

Math, funding rates, liquidation pricing, P&L calculations

Limit orders, take profit orders, stop loss, and stop market orders

Auto-cancel and auto-deleveraging

GLP, esGMX, GMX staking and delegation

Course Description

Who is this course for?

  • Software engineers
  • Web3 developers
  • Finance developers
  • Smart contract security researchers

Potential Careers

DeFi Developer

$75,000 - $200,000 (avg. salary)

Smart Contract Engineer

$100,000 - $150,000 (avg. salary)

Web3 developer

$60,000 - $150,000 (avg. salary)

Web3 Developer Relations

$85,000 - $125,000 (avg. salary)

Smart Contract Auditor

$100,000 - $200,000 (avg. salary)

Security researcher

$49,999 - $120,000 (avg. salary)

Meet your instructors

Tasuku Nakamura

Tasuku Nakamura

Founder at smartcontract.engineer

Smart contract engineer and educator.

Last updated on June 26, 2025