Hello!
We need to automatically reallocate liquidity in the pool when the price goes out of range.
ETH-USDT Pool
https://traderjoexyz.com/arbitrum/pool
The logic is simple:
1. If there is no liquidity from us in the pool, we add liquidity in the range.
2. If our added liquidity is out of range, we reallocate it to a new range.
Reallocation:
2.1. We withdraw all ETH and USDT liquidity from the pool.
2.2. We check the balances of available ETH and USDT tokens in the wallet (web3 lib)
2.3. We add liquidity in the new range based on the token balances and their desired distribution.
(in the current active bar of the pool, we can add ETH and USDT, in the bars to the right of the current one only ETH, in the bars to the left only USDT)
Examples of interaction with the pool:
https://docs.traderjoexyz.com/SDK/removeLiquidity
https://docs.traderjoexyz.com/SDK/addLiquidity
If this can be done entirely using the web3 library in Python or Node, that works too.
Best regards,
Andrey