🔶Swap threshold ratio
Learn how the swap threshold ratio works for ERC-20 tokens created on 20lab.

What is Swap Threshold Ratio?
The swap threshold ratio in tokens created on 20lab.app represents the percentage of available liquidity on the main DEX pair that must be collected from taxes before the token smart contract can swap these accumulated fees and send them to the appropriate locations.
When Does It Apply?
The swap threshold ratio is effective when you select one or more of the following tax types:
Wallet taxes sent in native coins (e.g., BNB) or custom tokens (e.g., USDT)
Liquidity tax
Dividend tax
How It Works
Step 1: Tax Collection
When the above taxes are charged (on buys, sells, and/or transfers), they are first sent to the token's smart contract balance, which you can see in the Block Explorer.

Important: Tokens transferred directly to the token smart contract (e.g., using the transfer() function) don't count towards the swap threshold.
Step 2: Threshold Check
Once the amount of tokens in the token's smart contract balance exceeds the swap threshold, the taxes will be swapped. The swapping process takes the appropriate amounts from the token's smart contract balance and uses your main liquidity pool on your default exchange to swap and send the taxes where they should go.
Why Use a Threshold?
There are two important reasons for this delay:
1. Gas Efficiency
This saves users money on gas fees. If swaps occurred with every transaction, the gas cost for the swap could be greater than the actual value of the taxes, essentially burning users' money.
2. Technical Limitation
Buy transactions cannot trigger swaps - this is a DEX limitation that cannot be changed on the token smart contract side. The token smart contract must wait for a sell or transfer transaction to trigger the swap.
Recommended Setting
The automatic and safest value for the swap threshold ratio is 0.5% of available liquidity.
Practical Example
Let's see how this works with a real example:
Initial Setup
Your liquidity pool: 500,000 tokens + 5 BNB
Your swap threshold ratio: 0.5%
Your swap threshold: 500,000 × 0.5% = 2,500 tokens
Liquidity tax rates: 2% (buys), 2% (sells), 0% (transfers)
Dividend tax rates: 2% (buys), 2% (sells), 0% (transfers)
How It Works in Practice
With this configuration, your swap threshold is 2,500 tokens. This value will change every time someone buys or sells your token, but it will scale proportionally to the available liquidity.
Current situation: 2,000 tokens already collected from taxes and sitting in the token smart contract.
Scenario 1: Buy Transaction
If the next transaction is a buy of 50,000 tokens:
2,000 tokens will be collected from that transaction (4% total tax rate)
No swaps will be triggered because buy transactions can't trigger swaps
Total accumulated tokens: 4,000 tokens
Scenario 2: Sell Transaction
If the next transaction is a sell of 50,000 tokens:
2,000 tokens are first collected and transferred to the token contract
Total accumulated tokens: 4,000 tokens (exceeds the 2,500 threshold)
Swaps are triggered in the same transaction:
2,000 tokens used for liquidity tax
2,000 tokens used for dividend tax
After completion: No or almost no tokens left in the token smart contract balance
Next Cycle
The next collection cycle will then begin to accumulate the required number of tokens for the next swap.
Key Points to Remember
Threshold scales with your liquidity pool size
Only sell and transfer transactions can trigger swaps
Buy transactions only collect taxes but cannot trigger swaps
The system is designed to save gas costs for your token holders
Swaps happen automatically when the threshold is reached
Last updated
Was this helpful?