Swap Direction
Understanding X→Y vs Y→X swaps in DLMM. Token ordering determines swap direction and affects how you interact with pairs.
Token Ordering in DLMM
In every pair:
Token X: The token with the smaller address (sorted)
Token Y: The token with the larger address
This ordering is permanent and automatic
// Example ordering
TokenX: "0x2::sui::SUI" // Smaller address
TokenY: "0xabc...::usdc::USDC" // Larger address
// SUI is always X, USDC is always Y in this pairUnderstanding Swap Directions
X→Y Swap (xtoy = true)
Selling Token X
Buying Token Y
Price moves UP (more Y per X)
Y→X Swap (xtoy = false)
Selling Token Y
Buying Token X
Price moves DOWN (less Y per X)
Checking Token Order
Common Patterns
Swap by Token Type
User-Friendly Wrapper
Price Movement
Quick Reference
Want to
Token In
Token Out
Use
Buy SUI
USDC (Y)
SUI (X)
xtoy: false
Sell SUI
SUI (X)
USDC (Y)
xtoy: true
Buy USDC
SUI (X)
USDC (Y)
xtoy: true
Sell USDC
USDC (Y)
SUI (X)
xtoy: false
Common Mistakes
Related Topics
Execute Swap - Perform swaps
Get Single Pair - Check token order
Calculate Swap Output - Preview results
Last updated