Perpetual Position Auto-Close on Funding Threshold
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
This tool enables perpetual traders to set auto-close thresholds based on funding rates. In perpetual contracts, funding rates are periodic payments exchanged between long and short positions to keep the contract price aligned with the underlying asset. High funding rates can significantly impact profitability. This tool allows users to set a funding rate threshold — when the rate exceeds the threshold, the position is automatically closed to protect against excessive funding costs. It connects to your wallet and reads the perpetual contract address, position ID, funding rate, funding threshold, position size, collateral amount, market price, auto-close status, auto-close history, and timestamps. The tool signs and submits transactions to set auto-close on funding threshold, update threshold parameters, close positions automatically, record auto-close metadata, and emit auto-close events.
HOW TO USE
1. Connect your wallet using the wallet bridge (supports MetaMask, WalletConnect, and other EVM-compatible wallets).
2. Select the target network that matches your perpetual contract deployment.
3. Enter the perpetual contract address and the position ID, then click "load contract" to initialize the connection.
4. Click "fetch auto-close status" to retrieve the current funding rate, auto-close status, position size, collateral amount, and market price.
5. Review the current funding rate and auto-close status — if enabled, the position will close automatically when funding exceeds the threshold.
6. Enter the funding threshold in basis points (e.g., 50 = 0.5%).
7. Click "validate auto-close" to verify that the threshold is valid and within acceptable limits.
8. Click "check auto-close history" to view past auto-close events for this position.
9. Review the funding rate, threshold, and auto-close status before executing.
10. Click "set auto-close" to enable auto-close with the specified threshold, or "disable auto-close" to turn it off.
TECHNICAL MECHANISM
The tool uses ethers.js v5.7.2 to interact with any EVM-compatible perpetual contract that implements a standard auto-close interface (getFundingRate(uint256) view returns (uint256), getAutoCloseStatus(uint256) view returns (bool), getPosition(uint256) view returns (uint256, uint256, uint256), setAutoClose(uint256, uint256) external, disableAutoClose(uint256) external, getAutoCloseHistory(uint256) view). The setAutoClose function sets the funding rate threshold for the position. When the current funding rate exceeds this threshold (in absolute value), the contract automatically closes the position, protecting the user from excessive funding costs. The getFundingRate view returns the current funding rate for the position, allowing users to monitor rates in real-time. The contract maintains a history of auto-close settings and triggers, storing timestamps, thresholds, and trigger events for audit purposes. Transaction handling follows EIP-1559 gas price calculations using receipt.effectiveGasPrice for accurate cost reporting. Auto-close metadata is recorded both in the contract's history and locally for the user's reference.
WHAT IT CANNOT SEE
This tool operates purely on-chain and cannot verify off-chain funding rate accuracy — it does not check whether the funding rate is calculated correctly or based on accurate data. It cannot predict funding rate movements — the tool cannot forecast whether the funding rate will exceed the threshold. It cannot ensure optimal threshold setting — the tool does not provide guidance on what threshold is appropriate for the user's risk tolerance. It cannot detect funding rate manipulation — the tool cannot identify attempts to manipulate the funding rate. The tool also cannot guarantee that auto-close prevents losses — while auto-close protects against funding costs, it does not protect against price movements or other risks.
PLEASE NOTE
This tool works exclusively with EVM-compatible blockchain networks (Ethereum, Polygon, Arbitrum, Optimism, Base, etc.). It requires the perpetual contract to implement the auto-close interface described above. All transactions incur gas fees paid by the connected wallet. The tool maintains no persistent storage — all state is refreshed from the blockchain on each session. Setting an auto-close threshold is an important risk management decision — ensure you understand the funding rate dynamics and choose a threshold that aligns with your risk tolerance. Consider the frequency of funding rate payments and your position size when setting the threshold. Always verify the current funding rate and auto-close status after configuration to ensure it is working as expected.