Disable MetaMask Popups for Auto Stop Loss/Take Profit Closures in ethers.js dApp

Description:

I’m building a trading dApp where users can open futures positions with Stop Loss (SL) and Take Profit (TP) levels. When the price reaches SL or TP, the trade should close automatically.

However, in my current implementation, when SL/TP is hit, MetaMask automatically opens a confirmation popup. The trade only closes after the user clicks “Confirm.”

Expected behavior:
SL/TP auto-close should happen without any MetaMask popup and without user confirmation. Only manual trade closure should require MetaMask.

I want guidance on the correct approach:

  • Is MetaMask able to auto-confirm a transaction?

  • Should SL/TP auto-close be executed by a backend keeper/bot using its own wallet instead of the user’s MetaMask signer?

  • What is the recommended architecture for automatic executions in an ethers.js + MetaMask dApp?


Purpose:

To understand the correct pattern for implementing automated SL/TP trade closures without requiring MetaMask confirmation, and confirm if this must be handled by a backend keeper/bot instead of the user’s wallet.


Extension/Mobile/Both:

Browser Extension (main issue), but the behavior should be consistent across extension + mobile MetaMask.


Images/Attachments:

Hi, could you please create a post regarding this on our new Builder Hub https://builder.metamask.io/ as everything developer-related was moved there?
Thank you! :grinning_face: :hot_beverage:

1 Like