There is an issue (particularly when the bot accounts have little bank balance available) where it is possible for the bots to run out of tokens to use to swap, when this happens and the target price keeps moving, the "rebalancing" assumes that the pair is well-arbitraged (ie. ticks on either side of the desired price are of different tokens) and will withdraw almost all of the remaining ticks one the side leading to a severe imbalance of tokens on one side.
I'm not sure how the bots actually "run out of tokens" on one side, if they aren't deposited in Dex ticks then surely they are now in the bot's bank accounts and can be used to swap with. It is possible that a different error is being hit: Swap amount too small; creates unfair spread for liquidity providers is an error sometimes being seen when using FILL_OR_KILL type orders. The simulation uses IMMEDIATE_OR_CANCEL orders and never sees this error, but it does often get "success (code: 0)" txs where no ticks were swapped at all. Its possible that this is the manifestation of that error in the IMMEDIATE_OR_CANCEL order type, and the simulation is becoming one-sided because it has hit a configuration of ticks that gives this error and it cannot swap past it.
the simulation below (video sped up) shows the simulation with the following command:
make start-trade-bot BOTS=3 TRADE_DURATION_SECONDS=7200 \
FAUCET_MNEMONIC="banner spread envelope side kite person disagree path silver will brother under couch edit food venture squirrel civil budget number acquire point work mass" \
TOKEN_CONFIG='{"1000000000000uibcatom<>10000000000000uibcusdc":{"price":0.1,"period1":3600,"gas":"1000000000untrn"}}'
In this video:
the green line is the price calculated from the liquidity
the white line is the price as returned by the indexed (last swap price)
the red line is the target price of the simulation
Note that the swaps appear to work fine in one direction (right to left), but struggle in the other direction.
There is an issue (particularly when the bot accounts have little bank balance available) where it is possible for the bots to run out of tokens to use to swap, when this happens and the target price keeps moving, the "rebalancing" assumes that the pair is well-arbitraged (ie. ticks on either side of the desired price are of different tokens) and will withdraw almost all of the remaining ticks one the side leading to a severe imbalance of tokens on one side.
I'm not sure how the bots actually "run out of tokens" on one side, if they aren't deposited in Dex ticks then surely they are now in the bot's bank accounts and can be used to swap with. It is possible that a different error is being hit:
Swap amount too small; creates unfair spread for liquidity providers
is an error sometimes being seen when usingFILL_OR_KILL
type orders. The simulation usesIMMEDIATE_OR_CANCEL
orders and never sees this error, but it does often get "success (code: 0)" txs where no ticks were swapped at all. Its possible that this is the manifestation of that error in theIMMEDIATE_OR_CANCEL
order type, and the simulation is becoming one-sided because it has hit a configuration of ticks that gives this error and it cannot swap past it.the simulation below (video sped up) shows the simulation with the following command:
In this video:
Note that the swaps appear to work fine in one direction (right to left), but struggle in the other direction.
https://github.com/neutron-org/dex-trading-bot/assets/6194521/b80c39b7-0df0-4234-8f1e-48f5be397c3f