Skip to main content

Overview

The SvmCrossChainOrder class represents a cross-chain swap order originating from Solana (SVM - Solana Virtual Machine). It extends the BaseOrder class and handles Solana-specific order creation, serialization, and on-chain account derivation.
Solana orders have a two-step process: first announce the order on-chain, then submit it to the relayer for matching.

Creating an Order

SvmCrossChainOrder.new()

Create a new Solana cross-chain order.
orderInfo
OrderInfoData
required
Order information containing assets, amounts, and addresses
escrowParams
SolanaEscrowParams
required
Escrow configuration parameters
details
SolanaDetails
required
Auction configuration
extra
Omit<SolanaExtra, 'srcAssetIsNative'>
required
Additional configuration options
import { SvmCrossChainOrder, SolanaAddress, EvmAddress } from '@1inch/cross-chain-sdk'

const order = SvmCrossChainOrder.new(
  {
    srcToken: SolanaAddress.fromString('So11111111111111111111111111111111111111112'),
    dstToken: EvmAddress.fromString('0x...'),
    maker: SolanaAddress.fromString('...'),
    srcAmount: 1000000n,
    minDstAmount: 900000n,
    receiver: EvmAddress.fromString('0x...')
  },
  escrowParams,
  details,
  {}
)

SvmCrossChainOrder.fromContractOrder()

Reconstitute an order from on-chain instruction data.
data
ParsedCreateInstructionData
required
Parsed create instruction data from blockchain
auction
AuctionDetails
required
Auction configuration
const order = SvmCrossChainOrder.fromContractOrder(instructionData, auction)

SvmCrossChainOrder.fromJSON()

Deserialize an order from JSON.
data
SolanaOrderJSON
required
JSON representation of the order
const order = SvmCrossChainOrder.fromJSON(jsonData)

Order Properties

Basic Information

maker
SolanaAddress
Order creator’s Solana wallet address
makerAsset
SolanaAddress
Source token address on Solana
takerAsset
EvmAddress
Destination chain token address
makingAmount
bigint
Amount being swapped from Solana
takingAmount
bigint
Minimum amount expected on destination chain
receiver
EvmAddress
Recipient address on destination chain

Timing

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

Security

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

Configuration

dstChainId
SupportedChain
Destination chain ID
salt
bigint
Random salt value (u64)
auction
AuctionDetails
Auction configuration
resolverCancellationConfig
ResolverCancellationConfig
Resolver cancellation settings
srcAssetIsNative
boolean
Whether source asset is native SOL
source
string
Order source identifier
partialFillAllowed
boolean
Whether partial fills are allowed (same as multipleFillsAllowed)
multipleFillsAllowed
boolean
Whether multiple fills are allowed

Methods

toJSON()

Serialize the order to JSON format.
const json = order.toJSON()
Returns: SolanaOrderJSON - JSON representation of the order

getOrderHash()

Calculate the order hash.
const orderHash = order.getOrderHash(chainId)
srcChainId
number
required
Source chain ID (ignored for Solana, included for interface compatibility)
Returns: string - Order hash in base58 encoding

getOrderHashBuffer()

Get the order hash as a buffer.
const hashBuffer = order.getOrderHashBuffer()
Returns: Buffer - Order hash as buffer

getOrderAccount()

Derive the on-chain order account address.
const orderAccount = order.getOrderAccount(programId)
programId
SolanaAddress
required
Escrow factory program ID
Returns: SolanaAddress - Order account PDA (Program Derived Address)

getSrcEscrowAddress()

Derive the escrow account address for a fill.
const escrowAddress = order.getSrcEscrowAddress(
  programId,
  taker,
  hashLock,
  fillAmount
)
programId
SolanaAddress
required
Escrow factory program ID
taker
SolanaAddress
required
Address of the resolver who filled the order
hashLock
HashLock
Hash lock for the specific fill. Defaults to order’s root hash lock. Required for multiple fills
fillAmount
bigint
Amount being filled. Defaults to full order amount
Returns: SolanaAddress - Escrow PDA that owns the filled funds

getSrcEscrowATA()

Get the Associated Token Account where funds are stored after fill.
const escrowATA = order.getSrcEscrowATA({
  programId,
  taker,
  tokenProgramId,
  fillAmount,
  hashLock
})
params
object
required
Returns: SolanaAddress - Associated Token Account address

getCalculator()

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

getOrderHashBuffer() (static)

Calculate order hash from parameters.
const hash = SvmCrossChainOrder.getOrderHashBuffer(params)
params
OrderHashParams
required
Order parameters for hash calculation
Returns: Buffer - Order hash buffer

Solana-Specific Concepts

Order Announcement vs Submission

Unlike EVM chains where orders can be submitted directly off-chain, Solana orders follow a two-step process:
  1. On-chain Announcement: The order must first be created on-chain through a Solana transaction to the escrow factory program. This creates the order account PDA.
  2. Relayer Submission: After on-chain confirmation, the order details are submitted to the 1inch relayer network for matching with resolvers.
