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

liquidator: rebalance with openbook (limit order) #938

Merged
merged 5 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
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
7 changes: 7 additions & 0 deletions bin/liquidator/src/cli_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ pub struct Cli {
#[clap(long, env, default_value = "30")]
pub(crate) rebalance_refresh_timeout_secs: u64,

#[clap(long, env, value_enum, default_value = "false")]
pub(crate) rebalance_using_limit_order: BoolArg,

/// distance (in bps) from oracle price at which to place order for rebalancing
#[clap(long, env, default_value = "100")]
pub(crate) rebalance_limit_order_distance_from_oracle_price_bps: u64,

/// if taking tcs orders is enabled
///
/// typically only disabled for tests where swaps are unavailable
Expand Down
10 changes: 9 additions & 1 deletion bin/liquidator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ async fn main() -> anyhow::Result<()> {
let (rebalance_trigger_sender, rebalance_trigger_receiver) = async_channel::bounded::<()>(1);
let (tx_tcs_trigger_sender, tx_tcs_trigger_receiver) = async_channel::unbounded::<()>();
let (tx_liq_trigger_sender, tx_liq_trigger_receiver) = async_channel::unbounded::<()>();

if cli.rebalance_using_limit_order == BoolArg::True && !signer_is_owner {
warn!("Can't withdraw dust to liqor account if delegate and using limit orders for rebalancing");
}

let rebalance_config = rebalance::Config {
enabled: cli.rebalance == BoolArg::True,
slippage_bps: cli.rebalance_slippage_bps,
Expand All @@ -263,8 +268,11 @@ async fn main() -> anyhow::Result<()> {
.rebalance_alternate_sanctum_route_tokens
.clone()
.unwrap_or_default(),
allow_withdraws: signer_is_owner,
allow_withdraws: cli.rebalance_using_limit_order == BoolArg::False || signer_is_owner,
use_sanctum: cli.sanctum_enabled == BoolArg::True,
use_limit_order: cli.rebalance_using_limit_order == BoolArg::True,
limit_order_distance_from_oracle_price_bps: cli
.rebalance_limit_order_distance_from_oracle_price_bps,
};
rebalance_config.validate(&mango_client.context);

Expand Down
Loading
Loading