liquidator: stop withdraw attempts on delgated accounts
This commit is contained in:
parent
cdf804e971
commit
0a55184ec7
|
@ -16,6 +16,7 @@ use mango_v4_client::{
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use solana_sdk::commitment_config::CommitmentConfig;
|
use solana_sdk::commitment_config::CommitmentConfig;
|
||||||
use solana_sdk::pubkey::Pubkey;
|
use solana_sdk::pubkey::Pubkey;
|
||||||
|
use solana_sdk::signer::Signer;
|
||||||
use tracing::*;
|
use tracing::*;
|
||||||
|
|
||||||
pub mod liquidate;
|
pub mod liquidate;
|
||||||
|
@ -194,6 +195,11 @@ async fn main() -> anyhow::Result<()> {
|
||||||
.await?;
|
.await?;
|
||||||
let mango_group = mango_account.fixed.group;
|
let mango_group = mango_account.fixed.group;
|
||||||
|
|
||||||
|
let signer_is_owner = mango_account.fixed.owner == liqor_owner.pubkey();
|
||||||
|
if cli.rebalance == BoolArg::True && !signer_is_owner {
|
||||||
|
warn!("rebalancing on delegated accounts will be unable to free token positions reliably, withdraw dust manually");
|
||||||
|
}
|
||||||
|
|
||||||
let group_context = MangoGroupContext::new_from_rpc(&client.rpc_async(), mango_group).await?;
|
let group_context = MangoGroupContext::new_from_rpc(&client.rpc_async(), mango_group).await?;
|
||||||
|
|
||||||
let mango_oracles = group_context
|
let mango_oracles = group_context
|
||||||
|
@ -322,6 +328,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
.filter(|v| !v.is_empty())
|
.filter(|v| !v.is_empty())
|
||||||
.map(|name| mango_client.context.token_by_name(name).token_index)
|
.map(|name| mango_client.context.token_by_name(name).token_index)
|
||||||
.collect(),
|
.collect(),
|
||||||
|
allow_withdraws: signer_is_owner,
|
||||||
};
|
};
|
||||||
|
|
||||||
let rebalancer = Arc::new(rebalance::Rebalancer {
|
let rebalancer = Arc::new(rebalance::Rebalancer {
|
||||||
|
|
|
@ -28,6 +28,7 @@ pub struct Config {
|
||||||
pub refresh_timeout: Duration,
|
pub refresh_timeout: Duration,
|
||||||
pub jupiter_version: jupiter::Version,
|
pub jupiter_version: jupiter::Version,
|
||||||
pub skip_tokens: Vec<TokenIndex>,
|
pub skip_tokens: Vec<TokenIndex>,
|
||||||
|
pub allow_withdraws: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn token_bank(
|
fn token_bank(
|
||||||
|
@ -387,7 +388,11 @@ impl Rebalancer {
|
||||||
|
|
||||||
// Any remainder that could not be sold just gets withdrawn to ensure the
|
// Any remainder that could not be sold just gets withdrawn to ensure the
|
||||||
// TokenPosition is freed up
|
// TokenPosition is freed up
|
||||||
if amount > 0 && amount <= dust_threshold && !token_position.is_in_use() {
|
if amount > 0
|
||||||
|
&& amount <= dust_threshold
|
||||||
|
&& !token_position.is_in_use()
|
||||||
|
&& self.config.allow_withdraws
|
||||||
|
{
|
||||||
let allow_borrow = false;
|
let allow_borrow = false;
|
||||||
let txsig = self
|
let txsig = self
|
||||||
.mango_client
|
.mango_client
|
||||||
|
|
Loading…
Reference in New Issue