Skip to main content

Overview

The FusionOrder class represents a Fusion swap order with Dutch auction pricing and resolver whitelisting capabilities. It extends the limit order protocol with time-based pricing curves and access control.

Constructor

FusionOrder.new()

Creates a new FusionOrder instance.
settlementExtension
Address
required
Fusion extension contract address. See limit-order-settlement
orderInfo
OrderInfoData
required
Basic order parameters
makerAsset
Address
required
Token address to sell
takerAsset
Address
required
Token address to buy
makingAmount
bigint
required
Amount of maker asset to sell
takingAmount
bigint
required
Minimum amount of taker asset to receive
maker
Address
required
Order creator’s wallet address
receiver
Address
Recipient address for filled orders (defaults to maker)
salt
bigint
Random value for order uniqueness
details
Details
required
Auction configuration
auction
AuctionDetails
required
Auction pricing parameters. See AuctionDetails
whitelist
Whitelist
required
Resolver access control. See Whitelist
surplus
SurplusParams
Surplus fee configuration (default: NO_FEE)
extra
Extra
Additional order options
allowPartialFills
boolean
default:"true"
Allow order to be filled in multiple transactions
allowMultipleFills
boolean
default:"true"
Allow order to be filled by multiple resolvers
unwrapWETH
boolean
default:"false"
Automatically unwrap WETH to native ETH
enablePermit2
boolean
default:"false"
Use Permit2 for token approvals
orderExpirationDelay
bigint
default:"12n"
Seconds after auction ends before order expires
nonce
bigint
Required if partial or multiple fills disabled (max 40 bits)
permit
string
Permit signature for gasless approvals
source
string
Source tracking identifier
fees
Fees
Integrator and resolver fee configuration
optimizeReceiverAddress
boolean
default:"true"
Use zero address when maker equals receiver to save gas

Methods

build()

Builds the final order struct for submission.
const builtOrder = order.build()
return
LimitOrderV4Struct
Order struct with maker, makerAsset, makingAmount, receiver, takerAsset, takingAmount, makerTraits, and salt

getOrderHash()

Computes the EIP-712 order hash.
chainId
number
required
Network chain ID (e.g., 1 for Ethereum mainnet)
const hash = order.getOrderHash(1)
return
string
Order hash for signing

getTypedData()

Generates EIP-712 typed data for wallet signatures.
chainId
number
required
Network chain ID
const typedData = order.getTypedData(1)
return
EIP712TypedData
Typed data object for signing

calcTakingAmount()

Calculates the required taking amount at a specific time considering auction dynamics.
taker
Address
required
Resolver address filling the order
makingAmount
bigint
required
Amount of maker asset being filled
time
bigint
required
Execution timestamp (Unix seconds)
blockBaseFee
bigint
default:"0n"
Block base fee in wei
const takingAmount = order.calcTakingAmount(
  resolverAddress,
  1000000000000000000n,
  1673548200n
)
return
bigint
Taking amount including auction adjustments and fees

getUserReceiveAmount()

Calculates how much the user will receive after fees.
taker
Address
required
Resolver address
makingAmount
bigint
required
Amount of maker asset
time
bigint
required
Execution timestamp (Unix seconds)
blockBaseFee
bigint
default:"0n"
Block base fee in wei
const userReceives = order.getUserReceiveAmount(
  resolverAddress,
  1000000000000000000n,
  1673548200n
)
return
bigint
Net amount user receives in taker asset

canExecuteAt()

Checks if an address can resolve the order at a given time.
executor
Address
required
Resolver address to check
executionTime
bigint
required
Timestamp to check (Unix seconds)
const canExecute = order.canExecuteAt(resolverAddress, 1673548200n)
return
boolean
True if executor can fill at that time

isExclusiveResolver()

Checks if a wallet has exclusive first-fill rights.
wallet
Address
required
Resolver address to check
const isExclusive = order.isExclusiveResolver(resolverAddress)
return
boolean
True if wallet has exclusive access period

isExclusivityPeriod()

