Might you wonder, "Why aim to shorten transaction durations?" Various compelling reasons support this strategy. For those accustomed to traditional trading, the landscape offers several order durations: day orders, good 'til canceled, and immediate or cancel (IoC) orders, with IoC orders being notably prevalent. They permit traders to place an order at a specific price for immediate execution or cancellation, facilitating swift shifts to alternate strategies if the initial attempt falters. While day orders serve value traders seeking precise price points, IoC orders are the go-to for traders engaged in high-frequency and arbitrage trading, prioritizing speed and adaptability.
Solana introduces a nuanced twist: a transaction, once submitted, can remain valid for up to 90 seconds. For an in-depth exploration of Solana's transaction mechanics, refer to Solana's transaction
documentation. It elucidates that a transaction's viability hinges on the validity of the blockhash, with the potential for the transaction to circulate among nodes until it is either incorporated into a block or the blockhash expires.
This mechanism unveils two methods for implementing IoC-like orders on Solana. Firstly, selecting slightly older blockhashes allows for control over the transaction's potential lifespan by using a blockhash nearing its expiry (set to expire in about 79 seconds from the current time).
Secondly, configuring your RPC node to limit your request's forwarding to a single node is feasible by adjusting the maxRetries to 1, as detailed here: Solana RPC
documentation.
A third, more nuanced approach involves leveraging Solana's forwarding packets, a type of traffic typically forwarded only once. This method, though less direct and somewhat unconventional, presents an intriguing option for validator owners.
Another way of doing things could be using some instruction, which is routed to the program which cancels the transaction if current time is later than the time specified in the argument.
For further insights and assistance in Solana development or to access Solana market data, visit our team's websites at Web3 Engineering's
Solana Development and
Solana Market Data.