# Request for SUAPP: SUAVE On-Chain Searcher Bot

**URL:** https://collective.flashbots.net/t/request-for-suapp-suave-on-chain-searcher-bot/3198
**Category:** SUAVE
**Tags:** request-for-suapp
**Created:** [March 14, 2024, 10:22am UTC](https://collective.flashbots.net/t/request-for-suapp-suave-on-chain-searcher-bot/3198 "2024-03-14T10:22:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![bert](https://collective.flashbots.net/user_avatar/collective.flashbots.net/bert/32/1850_2.png) [@bert](https://collective.flashbots.net/u/bert)
#### Post date: [March 14, 2024, 10:22am UTC](https://collective.flashbots.net/t/request-for-suapp-suave-on-chain-searcher-bot/3198/1 "2024-03-14T10:22:05Z")

</div>

**Request for SUAPP**  
I would love to see a SUAPP which is a searcher programmed in solidity. Basically, it would be a smart contract that owns a private key in the confidential data storage that corresponds to an EOA on Ethereum. Then, you could design a smart contract which pulled ETHL1 data and used that to size profitable arbitrage trades. Finally, you could create an ETH L1 tx with your EOA that executed these trades - potentially with a flashloan so that there are limited funds needed.

This is definitely a challenging SUAPP, but one that is possible and pretty interesting!

**Complications**  
There are a few things that are hard about this.

_When and where it is executed_  
Right now the programming model would require that this smart contract is called by a SUAVE transaction. It would be best if this is executed at the bottom of built blocks, or after a private transaction.

_What arbs to look for_  
You need some notion of what arbs to look for, e.g. to check for arbs between certain pools. Choosing this state is not trivial. A few possibilities:

- Checking for popular pools like ETH/USD
- Using hints that leak touched pools
- Having pools fed in some other way

_How the arb is calculated_  
Finally, we need some way of calculating an arb. A simple, generalized way to do this would be doing binary search and taking the most profitable trade if any exists.

---

<div class="post-metadata">

### Author: ![halo3mic](https://collective.flashbots.net/letter_avatar_proxy/v4/letter/h/77aa72/32.png) [@halo3mic](https://collective.flashbots.net/u/halo3mic)
#### Post date: [March 20, 2024, 1:59am UTC](https://collective.flashbots.net/t/request-for-suapp-suave-on-chain-searcher-bot/3198/2 "2024-03-20T01:59:02Z")

</div>

I think this is a cool idea!

# Rationale

From the builder’s perspective, allowing searchers to backrun the block increases its value, so if they don’t do it, someone else will win the PBS auction (given that the extracted value is great enough). This comes with a concern that to do this; they have to share information about the block being built with the searchers. The least revealing solution I can think of is sharing the state changes of the built block. I am not sure how bad revealing slot changes actually is in practice, especially if the builder is transparent about it and users can take this into account, but I hear it is still a concern.

The SUAVE builder doesn’t have to reveal any information about the built block in order for searchers to backrun. In this case the searchers would be contracts called by the builder and the strategy can even remain anonymous if SUAVE can ensure no information can be leaked through the searching process.

# SUAVE Block Backrunner POC with YakSwap

Almost three years ago, I built YakSwap, an aggregator that lives fully in the EVM. It is live today at [https://yieldyak.com/swap](https://yieldyak.com/swap) and you can learn more about its usage at [https://www.yieldyak-analytics.com/yakswap](https://www.yieldyak-analytics.com/yakswap). Code can be found [here](https://github.com/yieldyak/yak-aggregator). It supports most dexes including tick based ones (UniV3, TraderJoeV2…).

## YakSwap and arbitrage

While YakSwap was designed to find the best path for their trades some users used it to find and executed atomic arbitrage opportunities that more advanced bots missed.

- [Here is an example of YakSwap arb tx with ~$4000 profit](https://snowtrace.io/tx/0x83bf4f984fdb9ba3446696ea03c8f3f1cc59ac68c5c974cf521892f338e3443c).
- $250k was extracted via YakSwap in May 2022
- For more historical arbs or other info check out [this Colab notebook](https://colab.research.google.com/drive/1ZlquVwN1uSi8D65NE2GDOHL6JycMTKOL?usp=sharing).

## YakSwap SUAVE block backrunning

Although, YakSwap cannot compete with optimized arbitrage setups the record shows it can nevertheless extract significant profits. Since its pathfinding logic lives fully onchain it is uniquely positioned to be a useful tool to extract atomic arbitrage at the end of the block on SUAVE.

YakSwap router and its adapters would need to be deployed on the settlement chain and then any SUAVE contract can call it to find arb.  
In order to find opportunities at the end of a built block either state changes would need to be extracted from the built block and then passed into eth\_call via [state-override-set](https://geth.ethereum.org/docs/interacting-with-geth/rpc/ns-eth) or SUAVE execution client would need to provide a way to access block building session after block is built.

## Practical considerations

- Finding the best path for given amountIn, tokenIn and tokenOut with YakSwap can be quite slow depending on the computational intensity of dex logic and the amount of hop tokens and adapters. Restricting these parameters could cause missed opportunities.
- Multiple calls are required to find optimal amountIn which further increases the latency.
- I do believe there is a lot of potential optimizations to shave off latency, but it makes me wonder if it can be enough to compete with another block builder that will auction this off-chain by revealing storage slots or smth similar.

Would def love to discuss this further!
