Skip to main content

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 to AdminClosed and records DisputeResolved event.
    • adminClearDispute(tradeId, reason): Clears the dispute, returns status to Funded, does not touch funds; records DisputeCleared event.
    • Still retains adminWithdraw(tradeId) as a fallback option: Admin withdraws all escrowed funds, status becomes AdminClosed.

Security highlights:

  • State changes first, then token transfers, with core transfer functions protected by nonReentrant; uses SafeERC20.

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