View Facet

The View Facet contains all the read-only functions for the protocol. It reaches across every storage contract in the protocol and surfaces balances, intents, trades, symbols, oracles, fee structures, liquidation state, pause flags, access control, and computed values like fees and P&L.

Key Concepts:

  • Storage Organisation: The View Facet is structured to mirror the protocol's internal storage layout — Account, App, Close Intent, Counterparty Relations, Fee Management, Liquidation, Open Intent, State Control, Access Control, Symbol, and Trade. Functions are grouped by which storage contract they read from.

  • Pagination: Several functions that return arrays (trades, intents, symbols) come in two flavours — a full ID array getter and a paginated object getter that takes start and size parameters. The paginated versions are safe to call on large datasets without hitting gas limits.

  • Computed Views: Beyond raw storage reads, the View Facet also exposes calculated values — premium amounts, P&L, exercise fees, and open/close intent fees — using the same library logic the protocol itself uses internally. These are useful for simulating outcomes before submitting transactions.

  • Cross Balance: A user's allocated collateral for a specific counterparty relationship. getCrossBalance() returns the full CrossEntry struct for a given user/collateral/counterparty triplet.

  • Scheduled Release: The protocol tracks when balances are scheduled to be released back to parties. getScheduledReleaseEntry() exposes this per counterparty.


Account Storage Views

getIsolatedBalance()

Returns the unallocated balance a user holds for a given collateral — the funds available for withdrawal or allocation.

function getIsolatedBalance(address user, address collateral) external view returns (uint256);

getIsolatedLockedBalance()

Returns the portion of a user's isolated balance that is currently locked — for example, reserved for a pending withdrawal or locked during a protocol operation.

function getIsolatedLockedBalance(address user, address collateral) external view returns (uint256);

getReserveBalance()

Returns the amount held in a user's reserve balance for a given collateral — separate from both their isolated and cross balances.

getCrossBalance()

Returns the full CrossEntry struct for a user's cross balance with a specific counterparty and collateral. This includes the allocated balance and any associated metadata for that bilateral relationship.

getScheduledReleaseEntry()

Returns the ScheduledReleaseEntry for a user/collateral/counterparty combination — the protocol's record of when and how much collateral is scheduled to be released back to a party.

getCounterPartyAddresses()

Returns the full list of counterparty addresses that a user has a cross balance relationship with for a given collateral. Useful for enumerating all active bilateral relationships.

getWithdrawal()

Returns the full Withdraw struct for a given withdrawal ID — including the user, destination address, collateral, amount, and current status.

getLastWithdrawalId()

Returns the most recently assigned withdrawal ID. Useful for iterating over all withdrawals by incrementing from 1 to this value.

getExpressWithdrawProviderConfig()

Returns the ExpressWithdrawProviderConfig for a given provider and collateral combination — the configuration that governs how that provider handles fast withdrawals for that token.

getInvalidWithdrawalsPool()

Returns the address designated to receive collateral from withdrawals that fail validation checks.

getReleaseInterval()

Returns the effective release interval for a user — their custom interval if one has been configured, otherwise the system default.

getDefaultReleaseInterval()

Returns the protocol-wide default release interval applied to any PartyB that hasn't been given a custom one.

getUserReleaseInterval()

Returns both whether a user has a custom release interval configured and what that interval is. More useful than getReleaseInterval() when you need to distinguish between custom and default.

Example Response:

getMaxConnectedCounterParties()

Returns the protocol-wide cap on how many counterparty relationships a single party can have open simultaneously.

isManualSync()

Returns whether a user (typically a PartyB) has been flagged as requiring manual balance synchronisation before they can resume trading. This flag is set when a PartyB's config is updated via setPartyBConfig().

getNonce()

Returns the current nonce between two parties. Nonces are used internally to prevent replay attacks and ensure state consistency across bilateral operations.


App Storage Views

getVersion()

Returns the current protocol version number stored in AppStorage.

getBalanceLimitPerUser()

Returns the maximum balance a single user can hold for a given collateral.

getMaxCloseOrdersLength()

Returns the maximum number of close orders that can be submitted per trade at one time.

getMaxTradePerPartyA()

