For the complete documentation index, see llms.txt. This page is also available as Markdown.

CorkPoolManager

Singleton pool manager — all pool state, queries, previews, and raw operations

Address: 0xccCCcCcCCccCfAE2Ee43F0E727A8c2969d74B9eC (same on all chains)

CorkPoolManager is the singleton contract that holds all Cork Pool state and executes all pool operations. Use it directly for read operations. For write operations, use CorkAdapter which adds slippage and deadline protection.

Query Functions

These are the primary read functions for integrators.

swapRate

function swapRate(MarketId poolId) external view returns (uint256 rate)

Returns the exchange rate between Reference Asset and Collateral Asset, scaled to 18 decimals.

Interpretation: 1 Reference Asset = rate / 1e18 Collateral Assets.

Example: a rate of 0.82e18 (820000000000000000) means 1 Reference Asset is worth 0.82 Collateral Assets.

const rate = await client.readContract({
  address: CORK_POOL_MANAGER,
  abi: poolManagerAbi,
  functionName: 'swapRate',
  args: [MARKET_ID],
})
// rate = 820000000000000000n → 1 REF = 0.82 CA

assets

Returns the pool's Collateral Asset and Reference Asset balances in their native token decimals.

shares

Returns the Cork Principal Token (cPT) and Cork Swap Token (cST) contract addresses for a given market.

market

Returns the full Market configuration struct (all 8 fields). See Key Concepts below.

getId

Computes a MarketId from a Market struct. Useful for on-chain MarketId derivation.


Preview Functions

Preview functions return the expected output of an operation without executing it. Use them for UI quotes, pre-flight checks, and computing slippage parameters for CorkAdapter.

Preview functions return 0 (or all zeros for multi-value returns) if the operation is currently paused or if the pool has expired (for pre-expiry operations).

Deposit Previews

Unwind Deposit Previews

Withdraw Previews

Redeem Preview

Exercise Previews

Unwind Exercise / Swap Previews


Max Functions

Returns the maximum amount the given address can use for each operation. Accounts for token balances, allowances, and pool liquidity.


Fee Functions

Fees use 18-decimal precision: 1e18 = 1%. The maximum allowed fee is 5e18 (5%). Fees apply to exercise/swap and unwind exercise/swap operations.


Raw Operation Functions

CorkPoolManager exposes all pool operations directly. These functions execute the operation without slippage or deadline checks.


Key Concepts

Market Struct

Every Cork Pool is defined by a Market struct containing 8 fields:

Field
Type
Description

collateralAsset

address

The yield-bearing asset deposited into the pool (e.g., sUSDe)

referenceAsset

address

The asset whose risk is being hedged (e.g., vbUSDC)

expiryTimestamp

uint256

Unix timestamp when the pool expires

rateMin

uint256

Minimum swap rate the oracle can return (18 decimals). Rates below this are clamped.

rateMax

uint256

Maximum swap rate the oracle can return (18 decimals). Rates above this are clamped.

rateChangePerDayMax

uint256

Maximum allowed rate change per day in absolute value (18 decimals)

rateChangeCapacityMax

uint256

Maximum accumulated rate change capacity (18 decimals). Caps how much rate can change even if rateChangePerDayMax allows more.

rateOracle

address

Oracle contract providing the rate between Reference Asset and Collateral Asset

MarketId Computation

A MarketId is the keccak256 hash of the ABI-encoded Market struct:

In TypeScript with viem:

You can also compute it on-chain by calling getId(Market) on CorkPoolManager.

A MarketId is deterministic — the same Market parameters always produce the same MarketId, regardless of which chain you compute it on.

Operations Table

Before Expiry

Operation
You Provide
You Receive
Pool Effect

Deposit / Mint

Collateral Asset

cPT + cST

CA ↑

Unwind Deposit

cPT + cST

Collateral Asset

CA ↓

Withdraw

cPT

CA + REF (proportional)

CA ↓, REF ↓

Exercise (swap / exercise)

REF + cST

Collateral Asset - Fee

CA ↓, REF ↑, cST ↑

Repurchase (unwindSwap / unwindExercise)

Collateral Asset

REF + cST

CA ↑, REF ↓, cST ↓

After Expiry

Operation
You Provide
You Receive

Redeem

cPT

CA + REF (proportional to pool composition)

Swap Rate Formula

The swap rate determines how much Collateral Asset you receive per Reference Asset when exercising:

Example: with swapRate = 0.82e18, exercising with 100 REF returns 82 CA (before fees). The exercise also consumes cST — see previewExercise for exact amounts.

Decimal Normalization

All Cork Principal Token (cPT) and Cork Swap Token (cST) amounts use 18 decimals, regardless of the underlying token's decimals. When the Collateral Asset or Reference Asset has different decimals (e.g., USDC with 6 decimals), the protocol normalizes internally.

  • Input amounts to contract functions should be in the token's native decimals (e.g., 6 decimals for USDC-based assets)

  • Share amounts (cPT, cST) are always 18 decimals

  • Swap rates and fees are always 18 decimals

Pause Bitmap

Each pool has a 5-bit pause bitmap controlling which operations are active:

Bit
Operation

0

Deposit

1

Swap / Exercise

2

Withdrawal

3

Unwind Deposit / Unwind Mint

4

Unwind Swap / Exercise

Query the pause state via getPausedBitMap(MarketId) or use the DefaultCorkController convenience functions (isDepositPaused, isSwapPaused, etc.) documented in Admin & Governance.

Last updated