liquidator: fix rebalance loops
selling 100% with flash loan swap fee charged on top meant creating a borrow
This commit is contained in:
parent
bf0d748d2d
commit
66c6ae1cff
|
@ -498,8 +498,11 @@ impl Rebalancer {
|
||||||
|
|
||||||
if amount > dust_threshold {
|
if amount > dust_threshold {
|
||||||
// Sell
|
// Sell
|
||||||
|
|
||||||
|
// To avoid creating a borrow when paying flash loan fees, sell only a fraction
|
||||||
|
let input_amount = amount * I80F48::from_num(0.99);
|
||||||
let (txsig, route) = self
|
let (txsig, route) = self
|
||||||
.token_swap_sell(token_mint, amount.to_num::<u64>())
|
.token_swap_sell(token_mint, input_amount.to_num::<u64>())
|
||||||
.await?;
|
.await?;
|
||||||
let out_token = self
|
let out_token = self
|
||||||
.mango_client
|
.mango_client
|
||||||
|
|
Loading…
Reference in New Issue