Skip to content

Functions

Vault-Only Functions

These functions revert if called by any address other than the authorized vault.

buyNoShares

function buyNoShares(uint256 assets)
    external
    returns (uint256 sharesAcquired, uint256 executionPrice)

Caller: Vault only

Description: Buy NO shares on the prediction market using USDC. Called by the vault during openPosition(). Returns a tuple — both values are used by the vault.

Returns:

Field Description
sharesAcquired NO shares received from the venue, in 1e18 precision
executionPrice Weighted average fill price in 1e18 fixed-point (e.g. 0.93e18 = $0.93). Assigned directly to position.entryPrice — the operator does not supply this value.

Implementation requirements:

  • If the order is split across multiple fills, executionPrice must be the weighted average fill price
  • Must revert if execution price exceeds entry slippage tolerance (maximum 50 bps)
  • Slippage check: revert if executionPrice > entryQuote × 1.005

sellNoShares

function sellNoShares(uint256 shares)
    external
    returns (uint256 actualSharesSold, uint256 usdcReceived)

Caller: Vault only

Description: Sell NO shares back to the prediction market for USDC. Rarely used — only called during emergencyLiquidate() when the system is paused.

Returns:

Field Description
actualSharesSold Shares actually sold, determined via before/after ERC-1155 balance diff. May be less than shares if the adapter's position is smaller than the requested amount.
usdcReceived USDC transferred back to the vault.

Implementation requirements:

  • The adapter must cap shares at its actual position size before filling — do not attempt to sell more than held
  • actualSharesSold must be computed via before/after balance diff, not by trusting the input value
  • Must revert if execution price is more than 200 bps (2%) below currentPrice() at call time. The operator should reduce maxShares and sell in smaller increments if the market is too thin.

claimSettlement

function claimSettlement() external returns (uint256 usdcReturned)

Caller: Vault only

Description: Claim settled funds after market resolution. Called by the vault during closePosition().

Pre-condition: isSettled() == true — must revert otherwise.

Behavior:

  1. Calls the venue's settlement claim mechanism
  2. Transfers all settlement USDC to the vault address in a single call
  3. Returns exact amount transferred
  4. Emits SettlementClaimed(usdcReturned, settlementPrice)

Public View Functions

These functions are callable by anyone and are used by the vault's pricing engine.

currentPrice

function currentPrice() external view returns (uint256)

Returns the current market price of NO shares on the venue, scaled to 1e18. For example, 0.93e18 = $0.93 per NO share.

Used by the vault to compute positionMarketValue and by the rebasePosition() constraints.


positionValue

function positionValue() external view returns (uint256)

Returns the current total USDC value of the adapter's NO share position:

positionValue = positionSize() × currentPrice() / 1e18

This is the value the vault uses as positionMarketValue(slotIndex) in the aggregate market NAV.


positionSize

function positionSize() external view returns (uint256)

Returns the number of NO shares currently held by the adapter, in 1e18 precision.


isSettled

function isSettled() external view returns (bool)

Returns true when the prediction market has resolved and settlement is final (oracle dispute window closed).

Must return false during dispute window

isSettled() must return false during any pending oracle dispute period. A premature true would allow markSettling() to be called before the outcome is final — a critical correctness requirement. Implement the dispute window check explicitly in the adapter.


Function Notes Summary

Function Key Implementation Requirement
buyNoShares Must return (sharesAcquired, executionPrice) as a tuple. Weighted average fill price if split across multiple fills. Revert if execution exceeds entry slippage tolerance (50 bps).
sellNoShares Returns (actualSharesSold, usdcReceived). Caps at actual position size; computes shares via balance diff. Revert if execution is more than 200 bps below currentPrice() at call time. Called exclusively from emergencyLiquidate.
isSettled Must return false during any oracle dispute window. Premature true causes markSettling() to be callable before outcome is final.
claimSettlement Must revert if isSettled() is false. Transfers all settlement USDC in a single call. Returns exact amount transferred.