// Step 1: Create order on-chain
const orderAccount = order.getOrderAccount(programId)
const tx = await escrowFactory.createOrder(order, orderAccount)
await connection.confirmTransaction(tx)

// Step 2: Submit to relayer
const submission = await sdk.submitOrder(order)

Program Derived Addresses (PDAs)

Solana uses PDAs for deterministic account addresses. The SDK provides methods to derive these addresses:
  • Order Account: Stores the order metadata on-chain
  • Escrow Account: Holds the maker’s funds after fill
  • Escrow ATA: The actual token account where funds are stored

Native SOL Handling

When swapping native SOL:
  1. Specify SolanaAddress.NATIVE as the srcToken
  2. The SDK automatically sets srcAssetIsNative: true
  3. Internally, the order uses Wrapped SOL (WSOL) address
  4. The escrow factory handles wrapping/unwrapping
const order = SvmCrossChainOrder.new(
  {
    srcToken: SolanaAddress.NATIVE, // Will use WSOL internally
    dstToken: EvmAddress.fromString('0x...'),
    maker: makerAddress,
    srcAmount: 1000000000n, // 1 SOL in lamports
    minDstAmount: 3000000000000000000n, // 3 tokens
    receiver: receiverAddress
  },
  escrowParams,
  details,
  {}
)

console.log(order.srcAssetIsNative) // true
console.log(order.makerAsset.toString()) // Wrapped SOL address

Resolver Cancellation

Solana orders support resolver-initiated cancellation with a premium:
import { ResolverCancellationConfig } from '@1inch/cross-chain-sdk'

// Disable cancellation
const noCancellation = ResolverCancellationConfig.disableResolverCancellation()

// Enable with almost zero premium (recommended)
const almostZero = ResolverCancellationConfig.ALMOST_ZERO

// Custom configuration
const customConfig = new ResolverCancellationConfig(
  1000n, // maxCancellationPremium (in basis points * 1000)
  3600   // cancellationAuctionDuration (in seconds)
)

Example Usage

import { 
  CrossChainSDK,
  SvmCrossChainOrder,
  SolanaAddress,
  EvmAddress,
  NetworkEnum
} from '@1inch/cross-chain-sdk'
import { Connection, Keypair } from '@solana/web3.js'

// Initialize SDK for Solana
const sdk = new CrossChainSDK({
  wallet: keypair,
  srcChainId: NetworkEnum.SOLANA,
  dstChainId: 1 // Ethereum
})

// Get a quote
const quote = await sdk.getQuote({
  srcTokenAddress: 'So11111111111111111111111111111111111111112', // SOL
  dstTokenAddress: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', // USDC
  amount: '1000000000' // 1 SOL
})

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

// Get order account address
const programId = SolanaAddress.fromString('...')
const orderAccount = order.getOrderAccount(programId)
console.log('Order Account:', orderAccount.toString())

// Announce order on-chain
const tx = await sdk.announceOrder(order)
console.log('Order announced:', tx)

// Submit to relayer
const submission = await sdk.submitOrder(order)
console.log('Order submitted:', submission.orderHash)

// Later, derive escrow addresses for a fill
const escrowAddress = order.getSrcEscrowAddress(
  programId,
  resolverAddress,
  hashLock,
  fillAmount
)

const escrowATA = order.getSrcEscrowATA({
  programId,
  taker: resolverAddress,
  tokenProgramId: TOKEN_PROGRAM_ID,
  fillAmount,
  hashLock
})

console.log('Escrow:', escrowAddress.toString())
console.log('Escrow ATA:', escrowATA.toString())

Type Definitions

SolanaOrderJSON

type SolanaOrderJSON = {
  orderInfo: {
    srcToken: string      // base58 Solana address
    dstToken: string      // hex EVM address
    maker: string         // base58 Solana address
    srcAmount: string     // u64 bigint as string
    minDstAmount: string  // u256 bigint as string
    receiver: string      // hex EVM address
  }
  escrowParams: {
    hashLock: string          // 32-byte hex string
    srcChainId: NetworkEnum.SOLANA
    dstChainId: number
    srcSafetyDeposit: string  // u64 bigint as string
    dstSafetyDeposit: string  // u64 bigint as string
    timeLocks: string         // u256 bigint as string
  }
  details: {
    auction: {
      startTime: string
      duration: string
      initialRateBump: number
      points: AuctionPoint[]
    }
  }
  extra: {
    srcAssetIsNative: boolean
    orderExpirationDelay: string
    resolverCancellationConfig: {
      maxCancellationPremium: string
      cancellationAuctionDuration: number
    }
    source?: string
    allowMultipleFills: boolean
    salt: string
  }
}

See Also

Build docs developers (and LLMs) love