Refreshing Estimates
It is recommended that transactions returned by the create-tx
API be signed and submitted within 30 seconds. When response.tx
is submitted within this window, the likelihood of successful order execution exceeds 99.9%.
There is no explicit time-to-live (TTL) on the transaction itself—that is, the period between receiving the create-tx
API response and submitting it on-chain. Transactions may remain valid for extended periods, especially when no pre-order-swap is involved or when the pre-order-swap is between stablecoins.
Handling Operating Expense Fluctuations
When the prependOperatingExpenses
parameter is enabled, special attention must be paid to how token approval amounts are set. If the allowance exactly matches response.estimation.srcChainTokenIn.amount
and there is a delay—typically more than a minute—before submitting response.tx
, operating expenses may increase. In this case, the estimate should be refreshed. If the updated expense exceeds the approved amount, an additional approval step is required, degrading the experience.
To prevent this, it is recommended to set the token allowance to infinity. When a finite allowance is required, it is advisable to include a buffer—commonly around 30%—to absorb any increase in gas costs or execution fees between approval and submission.
const { approximateOperatingExpense } = response.estimation.srcChainTokenIn;
const approveAmount = srcChainTokenInAmount + approximateOperatingExpense * 1.3;
This ensures that the approved amount remains sufficient, even if costs rise slightly before the transaction is broadcast.
You can see the code examples here.
Last updated
Was this helpful?