Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deposit index calculation #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat: log used deposit indexes during rebalancing
  • Loading branch information
dib542 committed May 2, 2024
commit a664a2e546af41eebc314bc8344e6fad5d2f17bb
16 changes: 9 additions & 7 deletions scripts/run_trade_bot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,12 @@ do
# rebalance: deposit ticks on one side to make up for the ticks that we withdraw from the other side
# determine new indexes close to the current price (within deposit accuracy, but not within swap accuracy)
echo "making deposit: '$tokenA' + '$tokenB'"
indexes="[$(
get_joined_array $tokenB_excess_user_deposits_count get_unique_integers_between $(( $current_price - $deposit_index_accuracy )) $(( $current_price - $swap_index_accuracy ))
),$(
get_joined_array $tokenA_excess_user_deposits_count get_unique_integers_between $(( $current_price + $swap_index_accuracy )) $(( $current_price + $deposit_index_accuracy ))
)]"
fees="$( get_joined_array $excess_user_deposits_count get_fee "$fees" )"
tx_response="$(
neutrond tx dex deposit \
`# receiver` \
Expand All @@ -455,19 +461,15 @@ do
repeat_with_comma "$tokenB_single_tick_deposit_amount" "$tokenA_excess_user_deposits_count"
)" \
`# list of tickIndexInToOut` \
"[$(
get_joined_array $tokenB_excess_user_deposits_count get_unique_integers_between $(( $current_price - $deposit_index_accuracy )) $(( $current_price - $swap_index_accuracy ))
),$(
get_joined_array $tokenA_excess_user_deposits_count get_unique_integers_between $(( $current_price + $swap_index_accuracy )) $(( $current_price + $deposit_index_accuracy ))
)]" \
$indexes \
`# list of fees` \
"$( get_joined_array $excess_user_deposits_count get_fee "$fees" )" \
$fees \
`# disable_autoswap` \
"$( repeat_with_comma "true" "$excess_user_deposits_count" )" \
`# options` \
--from $person --yes --output json --broadcast-mode sync --gas auto --gas-adjustment $GAS_ADJUSTMENT --gas-prices $GAS_PRICES
)"
tx_result="$( bash $SCRIPTPATH/helpers.sh waitForTxResult "$tx_response" "deposited: new close-to-price ticks ($tokenB_excess_user_deposits_count, $tokenA_excess_user_deposits_count)" )"
tx_result="$( bash $SCRIPTPATH/helpers.sh waitForTxResult "$tx_response" "deposited: new close-to-price ticks ($tokenB_excess_user_deposits_count, $tokenA_excess_user_deposits_count) $indexes" )"

# check if duration has been reached
if [ ! -z "$( check_duration )" ]
Expand Down