OtcHub.sol
Main contract for OTC trades.
States: Open → Funded → Settled/Cancelled/Disputed → AdminClosed
Key functions (conceptual):
createTrade(maker, token, price, deposit, window, direction, agreementHash)fund(tradeId)confirm(tradeId)raiseDispute(tradeId)/cancelDispute(tradeId)adminWithdraw(tradeId)
Security:
- Reentrancy guard
- Access control
- State checks
Flowchart
Dispute Resolution (extended)
- Admin options when
Disputed:adminResolveDispute(tradeId, winner, reason): After deducting fees, transfers all escrowed funds to the winning party; sets status toAdminClosedand recordsDisputeResolvedevent.adminClearDispute(tradeId, reason): Clears the dispute, returns status toFunded, does not touch funds; recordsDisputeClearedevent.- Still retains
adminWithdraw(tradeId)as a fallback option: Admin withdraws all escrowed funds, status becomesAdminClosed.
Security highlights:
- State changes first, then token transfers, with core transfer functions protected by
nonReentrant; usesSafeERC20.
Platform Fee Structure
OTC Hub implements a transparent and fair fee structure:
Transaction Fees
- Base Fee Rate: 0.5% of trade amount from both buyer and seller
- Total Platform Fee: 1% of trade amount (0.5% from each party)
- Fee Collection: Deducted automatically during trade settlement
Dispute Resolution Fees
- Standard Dispute: No additional fee for dispute initiation
- Dispute Resolution: 10% of trade amount deducted from the at-fault party's collateral
- Dispute Processing: Resolved by platform administrators with full evidence review