Certain actions require waiting 128 blocks for confirmation before additional actions are allowed. Here we discuss the reason for this delay as well as the instances in which it will occur.
The IDEX design uses an off-chain order book and matching engine to provide users with a fast and responsive trading experience.
Before users are credited with balances for trading in this off-chain system, they must move their funds on-chain into the IDEX smart contract. This guarantees that the credited funds will be available for settlement after any trades are executed off-chain.
The Polygon network requires 128 blocks before finality is reached. This means that until 128 blocks have passed, the IDEX matching engine cannot guarantee that deposit transactions are valid.
If IDEX credits a user off-chain before finality, it is possible for this deposit to be dropped. Any attempt by the user to trade these funds, which are no longer deposited in the smart contract, would lead to trade settlement failures and errors.
Confirmation Delay - Examples
The following are instances in which user’s will encounter the 128 block delay (~4-5 minutes at current block time):
Depositing funds for trading - users must wait before these funds are credited for trading in the off-chain system.
Adding liquidity to liquidity pools directly from your wallet
Users have the option of adding to liquidity pools using funds in their wallet (not already deposited to IDEX)
In this instance, users must wait five minutes before the liquidity addition is confirmed, and the user receives their LP tokens
Note: it is possible that the liquidity pool pricing changes during this block delay, and the slippage tolerance cause the liquidity addition to revert
In this instance, the funds will stay within the IDEX smart contract (as part of “My IDEX Balance”)
Users can re-submit the liquidity addition, which will be processed instantly, as the funds have already been deposited and passed the block delay
To avoid this, users can first deposit to IDEX and wait for confirmation prior to adding liquidity
Removing liquidity from liquidity pools with LP tokens that are in your wallet
Users can remove liquidity from liquidity pools using their existing LP tokens; these LP tokens will most often be held in the user’s wallet (or in a farm contract)
The liquidity removal function first deposits the LP tokens; after the block delay (guaranteeing that the LP token deposit won’t be reverted), the liquidity is released from the pool
Note: it is possible that the liquidity pool pricing changes during this block delay, and the slippage tolerance cause the liquidity removal to revert
In this instance, the LP tokens will stay deposited in the IDEX smart contract (as part of “My IDEX Balance”)
Users can re-submit the liquidity removal, which will be processed instantly, as the LP tokens have already been deposited and passed the block delay