Returns the maximum number of concurrent open trades a PartyA can hold.

getPriceOracleAddress()

Returns the address of the primary price oracle contract used for settlement price lookups.

isWhitelistedCollateral()

Returns whether a given token address is whitelisted as a valid collateral in the protocol.

getTradeNftAddress()

Returns the address of the ERC-721 contract used to represent trade ownership as NFTs.

isSignatureUsed()

Returns whether a given signature hash has already been consumed by the protocol. Used to prevent signature replay.

getSignatureVerifier()

Returns the address of the contract responsible for verifying UPnL and settlement price signatures.

Timing Parameter Views

These return the current values of all protocol timing parameters set via ControlFacet:

getPartyBConfig()

Returns the full PartyBConfig struct for a given PartyB — including their active status, oracle assignment, and other solver-specific settings.

Example Response:

isSymbolTypesSupportedByPartyB()

Returns whether a specific PartyB has marked a given symbol type as supported for trading.

isCallFromInstantLayer()

Returns whether the current execution context has been flagged as originating from the instant layer.


Close Intent Storage Views

getCloseIntent()

Returns the full CloseIntent struct for a given intent ID — including status, trade ID, price, quantity, deadline, and fee structure.

getCloseIntentIds()

Returns all close intent IDs ever created for a specific trade. Includes all statuses — pending, filled, expired, cancelled.

getCloseIntents()

Returns a paginated slice of CloseIntent structs for a given trade. Use start and size to page through large histories without hitting gas limits.

getLastCloseIntentId()

Returns the most recently assigned close intent ID — useful for knowing the upper bound when iterating.


Counterparty Relations Storage Views

getBoundPartyB()

Returns the PartyB address that a given PartyA is currently bound to. Returns the zero address if no binding exists.

getUnbindingRequestTime()

Returns the timestamp at which a PartyA submitted an unbinding request. Returns 0 if no request is pending.

getUnbindingCooldown()

Returns the protocol-wide cooldown period a party must wait between submitting an unbinding request and it taking effect.

isInstantActionsModeActive()

Returns whether instant actions mode is currently active for a given user.

getInstantActionsModeDeactivateTime()

Returns the earliest timestamp at which a user can deactivate their instant actions mode.

getDeactiveInstantActionModeCooldown()

Returns the protocol-wide cooldown before instant actions mode can be deactivated after activation.


Fee Management Storage Views

getDefaultFeeCollector()

Returns the address that receives platform fees when no affiliate-specific collector is configured.

isAffiliateActive()

Returns whether a given affiliate address is currently active and eligible to receive fee routing.

getAffiliateFeeCollector()

Returns the address that receives fees on behalf of a specific affiliate.

getAffiliateFee()

Returns the Fee struct defining an affiliate's fee structure for a specific symbol — including open and close fee rates.


Liquidation Storage Views

getInProgressLiquidationId()

Returns the active liquidation ID for a given PartyA/PartyB/collateral combination. Returns 0 if no liquidation is currently in progress for that combination.

getLiquidationDetail()

Returns the full LiquidationDetail struct for a given liquidation ID — including the parties involved, collateral, UPnL snapshot, collateral price at liquidation time, and current status.

getLastLiquidationId()

Returns the most recently assigned liquidation ID.


Open Intent Storage Views

getOpenIntent()

Returns the full OpenIntent struct for a given intent ID — including all TradeAgreements fields, price, deadline, status, fee structure, PartyB whitelist, and user data.

getActiveOpenIntentIds()

Returns the full array of currently active open intent IDs for a given user.

getActiveOpenIntentsCount()

Returns just the count of active open intents for a user — cheaper than fetching the full array when only the number is needed.

getActiveOpenIntents()

Returns a paginated slice of full OpenIntent structs for a user's active intents. Safe to call on users with large numbers of open intents.

getPartyAOpenIntentIndex() & getPartyBOpenIntentIndex()

Return the index of an intent within the PartyA or PartyB active intents array respectively. Used internally for efficient array management and exposed here for debugging and off-chain reconciliation.

getLastOpenIntentId()

Returns the most recently assigned open intent ID.


State Control Storage Views

Individual Pause State Checks

