MARS documentation
Rust librariesmars-protocol

mars-protocol · bonds

Public declarations and documentation for mars-protocol::bonds.

Package: mars-protocol · Workspace version: 0.1.0 · Module: bonds

This reference follows declared modules and public syntax, including public implementation methods. Function bodies and constant values are omitted. Feature conditions are retained. Private-module re-exports and trait resolution require the compiler; not every declaration is a root import.

bonds::BOND_CURRENCY

Canonical currency unit for MARS bonds on Sigil.

Sigil is the chain; MINTS is the monetary unit used for publisher bonds, slashing, rewards, and shard-operator stakes.

pub const BOND_CURRENCY: &str;

Source line: 17.

bonds::BondAmount

Exact, non-negative decimal amount used by every bond money field.

The wire form is always a JSON string in canonical plain-decimal notation. Values are constrained to PostgreSQL NUMERIC(38,18): at most 20 integer digits and 18 fractional digits, with no sign or exponent. This keeps signature bytes, threshold checks, and database values identical.

#[derive(Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[cfg_attr(feature = "contracts", schemars(transparent))]
#[cfg_attr(
    feature = "contracts",
    schemars(extend(
        "pattern" = r"^(0|[1-9][0-9]{0,19})(\.[0-9]{1,18})?$"
    ))
)]
#[cfg_attr(
    feature = "contracts",
    schema(
        value_type = String,
        pattern = r"^(0|[1-9][0-9]{0,19})(\.[0-9]{1,18})?$",
        example = "100.5"
    )
)]
pub struct BondAmount(String);

Source line: 42.

bonds::BondAmountError

Invalid exact bond amount.

#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
pub enum BondAmountError {
    /// The value is empty or uses unsupported notation.
    #[error("bond amount must use unsigned plain-decimal notation")]
    InvalidNotation,
    /// The value exceeds the fixed database precision or scale.
    #[error("bond amount exceeds NUMERIC(38,18) precision")]
    Overprecision,
}

Source line: 46.

bonds::BondAmount::SCALE

Maximum fractional scale accepted by the wire and database contract.

pub const SCALE: usize;

Source line: 57.

bonds::BondAmount::INTEGER_DIGITS

Maximum number of digits before the decimal point.

pub const INTEGER_DIGITS: usize;

Source line: 59.

bonds::BondAmount::from_integer

Build an exact whole-unit amount.

#[must_use]
pub fn from_integer(value: u64) -> Self;

Source line: 63.

bonds::BondAmount::as_str

Canonical plain-decimal representation.

#[must_use]
pub fn as_str(&self) -> &str;

Source line: 69.

bonds::BondAmount::is_zero

Whether the amount is exactly zero.

#[must_use]
pub fn is_zero(&self) -> bool;

Source line: 75.

bonds::BondAmount::to_ranking_f64

Convert only for non-monetary ranking calculations.

All validation and threshold decisions use [Ord], never this presentation-only approximation.

#[must_use]
pub fn to_ranking_f64(&self) -> f64;

Source line: 84.

bonds::BondReference

A reference to a bond stored in a MARS entry. Per MARS Specification Section 7.2.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct BondReference {
/// Unique bond identifier.

pub bond_id: String,
/// Amount staked in MINTS.

pub amount: BondAmount,
/// Currency — always "MINTS".

pub currency: String,
/// Current bond status.

pub status: BondStatus
}

Source line: 302.

bonds::Bond

Full bond record (server-side). Per MARS Specification Section 7.2.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct Bond {
/// Unique bond identifier.

pub bond_id: String,
/// DID of the publisher who posted the bond.

pub publisher_did: String,
/// DID of the entry this bond covers.

pub entry_did: String,
/// DID of the registry holding the bond.

pub registry_did: String,
/// Amount staked in MINTS.

pub amount: BondAmount,
/// Currency — always "MINTS".

pub currency: String,
/// When the bond was created.

pub created_at: chrono::DateTime<chrono::Utc>,
/// Current status.

pub status: BondStatus,
/// History of slashing events.

#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub slash_history: Vec<SlashEvent>
}

