Documentation Index Fetch the complete documentation index at: https://mintlify.com/1inch/fusion-sdk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The 1inch Fusion SDK provides multiple methods for creating and placing orders. This guide covers the complete workflow from getting a quote to submitting an order.
Order Flow
Get a Quote
Request quote information for your swap parameters
Create Order
Build the order structure with your parameters
Submit Order
Submit the signed order to the 1inch Fusion network
Monitor Status
Track the order status until it’s filled or expires
Method 1: Using placeOrder()
The placeOrder() method is the simplest way to create and submit an order. It handles the entire process in one call.
Basic Example
import { FusionSDK , NetworkEnum , PrivateKeyProviderConnector } from '@1inch/fusion-sdk'
import { Address , Bps } from '@1inch/limit-order-sdk'
const makerPrivateKey = '0x123....'
const makerAddress = '0x123....'
const blockchainProvider = new PrivateKeyProviderConnector (
makerPrivateKey ,
web3Provider
)
const sdk = new FusionSDK ({
url: 'https://api.1inch.dev/fusion' ,
network: NetworkEnum . ETHEREUM ,
blockchainProvider ,
authKey: 'YOUR_DEV_PORTAL_API_TOKEN'
})
const orderInfo = await sdk . placeOrder ({
fromTokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' , // WETH
toTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' , // USDC
amount: '50000000000000000' , // 0.05 ETH
walletAddress: makerAddress
})
console . log ( 'Order placed:' , orderInfo . orderHash )
With Optional Parameters
const orderInfo = await sdk . placeOrder ({
fromTokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' ,
toTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' ,
amount: '50000000000000000' ,
walletAddress: makerAddress ,
// Optional: specify custom receiver
receiver: '0x...' ,
// Optional: choose execution speed preset
preset: PresetEnum . fast , // 'fast' | 'medium' | 'slow'
// Optional: custom nonce for batch cancellations
nonce: 1 n ,
// Optional: add integrator fee
integratorFee: {
receiver: new Address ( '0x...' ),
value: new Bps ( 100 n ) // 1% = 100 bps
}
})
Method 2: Manual Order Creation
For more control, you can manually create and submit orders using separate method calls.
Step-by-Step Process
Complete Example
Step 1: Get Quote
Step 2: Create Order
Step 3: Submit Order
import {
FusionSDK ,
NetworkEnum ,
OrderStatus ,
PrivateKeyProviderConnector ,
Web3Like
} from '@1inch/fusion-sdk'
import { computeAddress , formatUnits , JsonRpcProvider } from 'ethers'
const PRIVATE_KEY = 'YOUR_PRIVATE_KEY'
const NODE_URL = 'YOUR_WEB3_NODE_URL'
const DEV_PORTAL_API_TOKEN = 'YOUR_DEV_PORTAL_API_TOKEN'
const ethersRpcProvider = new JsonRpcProvider ( NODE_URL )
const ethersProviderConnector : Web3Like = {
eth: {
call ( transactionConfig ) : Promise < string > {
return ethersRpcProvider . call ( transactionConfig )
}
},
extend () : void {}
}
const connector = new PrivateKeyProviderConnector (
PRIVATE_KEY ,
ethersProviderConnector
)
const sdk = new FusionSDK ({
url: 'https://api.1inch.dev/fusion' ,
network: NetworkEnum . BINANCE ,
blockchainProvider: connector ,
authKey: DEV_PORTAL_API_TOKEN
})
async function main () {
// Define swap parameters
const params = {
fromTokenAddress: '0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d' , // USDC
toTokenAddress: '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' , // BNB
amount: '10000000000000000000' , // 10 USDC
walletAddress: computeAddress ( PRIVATE_KEY ),
source: 'sdk-test'
}
// Step 1: Get quote
const quote = await sdk . getQuote ( params )
const dstTokenDecimals = 18
console . log (
'Auction start amount' ,
formatUnits (
quote . presets [ quote . recommendedPreset ]. auctionStartAmount ,
dstTokenDecimals
)
)
console . log (
'Auction end amount' ,
formatUnits (
quote . presets [ quote . recommendedPreset ]. auctionEndAmount ,
dstTokenDecimals
)
)
// Step 2: Create order
const preparedOrder = await sdk . createOrder ( params )
// Step 3: Submit order
const info = await sdk . submitOrder (
preparedOrder . order ,
preparedOrder . quoteId
)
console . log ( 'OrderHash' , info . orderHash )
// Step 4: Monitor order status
const start = Date . now ()
while ( true ) {
try {
const data = await sdk . getOrderStatus ( info . orderHash )
if ( data . status === OrderStatus . Filled ) {
console . log ( 'fills' , data . fills )
break
}
if ( data . status === OrderStatus . Expired ) {
console . log ( 'Order Expired' )
break
}
if ( data . status === OrderStatus . Cancelled ) {
console . log ( 'Order Cancelled' )
break
}
} catch ( e ) {
console . log ( e )
}
}
console . log ( 'Order executed for' , ( Date . now () - start ) / 1000 , 'sec' )
}
main ()
Order Parameters
Required Parameters
fromTokenAddress: Address of the token you’re selling
toTokenAddress: Address of the token you’re buying
amount: Amount to sell (in wei/smallest unit)
walletAddress: Your wallet address (order maker)
Optional Parameters
receiver: Address to receive the output tokens (defaults to walletAddress)
preset: Execution speed preset (fast, medium, slow)
nonce: Custom nonce for batch order cancellations
permit: EIP-2612 permit call data for gasless approvals
integratorFee: Fee configuration for integrators
source: String identifier for tracking order sources
Execution Presets
Presets control the auction duration and price curve for your order.
fast : Quick execution with smaller price improvement
medium : Balanced execution time and price (recommended)
slow : Longer auction for maximum price improvement
Best Practices
Always monitor order status after submission to handle expired or failed orders appropriately.
Error Handling : Wrap order submission in try-catch blocks
Status Monitoring : Poll order status regularly or use WebSocket integration
Allowances : Ensure token approvals are set before placing orders
Gas Estimation : Consider network conditions when choosing presets
Testing : Test with small amounts first on testnets
Common Issues
Insufficient Allowance
If you haven’t approved the Fusion contract to spend your tokens:
// First, approve the token
import { getContractAddress } from '@1inch/fusion-sdk'
const fusionContract = getContractAddress ( NetworkEnum . ETHEREUM )
// Use your web3 library to approve the token for fusionContract
Invalid Order Parameters
Ensure amounts are in the smallest token unit (wei) and addresses are valid checksummed addresses.
Next Steps