Secondary Market (P2P)
Peer-to-peer marketplace for negotiated trades at custom prices
Overview
The Secondary Market is a peer-to-peer order book where users trade YRT tokens directly with each other at negotiated prices—independent of liquidity pool pricing.
Key Innovation:
Off-chain orders, on-chain settlement - Gas efficient
EIP-712 signatures - Secure, standard order signing
Zero protocol fees - Direct peer-to-peer swaps
No slippage - Exact price matching
Why Two Markets?
Owna Finance provides dual trading venues to maximize liquidity and serve different trading needs:
🏦 Owna-DEX (AMM)
For instant trading at market price
Instant execution
Trade immediately
Price impact on large orders
Always liquid
24/7 availability
0.3% swap fee
Dynamic pricing
Market-driven
Slippage on volatile assets
No counterparty needed
Trade against pool
Must accept pool price
Best for:
Small to medium trades
Immediate execution needs
Users who accept current market price
High-frequency trading
🤝 Secondary Market (Order Book)
For negotiated trading at custom prices
Custom pricing
Set your own price
Must wait for counterparty
Zero fees
No protocol fee
Order may not fill
No slippage
Exact price guaranteed
Requires active matching
Large order friendly
No price impact
Off-chain order management
Best for:
Large block trades
Price-sensitive traders
Limit orders at specific prices
OTC (over-the-counter) deals
Professional Rationale: Dual-Market Approach
🎯 Market Efficiency Through Choice
Problem: Single trading venue forces all users into one mechanism
AMM: Instant but expensive for large trades
Order Book: Efficient pricing but requires liquidity
Solution: Dual markets serve different needs simultaneously
1. Capital Efficiency
Large trades split intelligently:
2. Liquidity Concentration
AMM provides base liquidity floor:
Always available for small/medium trades
Price discovery mechanism
24/7 instant execution
Order Book provides deep liquidity for size:
Large institutional orders
Custom pricing for bulk purchases
OTC settlement without pool impact
3. Risk Segregation
AMM Risk:
Impermanent loss for LPs
Slippage for large trades
Front-running vulnerability
Order Book Risk:
Order may not fill
Counterparty required
Off-chain order management
Users choose risk profile per trade.
4. Market Resilience
If AMM liquidity is thin:
Users post Secondary Market orders at fair prices
Orders fill when counterparties appear
Market continues functioning
If Order Book has no takers:
Users execute via AMM instantly
Trading never stops
Liquidity always exists
How It Works
Architecture
Order Lifecycle
1. Maker Creates Order (Off-chain)
2. Order Broadcasted (Off-chain)
Order stored in order book database
Visible to all potential takers
No gas cost until filled
3. Taker Fills Order (On-chain)
4. Order Cancellation (Optional)
Key Features
🔒 EIP-712 Typed Signatures
Orders signed with EIP-712 standard for security:
Benefits:
Human-readable order preview in wallet
Prevents signature replay attacks
Industry-standard security
Compatible with all major wallets
💰 Zero Protocol Fees
Unlike DEX (0.3% fee), Secondary Market has:
0% protocol fee on trades
Only gas costs (same as any token transfer)
Maximizes value for both parties
Comparison:
🎯 Exact Price Execution
No slippage—trade executes at exact order price:
🔄 Order Status Tracking
Three order states:
NONE
Order not yet filled/cancelled
✅ Yes
FILLED
Order successfully executed
❌ No
CANCELLED
Order cancelled by maker
❌ No
Prevents double-spending and replay attacks.
Trade Scenarios
Scenario 1: Bulk Purchase Below Market
Setup:
AMM Price: 1.2 USDC/YRT
Large buyer wants 10,000 YRT
AMM slippage would be ~20% on this size
Secondary Market Solution:
Result:
Buyer gets 10,000 YRT at 1.15 (vs 1.44 via AMM)
Seller gets better price than AMM (1.15 > 1.2 after fees)
Both parties save vs AMM slippage
Zero protocol fees
Scenario 2: OTC Property Sale
Setup:
Investor A holds 50,000 YRT from Property X
Investor B wants entire position
Too large for AMM without massive slippage
Secondary Market Solution:
Result:
Single atomic transaction
No AMM pool disturbance
Custom negotiated price
Off-chain negotiation, on-chain settlement
Scenario 3: Limit Orders
Setup:
Current AMM price: 1.0 USDC/YRT
Trader believes price will rise to 1.3
Wants to sell at 1.25 when it reaches that level
Secondary Market Solution:
Technical Implementation
Contract: SecondaryMarket.sol
Deployed at: [TBD - See technical/addresses.md]
Core Functions
1. executeSwap()
Executes atomic swap between maker and taker.
Validation:
✅ Signature matches maker address
✅ Order not already filled/cancelled
✅ Valid addresses and amounts
✅ Sufficient balances and approvals
Process:
Hash order with EIP-712
Recover signer from signature
Verify signer == order.maker
Mark order as FILLED
Transfer makerToken: maker → taker
Transfer takerToken: taker → maker
Emit SwapExecuted event
2. cancelOrder()
Cancels unfilled order (maker only).
Validation:
✅ Caller is order maker
✅ Order not already filled/cancelled
3. getOrderStatus()
Returns order state: 0 = NONE, 1 = FILLED, 2 = CANCELLED
Security Features
✅ ReentrancyGuard
All state-changing functions protected against reentrancy attacks.
✅ EIP-712 Typed Data
Standard signature format prevents:
Signature reuse across chains/contracts
Phishing attacks (wallet shows clear order details)
Replay attacks from other dApps
✅ SafeERC20
Uses OpenZeppelin SafeERC20 for all token transfers—handles non-standard ERC20 implementations.
✅ Order Hash Uniqueness
Salt parameter ensures order uniqueness:
Different salt = different hash = new order (even with same amounts)
✅ Order Status Tracking
Prevents double-execution:
Off-Chain Infrastructure
Order Book Management
Not included in smart contract (gas optimization):
Order storage and indexing
Order matching engine
Order broadcasting
Historical trade data
Implementation options:
Centralized Order Book
Fast order matching
Low latency
Requires trusted operator
Example: Custom API backend
Decentralized Order Relay
P2P order broadcasting
No central authority
Higher latency
Example: IPFS + libp2p
Hybrid Approach (Recommended)
Multiple independent relayers
Users choose preferred relayer
All orders settle on same contract
Example: Multiple frontends, shared contract
User Flows
Selling YRT Tokens
Buying YRT Tokens
DEX vs Secondary Market Comparison
When to Use DEX (AMM)
✅ Best for:
Small to medium trades (< $10,000)
Immediate execution required
Market orders
High-frequency trading
Don't want to wait for counterparty
❌ Avoid for:
Large block trades (> $50,000)
Price-sensitive transactions
When market is volatile (high slippage)
When to Use Secondary Market
✅ Best for:
Large block trades (> $50,000)
Custom pricing requirements
Limit orders
OTC deals
Minimizing fees
When you can wait for counterparty
❌ Avoid for:
Need instant execution
Small trade sizes (gas cost > savings)
Urgent trades
Integration Example
Smart Order Routing
Route trades to optimal venue:
Best Practices
For Makers (Order Creators)
1. Competitive Pricing
2. Sufficient Approval
3. Monitor Order Status
4. Cancel Stale Orders
For Takers (Order Fillers)
1. Verify Order Validity
2. Compare with AMM
Gas Optimization
Order Creation (Off-Chain)
Gas Cost: 0 ETH
Signing happens in wallet (free)
No blockchain transaction required
Orders stored off-chain
Order Execution
Gas Cost: ~100,000 - 150,000 gas
Breakdown:
Signature verification: ~5,000 gas
State updates: ~25,000 gas
Token transfers (2x): ~100,000 gas
Event emission: ~2,000 gas
Optimization Tips:
Batch multiple small orders into one large order
Use unlimited approval (approve once, trade many times)
Execute during low network congestion
Liquidity Dynamics
How Both Markets Interact
Arbitrage Creates Price Parity:
Liquidity Flow:
Advanced Features
Partial Fills (Future Enhancement)
Current: All-or-nothing orders Future: Partially fillable orders
Order Expiration (Future Enhancement)
Fee Structure (Future Enhancement)
Troubleshooting
Common Errors
1. InvalidSignature
2. OrderAlreadyFilled
3. OrderAlreadyCancelled
4. Insufficient Allowance
Debugging Tips
Deployment Information
Contract: SecondaryMarket.sol Network: Base Sepolia Testnet Address: [See technical/addresses.md] Verified: ✅ Yes
Constructor Parameters:
None (EIP-712 domain set internally)
Deployment Script:
Related Documentation
Owna-DEX Overview - AMM trading mechanism
YRT Factory Overview - Token creation
User Trading Guide - Complete trading guide
Technical Reference - Contract addresses
Summary
The Secondary Market complements Owna-DEX by providing:
✅ Zero-fee P2P trading for cost-conscious users
✅ Custom pricing for negotiated deals
✅ Large order support without slippage
✅ Limit order functionality for strategic trading
✅ OTC settlement for institutional trades
Together with AMM, creates complete trading ecosystem:
DEX = Instant liquidity + always available
Secondary Market = Custom pricing + zero fees
Result: Maximum flexibility, optimal execution for all trade sizes.
Built with EIP-712 🔏 Secured by OpenZeppelin 🛡️ Zero Protocol Fees 💰
Peer-to-peer trading at your price—bringing flexibility to tokenized real estate.
Last updated