Checks if the auction is in the exclusivity period.
time
bigint
Timestamp to check (defaults to now)
const isExclusive = order.isExclusivityPeriod()
return
boolean
True if in exclusivity period

isExpiredAt()

Checks if the order has expired.
time
bigint
required
Timestamp to check (Unix seconds)
const expired = order.isExpiredAt(1673548300n)
return
boolean
True if order is expired

Properties

maker
Address
Order creator address
makerAsset
Address
Token being sold
takerAsset
Address
Token being bought
makingAmount
bigint
Amount of maker asset
takingAmount
bigint
Amount of taker asset
receiver
Address
Receiver from order struct (may be optimized to zero address)
realReceiver
Address
Actual recipient of funds (resolves zero address to maker)
deadline
bigint
Order expiration timestamp (Unix seconds)
auctionStartTime
bigint
Auction start timestamp (Unix seconds)
auctionEndTime
bigint
Auction end timestamp (Unix seconds)
extension
Extension
Encoded extension data
partialFillAllowed
boolean
Whether partial fills are enabled
multipleFillsAllowed
boolean
Whether multiple fills are enabled
nonce
bigint
Order nonce value
salt
bigint
Order salt value

Example

import {AuctionDetails, FusionOrder, Whitelist, now, Address} from '@1inch/fusion-sdk'

const extensionContract = new Address('0x8273f37417da37c4a6c3995e82cf442f87a25d9c')
const resolvingStartAt = now()

const order = FusionOrder.new(
    extensionContract,
    {
        makerAsset: new Address('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
        takerAsset: new Address('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'),
        makingAmount: 1000000000000000000n,
        takingAmount: 1420000000n,
        maker: new Address('0x00000000219ab540356cbb839cbe05303d7705fa'),
        salt: 10n
    },
    {
        auction: new AuctionDetails({
            duration: 180n,
            startTime: 1673548149n,
            initialRateBump: 50000,
            points: [
                {
                    coefficient: 20000,
                    delay: 12
                }
            ]
        }),
        whitelist: Whitelist.new(resolvingStartAt, [
            {
                address: new Address(
                    '0x00000000219ab540356cbb839cbe05303d7705fa'
                ),
                allowFrom: resolvingStartAt
            }
        ])
    }
)

const extension = order.extension.encode() // => 0x...
const builtOrder = order.build()
/* => {
        maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
        makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
        makingAmount: '1000000000000000000',
        receiver: '0x0000000000000000000000000000000000000000',
        takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
        takingAmount: '1420000000',
        makerTraits:
            '29852648006495581632639394572552351243421169944806257724550573036760110989312',
        salt: '14832508939800728556409473652845244531014097925085'
    }
*/

Static Methods

fromNative()

Creates an order from native asset (ETH). Such orders must be submitted on-chain via ETHOrders.depositForOrder and off-chain to the relayer.
chainId
NetworkEnum
required
Network ID
ethOrdersFactory
ProxyFactory
required
ETHOrders proxy factory
settlementExtension
Address
required
Fusion extension contract
orderInfo
Omit<OrderInfoData, 'makerAsset'>
required
Order info without makerAsset (automatically set to WETH)
details
Details
required
Auction details and whitelist
extra
Extra
Additional options

fromDataAndExtension()

Reconstructs a FusionOrder from order struct and extension data.
order
LimitOrderV4Struct
required
Order struct data
extension
Extension
required
Extension bytes
const order = FusionOrder.fromDataAndExtension(orderStruct, extension)
return
FusionOrder
Reconstructed FusionOrder instance

isNativeOrder()

Checks if an order was created from native asset.
chainId
number
required
Network chain ID
ethOrderFactory
ProxyFactory
required
ETHOrders factory
order
LimitOrderV4Struct
required
Order to check
signature
string
required
Order signature
const isNative = FusionOrder.isNativeOrder(
  1,
  ethOrdersFactory,
  orderStruct,
  signature
)
return
boolean
True if order is from native asset

Build docs developers (and LLMs) love