Source line: 318.

bonds::BondStatus

Status of a publisher bond. Per MARS Specification Appendix A (bondReference schema).

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "snake_case")]
pub enum BondStatus {
    /// Bond is active and fully collateralized.
    Active,
    /// Bond has been partially slashed but still covers minimum.
    PartiallySlashed,
    /// Bond has been fully slashed — entry should be revoked.
    FullySlashed,
    /// Bond has been released back to the publisher.
    Released,
}

Source line: 345.

bonds::BondStatus::as_str

pub fn as_str(&self) -> &'static str;

Source line: 357.

bonds::SlashEvent

A slashing event recorded against a bond. Per MARS Specification Section 7.4.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct SlashEvent {
/// When the slash occurred.

pub timestamp: chrono::DateTime<chrono::Utc>,
/// Amount slashed in MINTS.

pub amount: BondAmount,
/// Reason for the slash.

pub reason: String,
/// DID of the reporter who triggered the slash.

pub reporter_did: String,
/// Distribution of slashed funds.

pub distribution: SlashDistribution
}

Source line: 378.

bonds::SlashDistribution

Distribution of slashed bond funds. Per MARS Specification Section 7.4: 30% reporter, 40% harmed parties, 30% network treasury.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct SlashDistribution {
/// Amount going to the reporter (30%).

pub reporter_share: BondAmount,
/// Amount going to harmed parties (40%).

pub harmed_parties_share: BondAmount,
/// Amount going to network treasury (30%).

pub treasury_share: BondAmount
}

Source line: 397.

bonds::SlashDistribution::standard_split

Compute a deterministic 30/40/30 split.

Reporter and harmed-party shares round down at the 18-decimal database quantum; the treasury receives the exact remainder, so no money is created or lost.

#[must_use]
pub fn standard_split(total: &BondAmount) -> Self;

Source line: 413.

bonds::BondRequirements

Minimum bond requirements by entry type. Per MARS Specification Section 7.3.

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct BondRequirements {
/// Whether a bond is required.

pub required: bool,
/// Minimum bond amount in MINTS.

pub minimum_amount: BondAmount
}

Source line: 432.

bonds::BondRequirements::for_entry_type

Get the minimum bond requirement for an entry type. Per MARS Specification Section 7.3.

pub fn for_entry_type(entry_type: &EntryType) -> Self;

Source line: 442.

bonds::MarsAnchor

On-chain anchor record for a MARS entry. Per MARS Specification Appendix B.

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub struct MarsAnchor {
/// Always "MarsAnchor".

#[serde(rename = "type")]
pub anchor_type_name: String,
/// DID of the anchored entry.

pub entry_did: String,
/// SHA-256 hash of canonicalized itemData.

pub item_data_hash: String,
/// DID of the publisher.

pub publisher_did: String,
/// SemVer version string.

pub version: String,
/// Timestamp of anchoring.

pub timestamp: chrono::DateTime<chrono::Utc>,
/// Type of anchor operation.

pub anchor_type: AnchorType,
/// Bond ID (if applicable).

#[serde(skip_serializing_if = "Option::is_none")]
pub bond_id: Option<String>,
/// Hash of the previous anchor (chain linking).

#[serde(skip_serializing_if = "Option::is_none")]
pub previous_anchor_hash: Option<String>
}

Source line: 477.

bonds::AnchorType

Anchor operation type. Per MARS Specification Section 10.1.

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[cfg_attr(feature = "contracts", derive(schemars::JsonSchema, utoipa::ToSchema))]
#[serde(rename_all = "camelCase")]
pub enum AnchorType {
    Register,
    Update,
    Revoke,
    Transfer,
    Attest,
}

Source line: 506.

bonds::AnchorType::as_str

pub fn as_str(&self) -> &'static str;

Source line: 515.

Source provenance

Source: mars-protocol/src/bonds.rs · SHA-256 19c8245fa2e672674e9bed3b464541c71f056caf48a6e8b26888c5fa9d188e52. Package overview.

On this page