Skip to main content

Overview

The SessionRegistry is the onchain component of Sunbreak’s compliance system. It stores verified sessions written by the Sunbreak API, enabling smart contracts to enforce compliance at time of transaction.

Contract Interface

All functions are caller-context (the app is msg.sender) and require your app to be authorized by the registry’s manager.

Enforcement (revert-on-fail)

  • enforceSessionActive(address acct) - reverts unless the account currently has an active session.
  • enforceSessionPresent(address wallet) - reverts unless the account has presence (not blacklisted).

Views

  • isSessionActive(address acct) - returns true if sessionExpiry > block.timestamp.
  • isSessionPresent(address wallet) - returns true if a session entry exists (non-zero).

Example Integration

Below is a reference pattern showing how exchanges commonly integrate registry checks into their matching logic.

Order Placement (Maker)

// Optional: ensure maker is compliant when creating an order
registry.enforceSessionActive(maker);

Settlement (Taker fills a Maker order)

// 1) Verify taker is active at execution
registry.enforceSessionActive(taker);

// 2) Ensure maker is not blacklisted (presence required)
registry.enforceSessionPresent(maker);

// Proceed with trade settlement
This ensures takers are verified in real time, while makers are only blocked if explicitly blacklisted (not merely expired).

Session States

ConditionMeaningCommon Exchange Response
sessionExpiry > tsActive (currently compliant)Allow trade
sessionExpiry <= ts && != 0Expired (inactive but not blacklisted)Allow maker fills or reverify
sessionExpiry == 0Never had session or revokedBlock trade
Note: ts = block.timestamp

Decision Flow Example

RoleRequired CheckFunctionFails →
TakerMust be activeenforceSessionActive(taker)Reject fill
MakerMust be presentenforceSessionPresent(maker)Reject fill

Implementation Notes

  • The Sunbreak SDK issues sessions after compliance verification and writes them onchain through authorized signers.
  • The SessionRegistry contract exposes deterministic session state - active, expired, or revoked - for any authorized app to query.
  • Exchanges or protocols can implement their own matching and enforcement logic around these functions.