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.
Order information containing assets, amounts, and addresses Show OrderInfoData properties
Source token address on Solana. Use SolanaAddress.NATIVE for SOL
Destination chain token address
Solana wallet address of order creator
Amount to swap from Solana (u64 max)
Minimum amount to receive on destination chain (u256 max)
Receiver address on destination chain
escrowParams
SolanaEscrowParams
required
Escrow configuration parameters Show SolanaEscrowParams properties
Hash lock for atomic swap security
srcChainId
NetworkEnum.SOLANA
required
Source chain ID (must be Solana)
Safety deposit on Solana (u64 max)
Safety deposit on destination chain (u64 max)
Time lock configuration for escrow stages
Auction configuration Show SolanaDetails properties
Dutch auction configuration
Additional configuration options Show SolanaExtra properties
Order expiration delay in seconds after auction ends
resolverCancellationConfig
ResolverCancellationConfig
Configuration for resolver cancellation. Defaults to ResolverCancellationConfig.ALMOST_ZERO
Order source identifier. Not required if salt > UINT_32_MAX
Allow order to be filled multiple times
Random value in interval [0, UINT_32_MAX]. If salt > UINT_32_MAX, source won’t be injected
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: 1000000 n ,
minDstAmount: 900000 n ,
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
const order = SvmCrossChainOrder . fromContractOrder ( instructionData , auction )
SvmCrossChainOrder.fromJSON()
Deserialize an order from JSON.
JSON representation of the order
const order = SvmCrossChainOrder . fromJSON ( jsonData )
Order Properties
Order creator’s Solana wallet address
Source token address on Solana
Destination chain token address
Amount being swapped from Solana
Minimum amount expected on destination chain
Recipient address on destination chain
Timing
Auction start timestamp in seconds
Auction end timestamp in seconds
Order expiration timestamp in seconds (u32)
Security
Hash lock for atomic swap
Safety deposit on destination chain
Configuration
resolverCancellationConfig
ResolverCancellationConfig
Resolver cancellation settings
Whether source asset is native SOL
Whether partial fills are allowed (same as multipleFillsAllowed)
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 )
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 )
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
)
Escrow factory program ID
Address of the resolver who filled the order
Hash lock for the specific fill. Defaults to order’s root hash lock. Required for multiple fills
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
})
Escrow factory program ID
Address who filled the order
Token Program or Token Program 2022
Filled amount. Defaults to full order
Hash lock for the fill. Can be omitted if multipleFillsAllowed is false
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 )
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:
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.
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:
Specify SolanaAddress.NATIVE as the srcToken
The SDK automatically sets srcAssetIsNative: true
Internally, the order uses Wrapped SOL (WSOL) address
The escrow factory handles wrapping/unwrapping
const order = SvmCrossChainOrder . new (
{
srcToken: SolanaAddress . NATIVE , // Will use WSOL internally
dstToken: EvmAddress . fromString ( '0x...' ),
maker: makerAddress ,
srcAmount: 1000000000 n , // 1 SOL in lamports
minDstAmount: 3000000000000000000 n , // 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 (
1000 n , // 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