MARKET
Internals
Crate path, key types, adjacent protocols for MARKET.
MARKET (Multi-Agent Registry for Economic Trading) lives in protocols/market-lib. This page covers where to find the implementation, the key Rust types, and how it composes with adjacent protocols.
Source
| Path | Contains |
|---|---|
protocols/market-lib/src/lib.rs | ProtocolModule impl, operation dispatch |
protocols/market-lib/src/protocol.rs | core protocol logic |
protocols/market-lib/src/types.rs | request/response types (derive schemars::JsonSchema) |
protocols/market-lib/tests/ | unit + integration tests |
schemas/market/v1/ | published JSON Schemas |
ProtocolModule contract
impl ProtocolModule for MarketProtocol {
fn protocol_name(&self) -> &'static str { "MARKET" }
fn version(&self) -> &'static str { "v1.0.0" }
fn operations(&self) -> Vec<&'static str> {
vec![
"asset_genesis",
"create_order",
"modify_order",
"cancel_order",
"create_bounty",
"query_orderbook",
"execute_trade",
"trade_history",
]
}
async fn invoke(&self, op: &str, payload: Value, ctx: &InvokeContext)
-> Result<Response, ProtocolError>
{
match op {
"asset_genesis" => self.asset_genesis(payload, ctx).await,
"create_order" => self.create_order(payload, ctx).await,
"modify_order" => self.modify_order(payload, ctx).await,
"cancel_order" => self.cancel_order(payload, ctx).await,
"create_bounty" => self.create_bounty(payload, ctx).await,
"query_orderbook" => self.query_orderbook(payload, ctx).await,
"execute_trade" => self.execute_trade(payload, ctx).await,
"trade_history" => self.trade_history(payload, ctx).await,
_ => Err(ProtocolError::UnknownOperation(op.into())),
}
}
}Adjacent
| Relation | Members |
|---|---|
| Consults | — |
| Records to | MAX · MOTET · MOMENT |
| Subject to | MAXIM · MOAT (cross-org) · MOOT (disputes) |
| Settled with | MEAL · MANA · MADE |
Status
Implemented · production-grade.
Tests
cargo test -p market-lib --all-featuresSee also
ProtocolModuletrait — the contract- Engine pipeline — the 8 stages
- Plugins — author your own