- Router: Bridge, swap, lend, stake and compose multistep flows in one call
- Exchange Rates: Fetch real time pricing across chains
- Yield: Discover and optimize yield values
- Debt: Borrow, repay and manage debt positions in a single transaction
- Widget: Prebuilt UI components for a secure and smooth UX
- Swidge (Coming Soon)
- Solve (Coming Soon)
Router
The Route API is a powerful and flexible automated pathfinding engine designed for developers to implement efficient onchain interaction logic and calculate optimal path between any two DeFi positions. Whether you’re swapping tokens, entering positions, adding liquidity or moving assets, the API provides everything needed for handling the complex routing logic automaticallyGetting Your First Router Quote
The first step in using the GlueX Router API is to generate a quote for a desired DeFi operation. This can be achieved by sending a POST request to the/v1/quote
endpoint. It’s recommended to start with the below example request and then explore more customization options in the Router API Reference
Sample Request
The first step in using the GlueX Router API to generate a quote. This can be achieved by sending aPOST
request to the /v1/quote
endpoint. It is recommended to start with the below example request and apply more customization from (here)[/docs/router/quote]
Sample Response
How to Use
Once you have the/quote
response, you can use any web3 library (eg: ethers.js, web3.js, web3.py) to build, sign and send the transaction. The key fields you’ll need are:
calldata
: ABI encoded function call for the routervalue
: Native token amount to attach (if input is a native token)computationUnits
: Simulated gas estimate (recommended -gasLimit = computationUnits × 1.3
)
Learn More
API Reference
Full specification and documentation for router API
Architecture
Learn more about the smart routing engine and it’s architecture
Tutorials
Indepth integration guides and best practices
Parameter Reference
Full request and response field definitions
Examples
Code snippets for common flows and use cases
Examples
Token Swap
Token Swap
With Router’s token swap API, you can swap any token A → token B on any supported blockchain in just one call.
Instead of dealing with multiple steps like approvals, liquidity sourcing and slippage calculations,
Router takes care of everything under the hood, letting you focus on what matters - receiving your desired token directly in your wallet
Here’s a real USDT → WBTC one call swap - 0x91c969f626d80c273008627d1a9d47b5f4600d9584ee045f0fdd57a080320dce
Why use GlueX for token swaps?
Traditionally, swapping tokens on a blockchain involves:- Finding liquidity pools across decentralized exchanges (DEXs)
- Checking prices and slippage tolerance to avoid bad execution
- Manually approving tokens so they can be spent by a smart contract
- Building and broadcasting the transaction with correct gas settings
- Tracking the transaction until it confirms
- The input token (what you’re swapping from)
- The output token (what you’re receiving)
- The amount
- Your wallet address
- Aggregate liquidity across multiple sources to find the best route
- Handle token approvals automatically
- Execute the transaction in one step
- Send the output tokens directly to your wallet (or any another specified address)
Example: Swap USDT → WBTC on Ethereum
Here’s how you can swap 100 USDT into WBTC on Ethereum in a single API request:Vault Entry
Vault Entry
With Router’s vault entry flow, you can deposit into yield vaults (like Yearn, Aave, etc.) in just one transaction
No matter if you already hold the vault’s underlying asset or need to swap into it first,
Router handles all the required steps automatically, saving you from manual approvals and multiple transactions
Here’s a real WBTC → MEVCapital USDC vault deposit transaction - 0xe608be4745380168d4b882f012cb37b0282ff0ff96749ad579747143a4693c6b
Why use GlueX for vault deposits?
Normally, entering a vault requires several steps:- Acquire the correct deposit token (swap into the asset the vault accepts)
- Approve the vault contract to spend your tokens
- Deposit the tokens into the vault
- Wait for confirmation before receiving vault shares in your wallet
- The input token (what you’re starting with)
- The vault token (the token you’ll receive, eg: yvUSDC)
- The amount
- Your wallet address
- Swap into the correct deposit asset if needed
- Approve the vault contract automatically
- Deposit the tokens on your behalf
- Send the vault shares (yvTokens) directly to your wallet (or any another specified address)
Example: Example: Deposit WBTC → MEVCapital USDC Vault
Here’s how you can deposit WBTC directly into the MEVCapital USDC Vault in one step:Lending
Lending
With Router’s lending flow, you can supply assets to lending protocols (like Aave, Compound, etc) and
receive interest-bearing tokens (aTokens, cTokens, etc) in one unified action.
Whether you already hold the protocol’s required asset or need to swap into it first, Router automates the entire process
Here’s a real USDC → Receive aWETH lending transaction - 0x37cdcdf63b962f3a945c37436da2965c12f590cc340eee72dde1187aa9ae0a40
Why use GlueX for Lending?
Normally, lending assets requires several manual steps:- Swap into the correct deposit token (eg: swap USDC into WETH if the protocol requires WETH)
- Approve the lending protocol contract to spend your tokens
- Call the protocol’s deposit method to supply liquidity
- Receive the corresponding aToken/cToken representing your deposit
- The input token (what you’re starting with)
- The deposit token you want to receive (eg: aWETH)
- The amount
- Your wallet address
- Swap into the correct asset if needed
- Handle approvals automatically
- Supply liquidity to the protocol
- Deliver the interest bearing token directly to your wallet (or any another specified address)
Example: Lend USDC → Receive aWETH
Here’s how to lend 50 USDC and receive aWETH in a single API request:Staking
Staking
With Router’s staking flow, you can stake any token into a staking protocol (such as Lido, Swell, Rocket Pool, etc)
and receive the staked token in a single call. Whether you already hold the staking asset or need to swap into it first,
Router automates the full lifecycle - from swap, to staking - in one gas optimized transaction
Here’s a real USDC → Receive DAI** into swETH lending transaction - 0x37cdcdf63b962f3a945c37436da2965c12f590cc340eee72dde1187aa9ae0a40
Why Use Router for Staking?
Normally, staking involves multiple steps:- Swap into the staking asset if you don’t already hold it
- Approve the staking contract to spend your tokens
- Send the stake transaction to the protocol
- Receive your staked token in return
- The input token (what you’re staking with)
- The staked token you want to receive
- The amount
- Your wallet address
- Swap if required into the correct staking asset
- Approve the staking contract
- Stake on your behalf
- Deliver the staked token directly to your wallet
Example: Stake DAI → swETH
Here’s how to stake DAI → swETH in one call using Router:Crosschain
Crosschain
COMING SOON…
Exchange Rate
The Exchange Rates API provides an easy to use, scalable solution for retrieving on-chain exchange rates between any two token pairs across multiple supported blockchains. Whether you’re building a DeFi app, wallet or trading platform, you can fetch realtime, accurate rates in a single batch callSample Request
The first step in using the GlueX Exchange Rates API to fetch the price of a token pair. This can be achieved by sending aPOST
request to the root /
endpoint. It is recommended to start with the below example request and apply more customization from (here)[/api-reference/exchange-rate-api/post-price]
Each call can batch upto 25 pairs per request
Sample Request
How to Use
- Parse the JSON: Iterate over the array to extract price for each token pair
- Batching: Request up to 25 pairs at once to minimize round trips
- No Auth Needed: Public access by default, supply an API key header for higher rate limits when available
Learn More
API Reference
Full specification and documentation for exchange rates API
Architecture
Learn more about the how the exchange rates works
Tutorials
Indepth integration guides and best practices
Parameter Reference
Full request and response field definitions
Examples
Code snippets for common flows and use cases
Examples
COMING SOON…
Widget
The GlueX Widget offers a plug and play UI for embedding full featured DeFi operations like routing, swap, bridge, stake, lend and more into your applicaation with minimal code and maximum customizationInstallation
Install the core packages (using your preferred package manager):Sample Integration
Embed the widget in your React (or compatible) app with just a few lines:Learn More
Configuration
Full list of
<GlueXWidget />
properties and default valuesTheming Guide
Deep dive into theme, style, shape, typography and color overrides
Event System
How to hook into widget events for analytics and UX
Advanced Examples
Prebuilt layouts and custom component overrides
Widget Studio
Visual tool for generating theme and config JSON