Skip to main content

Overview

The EvmCrossChainOrder class represents a cross-chain swap order originating from an EVM-compatible blockchain. It extends the BaseOrder class and encapsulates all order details including assets, amounts, escrow parameters, and auction configuration.

Creating an Order

EvmCrossChainOrder.new()

Create a new EVM cross-chain order.
escrowFactory
EvmAddress
required
Address of the escrow factory contract
orderInfo
EvmCrossChainOrderInfo
required
Order information containing assets, amounts, and addresses
escrowParams
EvmEscrowParams
required
Escrow configuration parameters
details
EvmDetails
required
Auction and fee details
extra
EvmExtra
Optional configuration
import { EvmCrossChainOrder, EvmAddress } from '@1inch/cross-chain-sdk'

const order = EvmCrossChainOrder.new(
  escrowFactory,
  {
    makerAsset: EvmAddress.fromString('0x...'),
    takerAsset: EvmAddress.fromString('0x...'),
    makingAmount: 1000000n,
    takingAmount: 900000n,
    maker: EvmAddress.fromString('0x...')
  },
  escrowParams,
  details
)

EvmCrossChainOrder.fromNative()

Create an order from a native asset (ETH, MATIC, etc.).
Native orders must be submitted on-chain through NativeOrderFactory.create AND off-chain through the relayer.
chainId
number
required
Source chain ID
ethOrdersFactory
ProxyFactory
required
Native order factory instance
escrowFactory
EvmAddress
required
Escrow factory address
orderInfo
Omit<EvmCrossChainOrderInfo, 'makerAsset'>
required
Order info without makerAsset (automatically set to wrapped native token)
details
EvmDetails
required
Auction and fee details
escrowParams
EvmEscrowParams
required
Escrow parameters
extra
EvmExtra
Optional configuration

EvmCrossChainOrder.fromDataAndExtension()

Reconstitute an order from its on-chain representation.
order
LimitOrderV4Struct
required
On-chain order structure
extension
Extension
required
Order extension data

Order Properties

Basic Information

maker
EvmAddress
Order creator’s address
makerAsset
EvmAddress
Source chain token address
takerAsset
AddressLike
Destination chain token address
makingAmount
bigint
Amount being swapped from source chain
takingAmount
bigint
Minimum amount expected on destination chain
receiver
AddressLike
Recipient address on destination chain (defaults to maker if not set)

Timing

auctionStartTime
bigint
Auction start timestamp in seconds
auctionEndTime
bigint
Auction end timestamp in seconds
deadline
bigint
Order expiration timestamp in seconds

Security

hashLock
HashLock
Hash lock for atomic swap
timeLocks
TimeLocks
Time lock configuration
srcSafetyDeposit
bigint
Safety deposit on source chain
dstSafetyDeposit
bigint
Safety deposit on destination chain

Configuration

dstChainId
SupportedChain
Destination chain ID
salt
bigint
Random salt value
nonce
bigint
Order nonce
partialFillAllowed
boolean
Whether partial fills are allowed
multipleFillsAllowed
boolean
Whether multiple fills are allowed

Methods

build()

Build the order into its on-chain struct format.
const orderStruct = order.build()
Returns: LimitOrderV4Struct - On-chain order structure

getOrderHash()

Calculate the order hash.
const orderHash = order.getOrderHash(chainId)
srcChainId
number
required
Source chain ID
Returns: string - Order hash as hex string

getTypedData()

Get EIP-712 typed data for signing.
const typedData = order.getTypedData(chainId)
srcChainId
number
required
Source chain ID
Returns: EIP712TypedData - Typed data for signing

getCalculator()

Get the auction calculator for this order.
const calculator = order.getCalculator()
Returns: AuctionCalculator - Auction calculator instance

isExclusiveResolver()

Check if a wallet is an exclusive resolver.
const isExclusive = order.isExclusiveResolver(wallet)
wallet
EvmAddress
required
Wallet address to check
Returns: boolean - True if wallet has exclusive rights

isExclusivityPeriod()

Check if currently in the exclusivity period.
const isExclusive = order.isExclusivityPeriod(timestamp)
time
bigint
required
Timestamp to check (in seconds)
Returns: boolean - True if in exclusivity period

canExecuteAt()

Check if an executor can fill the order at a given time.
const canExecute = order.canExecuteAt(executor, executionTime)
executor
EvmAddress
required
Executor address
executionTime
bigint
required
Execution timestamp in seconds
Returns: boolean - True if executor is allowed

getResolverFee()

Calculate the resolver fee.
const fee = order.getResolverFee(taker, time, blockBaseFee, makingAmount)
taker
EvmAddress
required
Resolver address
time
bigint
required
Execution timestamp in seconds
blockBaseFee
bigint
default:"0n"
Block base fee in wei
makingAmount
bigint
Amount to fill (defaults to full order)
Returns: bigint - Resolver fee amount

getIntegratorFee()

Calculate the integrator fee.
const fee = order.getIntegratorFee(taker, time, blockBaseFee, makingAmount)
taker
EvmAddress
required
Resolver address
time
bigint
required
Execution timestamp in seconds
blockBaseFee
bigint
default:"0n"
Block base fee in wei
makingAmount
bigint
Amount to fill (defaults to full order)
Returns: bigint - Integrator fee amount

isNative()

Check if order is a native token order.
const isNative = order.isNative(chainId, ethOrderFactory, signature)
chainId
number
required
Chain ID
ethOrderFactory
ProxyFactory
required
Native order factory instance
signature
string
required
Order signature
Returns: boolean - True if native order

nativeSignature()

Get the signature for submitting native order on-chain.
Only valid if order was created with fromNative() method.
const signature = order.nativeSignature(maker)
maker
EvmAddress
required
Maker address
Returns: string - Signature for on-chain submission

Example Usage

import { 
  CrossChainSDK,
  EvmCrossChainOrder,
  EvmAddress,
  HashLock,
  TimeLocks,
  AuctionDetails,
  Whitelist
} from '@1inch/cross-chain-sdk'

// Initialize SDK
const sdk = new CrossChainSDK({
  wallet: privateKey,
  srcChainId: 1,
  dstChainId: 42161
})

// Get a quote
const quote = await sdk.getQuote({
  srcTokenAddress: '0x...',
  dstTokenAddress: '0x...',
  amount: '1000000'
})

// Create order from quote
const order = await sdk.createOrder(quote)

// Access order properties
console.log('Maker:', order.maker.toString())
console.log('Making Amount:', order.makingAmount)
console.log('Taking Amount:', order.takingAmount)
console.log('Deadline:', order.deadline)

// Check execution eligibility
const canExecute = order.canExecuteAt(
  resolverAddress,
  BigInt(Math.floor(Date.now() / 1000))
)

// Calculate fees
const resolverFee = order.getResolverFee(
  resolverAddress,
  BigInt(Math.floor(Date.now() / 1000))
)

See Also

Build docs developers (and LLMs) love