Service: Secondary Market & Trading Engine
The Secondary Market & Trading Engine provides the core infrastructure for post-issuance liquidity, transforming static, tokenized assets (Offers) into tradable, discoverable financial instruments. It addresses the fundamental problems of private asset illiquidity—high friction, siloed investor pools, opaque pricing, counterparty risk, and complex compliance—by providing a compliant, automated trading environment.
This engine orchestrates the entire lifecycle of a trade, from order placement and compliance checks to on-chain settlement.
This engine is built on five key pillars:
Continuous Compliance: Enforces the Offers's specific rules (e.g., investor accreditation, jurisdiction, lockups) on every single trade. It integrates with a Regulatory Compliance Engine to ensure no prohibited transfers can occur.
Transparent Price Discovery: Provides a central, permissioned venue for all eligible investors to view market depth and place orders, establishing a fair market price through a unified order book.
Atomic Settlement (DvP): Leverages smart contracts for "Delivery vs. Payment" (DvP) settlement. This eliminates counterparty risk by ensuring the RWA token and the payment (e.g., stablecoin) are exchanged in a single, indivisible on-chain transaction.
Unified Order Book: Aggregates all buy/sell interest for each asset into a high-performance, off-chain order book for rapid matching, ensuring the best execution price.
Market Integrity & Auditability: Creates a verifiable, immutable record (
Trade) for every completed transaction, providing a transparent history for investors, issuers, and regulators.Unlock Investor Liquidity: Provides a clear, compliant path for primary investors to exit their positions and for new investors to gain access.
Attract New Capital: Makes your platform's Offers significantly more attractive to investors, as liquidity is a primary consideration.
Frictionless Trading: Automates the entire trade lifecycle, reducing settlement times from days (in TradFi) to seconds.
Actionable Market Data: Provides real-time trade and volume data, giving issuers and investors the insights they need.
Core Technical Components & APIs
This engine introduces Order and Trade models and interacts heavily with your existing Profile, Offers, and EVM infrastructure.
Primary Models:
Order Model(future): The central record for an investor's intent to buy or sell.Trade Model(future): The immutable record of a completed, matched trade.Offer Model: Used to fetch the asset's specific trading rules, compliance requirements, and associated EVM Contract address.
Profile Model: Used (via a Regulatory Compliance Engine) to verify an investor's identity, jurisdiction, and accreditation status before a trade.
EVM Wallet: Used to check the seller's token balance and the buyer's stablecoin balance.
EVM Transfer: This model logs the successful on-chain transfers that result from a settled
Trade.
Governing Logic:
Order Matching Logic: The core "engine" that scans theOrder Bookand matches compatible buy/sell orders (e.g., Price-Time Priority). This logic runs off-chain for performance.Pre-Trade Compliance Check: The most critical logic. This function is called before anyOrderis accepted into the book. It must verify:
Primary APIs:
trading-api(future): Exposed to the Investor Portal. Used to create, cancel, and view the status ofOrdersand to fetchTradehistory.market-data-api(future): Provides real-time order book depth, last traded price, and volume data to the Investor Portal and Issuer Portal.settlement-api(future): Called by the matching engine (after a match) to orchestrate the on-chain atomic swap.evm-api: To execute the final on-chain DvP settlement transaction.
kyc-api/user-api: Used by the engine to query the Regulatory Compliance Engine for the pre-trade checks.
The Process Lifecycle & Key Capabilities
The engine manages the entire trade lifecycle through four distinct, automated phases.
Phase 1: Order Placement & Pre-Trade Validation
This phase ensures that only valid, compliant orders enter the marketplace.
Initiation: An investor, via the Investor Portal, submits a buy or sell
Orderusing thetrading-api.Validation: The engine immediately performs two critical checks:
Balance Check: Calls the evm-api to verify the seller's EVM Wallet holds the required
quantityof tokens, OR the buyer's EVM Wallet holds the required stablecoin (e.g.,price * quantity).Compliance Check: Calls the
compliance-apito run thePre-Trade Compliance Checklogic against both the buyer and seller.
Placement: If both checks pass, the
Orderis created with anOPENstatus and placed into the live, off-chain order book for that asset. If either check fails, thetrading-apireturns a specific error (e.g., "Insufficient Funds," "Buyer Not Eligible").
Phase 2: Order Matching (Off-Chain)
This is the high-speed "engine" component that finds trades.
Order Book Management: The engine maintains the
Order Bookfor all tradable assets, updating it in real-time asOrdersare placed or cancelled.Matching Logic: The
Order Matching Logic(Price-Time Priority) continuously scans the book. When a buyOrder's price is greater than or equal to a sellOrder's price, it finds a match.Trade Creation: Upon a match, the engine "locks" the corresponding
Orders(or parts of them, for partial fills) and creates an immutableTraderecord with aPENDING_SETTLEMENTstatus.
Phase 3: Automated Execution & Settlement (On-Chain)
This phase orchestrates the on-chain "atomic swap" to finalize the trade.
Trigger: A new
Traderecord is created withPENDING_SETTLEMENTstatus.Action: The engine immediately calls the internal
settlement-api, passing theTradedetails .Atomic Swap: The
settlement-apiconstructs and calls the evm-api to execute a single, atomic smart contract transaction. This contract function does the following:Transfers the RWA tokens from the Seller's EVM Wallet to the Buyer's EVM Wallet.
Simultaneously transfers the stablecoin payment from the Buyer's EVM Wallet to the Seller's EVM Wallet.
- If either transfer fails (e.g., seller's balance changed), the entire transaction reverts. No funds or assets are lost.
Phase 4: Confirmation & Post-Trade Update
This phase cleans up the records after a successful on-chain settlement.
Confirmation: The engine listens for the successful
SETTLEDevent from the on-chain transaction.Logging: The
Traderecord is updated toCOMPLETED, and thesettlement_tx_hashis stored. The corresponding EVM Transfer records are created.Order Update: The
Orderrecords that made up theTradeare updated toFILLED(orPARTIALLY_FILLEDif only a portion was matched).Notification: The engine calls the
notification-apito alert both the buyer and seller that their trade has been successfully executed.Cap Table Update: An event is sent to the Cap Table to update the official, off-chain list of token holders for the Offer.
Advanced Scenarios & Platform Resilience
Pre-Trade Compliance Failures: If any pre-trade check fails, the
trading-apirejects theOrderimmediately. This is a critical feature: a non-compliant order never even touches the order book.On-Chain Settlement Failures: If the atomic swap fails on-chain (e.g., out of gas, or the seller moved their tokens), the
Tradeis markedFAILED. The "locked"Ordersare automatically returned to theOPENstate in the order book to be matched again.Order Cancellations: An investor can call the
trading-apito cancel anyOrderthat has anOPENstatus. The engine ensures a "race condition" is handled where anOrdercannot be cancelled at the same moment it is being matched.Administrative Controls: The Issuer Portal has the ability to pause trading for a specific Offer (by instructing the engine to reject all new
Orders) or to administratively cancel anyOrderin the book.