Now that you have properly installed, tested, and configured Gateway, it's time to run a bot that calls the Gateway DEX endpoints.
You can either run the AMM-Arbitrage Strategy, or the sample Scripts that utilize Gateway if you want more fine-grained control.
Approval needed!
Currently, if any tokens do not have sufficient allowance, both strategies and scripts will not start and the logs will show messages like [connector] is not ready. Please wait... continually. See Approving tokens for information on how to approve tokens.
Use the start command, and then answer Yes when asked to confirm the strategy settings.
After starting the amm_arb strategy, you’ll see the apparent prices on the AMM market will track the prices on the CEX exchange, and if there is none, the strategy will report no arbitrage opportunities.
When it detects an arbitrage opportunity where the total cost to execute the transactions (including gas and fees) still results in a profit higher than (min_profitability), then the bot will automatically execute the two transactions.
If concurrent_orders_submission is false, then the bot will try to execute and confirm the transaction on connector_1 before executing the transaction on connector_2.
On testnets like Goerli, prices are typically out of line with CEXs, so getting transactions executed is trivial. However, when testing on mainnets, triggering an arbitrage transaction may be trickier.
One option is to set the min_profitability to be negative, but that may result in losses when testing on mainnet. Therefore, we have added a debug_price_shim feature that lets you modify the apparent prices on the AMM market in the Debug Console and trigger mock arbitrage transactions.
To use this feature, set debug_price_shim to True in your amm-arb configuration, either by modifying the config file or running the config command:
>>>configdebug_price_shimTrue
Let’s say you want to raise the WETH prices on the AMM connector by 40 USDT, in order to trigger a sell on the AMM connector and a buy on the CEX connector.
The code snippet below will cause amm_arb to send sell transactions to Uniswap Goerli and simulated buys on Binance paper trade market. The price delta will persist in the AMM market for 1 minute. Afterwards, it’ll return back to tracking the CEX paper trade market.
Conversely, if you want to trigger buys on the AMM side and sells on the CEX paper trade side, you can give negative delta prices to make WETH-DAI on the AMM side cheaper.
Again, the negative delta price will persist on the AMM market for 1 minute.
If the price delta isn’t enough to trigger an arb opportunity due to high gas fees, feel free to use large delta values, e.g. Decimal(200) or even Decimal(500). While the price deltas needed seem unrealistically large - this is reflective of real trading constraints because a small order size would need a large price delta to cover the gas fees.