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

Price improvemenet fee policy autopilot argument #2377

Merged
merged 4 commits into from
Feb 7, 2024
Merged
Changes from all 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
27 changes: 27 additions & 0 deletions crates/autopilot/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,12 @@ pub struct FeePolicy {
/// - Surplus with cap:
/// surplus:0.5:0.06
///
/// - Price improvement without cap:
/// price_improvement:0.5:1.0
///
/// - Price improvement with cap:
/// price_improvement:0.5:0.06
///
/// - Volume based:
/// volume:0.1
#[clap(long, env, default_value = "surplus:0.0:1.0")]
Expand All @@ -371,6 +377,7 @@ impl FeePolicy {
factor,
max_volume_factor,
},
FeePolicyKind::PriceImprovement { .. } => todo!(),
FeePolicyKind::Volume { factor } => domain::fee::Policy::Volume { factor },
}
}
Expand All @@ -380,6 +387,10 @@ impl FeePolicy {
pub enum FeePolicyKind {
/// How much of the order's surplus should be taken as a protocol fee.
Surplus { factor: f64, max_volume_factor: f64 },
/// How much of the order's price improvement should be taken as a protocol
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be good to define price improvement since this is a bit nuanced.

/// fee where price improvement is a difference between the executed price
/// and the best quote.
PriceImprovement { factor: f64, max_volume_factor: f64 },
/// How much of the order's volume should be taken as a protocol fee.
Volume { factor: f64 },
}
Expand Down Expand Up @@ -407,6 +418,22 @@ impl FromStr for FeePolicyKind {
max_volume_factor,
})
}
"priceImprovement" => {
let factor = parts
.next()
.ok_or("missing price improvement factor")?
.parse::<f64>()
.map_err(|e| format!("invalid price improvement factor: {}", e))?;
let max_volume_factor = parts
.next()
.ok_or("missing price improvement max volume factor")?
.parse::<f64>()
.map_err(|e| format!("invalid price improvement max volume factor: {}", e))?;
Ok(Self::PriceImprovement {
factor,
max_volume_factor,
})
}
"volume" => {
let factor = parts
.next()
Expand Down
Loading