User Defined Value Types
User Defined Value Types used in VirtuSwap DEX contracts
Last updated
User Defined Value Types used in VirtuSwap DEX contracts
Last updated
RouteData
is a value type, defined as uint256
. It is utilized to store compact information about trading route steps in the . The RouteData
type combines multiple pieces of route-related data into a single uint256
value for optimized on-chain processing.
The RouteData
encodes three pieces of information:
Transit Start Index is stored in the most significant 64 bits (bits 192-255). It indicates the index of the first intermediate token in the array of transit tokens addresses of the route.
Transit Length is stored in the next 64 bits (bits 128-191). It represents the number of intermediate tokens in the route step. If set to type(uint64).max
, it signifies a virtual swap (a case when a swap on the will be executed if it is not locked).
Amount is stored in the least significant 128 bits (bits 0-127). It is equal to the token amount involved in the route (amountIn
for exact in swaps or amountOut
for exact out swaps).
For direct swaps (through one real pool) the transit length is equal to 0
and transit tokens are ignored.