Each operation type has its own boolean pause flag with a dedicated getter. These are the same flags toggled by ControlFacet's pause/unpause functions:

getAllPauseStates()

Returns all eleven pause flags plus the global PartyB emergency mode status in a single call. The most efficient way for a frontend or monitoring system to get a complete picture of the protocol's operational state.

Example Response:

isPartyBsEmergencyMode()

Returns whether the system-wide PartyB emergency mode is currently active.

isPartyBInEmergencyMode()

Returns whether a specific PartyB address is currently in individual emergency mode.

isAddressSuspended()

Returns whether a given address has been suspended from protocol operations.

isWithdrawalSuspended()

Returns whether a specific withdrawal by ID has been suspended and cannot currently be completed or cancelled.


Access Control Storage Views

hasRole()

Returns whether a given address holds a specific role.

getRoleMembers()

Returns the full array of addresses that currently hold a given role. Uses the enumerable set stored in AccessControlStorage.

getRoleMemberCount()

Returns the number of addresses holding a given role — cheaper than fetching the full array.

getRoleMember()

Returns the address at a specific index within the members of a role. Useful for iterating role membership without fetching the entire array.


Symbol Storage Views

getOracle()

Returns the full Oracle struct for a given oracle ID — including the oracle's name and contract address.

Example Response:

getLastOracleId()

Returns the most recently assigned oracle ID — the upper bound for iterating all registered oracles.

getSymbol()

Returns the full Symbol struct for a given symbol ID — including name, option type, oracle ID, collateral, platform fee, symbol type, and validity status.

Example Response:

getSymbols()

Returns a paginated array of Symbol structs. start is a symbol ID offset; size controls how many to return. Returns an empty array if start exceeds the last symbol ID.

getLastSymbolId()

Returns the most recently assigned symbol ID.


Trade Storage Views

getTrade()

Returns the full Trade struct for a given trade ID — including PartyA, PartyB, all trade agreement terms, current quantity, status, and settlement data.

getActiveTradeIdsOfPartyA()

Returns all currently active trade IDs for a given PartyA address.

getActiveTradesOfPartyA()

Returns paginated Trade structs for a PartyA's active positions. Use start and size to page through large portfolios.

getActiveTradeIdsForPartyB()

Returns all active trade IDs for a given PartyB scoped to a specific collateral token.

getPartyATradeIndex() & getPartyBTradeIndex()

Return the index of a trade within the PartyA or PartyB active trades array respectively. Exposed for off-chain reconciliation and debugging.

getLastTradeId()

Returns the most recently assigned trade ID.


Computed Open Intent Views

These functions use the same fee and premium calculation logic as the protocol itself, letting callers simulate values before submitting transactions.

getOpenIntentPlatformFee()

Calculates the platform fee that would be charged when an open intent is filled, using the intent's stored fee structure and price.

getOpenIntentAffiliateFee()

Calculates the affiliate fee applicable to the open intent's fill at the stored price.

getOpenIntentPremium()

Calculates the total premium for the open intent at the stored price — what PartyA pays to PartyB to open the options position.

getOpenIntentPremiumProportional()

Calculates the premium for the open intent at a supplied price rather than the stored one. Useful for simulating fill outcomes at different price points.


Computed Close Intent Views

getCloseIntentPlatformFee()

Calculates the platform fee for closing a given quantity of a close intent at the specified price.

getCloseIntentAffiliateFee()

Calculates the affiliate fee for closing a given quantity of a close intent at the specified price.


Computed Trade Views

getTradeOpenAmount()

Returns the currently open (unfilled) quantity of a trade — the original quantity minus any amount that has already been partially closed.

getTradeAvailableAmountToClose()

Returns the quantity of a trade that is currently available to close — the open amount minus any quantity already locked in pending close intents.

getTradePnl()

Calculates the P&L for a trade at a given current price and for a specified filled amount. Uses the same calculation logic as the settlement engine.

getTradePremium()

Returns the total premium amount for a trade — what was paid to open the options position.

getTradeExerciseFee()

Calculates the exercise fee that would be charged for a trade given a settlement price and the computed P&L. Applies the trade's stored ExerciseFee rate and cap.

Last updated