# Executors

Stabilize protocol operates using a decentralized network of executors to interact with the strategy contract when arbitrage opportunities present themselves. These Executors are pivotal within the ecosystem of Stabilize, since they ensure a decentralized and redundant execution of trades.

#### Medium post:

{% embed url="<https://stabilize.medium.com/the-stabilize-protocol-is-a-decentralized-finance-application-designed-to-help-keep-stablecoins-c6f0b9b7c09f>" %}

#### Can anyone be an Executor?&#x20;

In theory yes, anyone can "execute" the smart contract function executeSwapTokens to make the transaction happen, also manually. If the trade is not profitable it will not be executed, the strategies can\`t loose due to Executors doing it "wrong" . Executors are getting a fair reward for executing the transaction.

#### How to set up an Executor bot

The easiest way to start is to develop an off-chain bot that monitors the strategy continuously. You can also use services like Keeper for this purpose. This bot would query the expectedProfit function which returns wei units (10¹⁸ wei = 1 USD / BTC), calculate its own expected profit (10% of the expected profit) then calculate the gas cost based on current gas prices. If the profit is greater than the gas costs, the bot would create a transaction to executeSwapTokens with its own address as the parameter to receive its percent of profit. The bot may also set a minimum seconds since the last trade to limit its gas cost in case someone else beats it to the trade.

Ideally, the executor will make continuous profit, trading depositors funds at the right times and depositors will make the best compound interest possible as their funds are traded at the most profitable times. It is important to note that the contract itself doesn’t allow for trading at a loss.

Trade executors can earn a certain profit cut off each trade by timing the trade at the right time (depending on the strategy the % differs) . The expectedProfit (bool inWETHForExecutor) function includes a boolean that allows executors to see their WETH profit from the next prospective trade, instead of total profit (in tokens) for the trade.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://s-and-s.gitbook.io/stabilize/main-body/executors.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
