pub struct PartnerFeeEntry {
pub volume_bps: Option<u32>,
pub surplus_bps: Option<u32>,
pub price_improvement_bps: Option<u32>,
pub max_volume_bps: Option<u32>,
pub recipient: String,
}Expand description
A single partner fee policy entry (schema v1.14.0).
Exactly one of volume_bps, surplus_bps, or price_improvement_bps
should be set; the other two should be None. Use the named
constructors volume, surplus, or
price_improvement to enforce this invariant.
All basis-point values must be ≤ 10 000 (= 100 %). Values above that
threshold will be flagged by validate_app_data_doc.
§Example
use cow_rs::app_data::PartnerFeeEntry;
// 0.5 % volume-based fee
let fee = PartnerFeeEntry::volume(50, "0xRecipientAddress");
assert_eq!(fee.volume_bps(), Some(50));
assert_eq!(fee.surplus_bps(), None);Fields§
§volume_bps: Option<u32>Volume-based fee in basis points of the sell amount.
surplus_bps: Option<u32>Surplus-based fee in basis points.
price_improvement_bps: Option<u32>Price-improvement fee in basis points.
max_volume_bps: Option<u32>Volume cap in basis points (required for surplus/price-improvement variants).
recipient: StringAddress that receives the fee.
Implementations§
Source§impl PartnerFeeEntry
impl PartnerFeeEntry
Sourcepub fn volume(volume_bps: u32, recipient: impl Into<String>) -> Self
pub fn volume(volume_bps: u32, recipient: impl Into<String>) -> Self
Construct a volume-based fee entry.
The fee is charged as a percentage of the sell amount. This is the most common fee model for integration partners.
§Parameters
volume_bps— fee rate in basis points (e.g.50= 0.5 %). Must be ≤ 10 000 to pass validation.recipient— the0x-prefixed Ethereum address that receives the fee.
§Returns
A new PartnerFeeEntry with only volume_bps set.
§Example
use cow_rs::app_data::PartnerFeeEntry;
let fee = PartnerFeeEntry::volume(50, "0xRecipient");
assert_eq!(fee.volume_bps(), Some(50));
assert_eq!(fee.surplus_bps(), None);
assert_eq!(fee.max_volume_bps(), None);Sourcepub fn surplus(
surplus_bps: u32,
max_volume_bps: u32,
recipient: impl Into<String>,
) -> Self
pub fn surplus( surplus_bps: u32, max_volume_bps: u32, recipient: impl Into<String>, ) -> Self
Construct a surplus-based fee entry.
The fee is charged as a percentage of the surplus (the difference
between the execution price and the limit price). A max_volume_bps
cap is required to bound the fee as a percentage of the sell amount.
§Parameters
surplus_bps— fee rate in basis points on the surplus.max_volume_bps— cap on the fee as a percentage of sell amount.recipient— the0x-prefixed Ethereum address that receives the fee.
§Returns
A new PartnerFeeEntry with surplus_bps and max_volume_bps set.
§Example
use cow_rs::app_data::PartnerFeeEntry;
let fee = PartnerFeeEntry::surplus(30, 100, "0xRecipient");
assert_eq!(fee.surplus_bps(), Some(30));
assert_eq!(fee.max_volume_bps(), Some(100));Sourcepub fn price_improvement(
price_improvement_bps: u32,
max_volume_bps: u32,
recipient: impl Into<String>,
) -> Self
pub fn price_improvement( price_improvement_bps: u32, max_volume_bps: u32, recipient: impl Into<String>, ) -> Self
Construct a price-improvement fee entry.
The fee is charged as a percentage of the price improvement the
solver achieved. A max_volume_bps cap is required to bound the
fee as a percentage of the sell amount.
§Parameters
price_improvement_bps— fee rate in basis points on the price improvement.max_volume_bps— cap on the fee as a percentage of sell amount.recipient— the0x-prefixed Ethereum address that receives the fee.
§Returns
A new PartnerFeeEntry with price_improvement_bps and
max_volume_bps set.
§Example
use cow_rs::app_data::PartnerFeeEntry;
let fee = PartnerFeeEntry::price_improvement(20, 80, "0xRecipient");
assert_eq!(fee.price_improvement_bps(), Some(20));
assert_eq!(fee.max_volume_bps(), Some(80));
assert_eq!(fee.volume_bps(), None);Sourcepub const fn volume_bps(&self) -> Option<u32>
pub const fn volume_bps(&self) -> Option<u32>
Extract the volume fee in basis points, if present.
§Returns
Some(bps) if this is a volume-based fee entry, None otherwise.
Sourcepub const fn surplus_bps(&self) -> Option<u32>
pub const fn surplus_bps(&self) -> Option<u32>
Extract the surplus fee in basis points, if present.
§Returns
Some(bps) if this is a surplus-based fee entry, None otherwise.
Sourcepub const fn price_improvement_bps(&self) -> Option<u32>
pub const fn price_improvement_bps(&self) -> Option<u32>
Extract the price-improvement fee in basis points, if present.
§Returns
Some(bps) if this is a price-improvement fee entry, None otherwise.
Sourcepub const fn max_volume_bps(&self) -> Option<u32>
pub const fn max_volume_bps(&self) -> Option<u32>
Extract the max-volume cap in basis points, if present.
§Returns
Some(bps) for surplus/price-improvement entries, None for volume entries.
Trait Implementations§
Source§impl Clone for PartnerFeeEntry
impl Clone for PartnerFeeEntry
Source§fn clone(&self) -> PartnerFeeEntry
fn clone(&self) -> PartnerFeeEntry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PartnerFeeEntry
impl Debug for PartnerFeeEntry
Source§impl<'de> Deserialize<'de> for PartnerFeeEntry
impl<'de> Deserialize<'de> for PartnerFeeEntry
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for PartnerFeeEntry
impl Display for PartnerFeeEntry
Auto Trait Implementations§
impl Freeze for PartnerFeeEntry
impl RefUnwindSafe for PartnerFeeEntry
impl Send for PartnerFeeEntry
impl Sync for PartnerFeeEntry
impl Unpin for PartnerFeeEntry
impl UnsafeUnpin for PartnerFeeEntry
impl UnwindSafe for PartnerFeeEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.