> ## Documentation Index
> Fetch the complete documentation index at: https://docs.epicentral.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# Reference

> High-level exports of @epicentral/sos-sdk grouped by domain.

This page summarizes the high-level integrator exports from `@epicentral/sos-sdk` (`0.33.1`). Import all symbols from the package root. For full parameter interfaces and lower-level PDA or instruction helpers, inspect the bundled TypeScript definitions in `@epicentral/sos-sdk`.

## Program and Accounts

| Export | Purpose |
| - | - |
| `getProgramId` / `getProgramIdString` | Returns the Solana Option Standard program address. |
| `resolveOptionAccounts` | Derives PDAs for an Option Identity and optionally loads pool and vault state when `rpc` is passed. |
| `fetchAllOptionPools` / `fetchOptionPool` | Lists every `OptionPool` or fetches one by address. |
| `fetchAllVaults` / `fetchVault` | Lists all OMLP vaults or fetches one by address. |
| `fetchPositionAccountsByBuyer` / `fetchBuyerPosition` | Fetches Long `PositionAccount` records for a wallet or by address. |
| `fetchWriterPositionsByWriter` / `fetchWriterPositionsForPool` / `fetchWriterPosition` | Fetches `WriterPosition` accounts by Writer, by pool, or by address. |
| `fetchPoolLoansByMaker` / `fetchAllActivePoolLoans` / `fetchPoolLoan` | Fetches OMLP `PoolLoan` accounts by maker, across the protocol, or by address. |
| `fetchMarketDataAccount` / `fetchOptionAccount` / `fetchLenderPosition` | Single-account fetchers for Market Data, Option Series metadata, and OMLP lender positions. |

## Long Positions

| Export | Purpose |
| - | - |
| `preflightBuyFromPoolMarketOrder` | Verifies pool and Writer liquidity before opening a Long. |
| `buildBuyFromPoolMarketOrderTransactionWithDerivation` | Builds a single-leg market buy with premium and slippage protection. |
| `buildBuyFromPoolMultiFromIdentities` | Builds up to 4 Long buys sharing one underlying asset and payment mint. |
| `preflightCloseLongToPool` | Verifies sold-ring consistency before closing a Long. |
| `buildCloseLongToPoolTransactionWithDerivation` | Builds a single-leg Long close. Pass `closeLongTokenAccount: false` on partial closes. |
| `buildCloseLongToPoolMultiFromIdentities` | Builds up to 4 Long closes sharing one underlying asset and Collateral Mint. |

## Short Positions and OMLP Loans

| Export | Purpose |
| - | - |
| `deriveOptionSeriesLegAddresses` | Derives per-strike addresses for a multi-leg Short. |
| `findLegsNeedingSeriesInit` | Returns strikes that still need `init_option_series`. |
| `buildInitOptionSeriesInstruction` | Initializes an Option Series and `WriterPosition`. Chunk at `MAX_SERIES_INITS_PER_TRANSACTION` (`2`). |
| `buildOptionMintMultiTransactionWithDerivation` | Mints up to `MAX_MINT_LEGS` (`4`) Short legs per transaction. |
| `buildLeveragedOptionMintMultiWithBorrowTransaction` | Borrows from OMLP and mints in one instruction, up to `MAX_LEVERAGED_MINT_LEGS` (`4`) legs. |
| `buildBorrowFromPoolInstruction` | Borrows OMLP liquidity into a `WriterPosition` in a standalone instruction. |
| `buildRepayPoolLoanFromWalletInstruction` / `buildRepayPoolLoanInstruction` / `buildRepayPoolLoanFromCollateralInstruction` | Repays an OMLP loan from the maker wallet, escrow, or series collateral vault. |
| `preflightUnwindWriterUnsold` | Computes `effectiveUnwindQty` and active loan balances before unwinding. |
| `buildUnwindWriterUnsoldWithLoanRepayment` | Unwinds Unsold Size and repays active loans in one transaction. |
| `buildUnwindWriterUnsoldMultiWithLoanRepayment` | Unwinds up to 4 legs sharing one underlying asset and Collateral Mint. |

## Lending (OMLP)

| Export | Purpose |
| - | - |
| `buildDepositToPositionTransaction` | Deposits a Collateral Mint into its OMLP vault. |
| `buildWithdrawFromPositionTransaction` | Withdraws a chosen token amount from an OMLP vault. |
| `withdrawAllFromPosition` | Withdraws the lender's full share, capped by available vault cash. |
| `withdrawInterestFromPosition` | Withdraws accrued interest above cost basis, capped by available vault cash. |

## Transactions and Configuration

| Export | Purpose |
| - | - |
| `sendBuiltTransaction` | Signs, sends, and confirms a `BuiltTransaction`. Pass `version: 1`. |
| `DEFAULT_V1_LOADED_ACCOUNTS_DATA_SIZE_LIMIT` | Default `8 MiB` loaded-accounts budget for version 1 transactions. |
| `setGlobalTradeConfig` | Sets default slippage and compute-budget values for builders and sends. |

## Pricing, Oracles, and Test Collateral

| Export | Purpose |
| - | - |
| `resolvePythFeedIdFromMarketData` | Reads the Pyth feed ID stored on `MarketDataAccount`. |
| `pythPriceFeedAddress` | Derives the shard-0 Pyth price feed account passed as `priceUpdateAccount`. |
| `fetchPythPriceUpdateAccountData` / `evaluatePythPriceUpdate` / `pythPriceToNumber` | Loads, validates freshness (`maxAgeSeconds < 20`), and decodes a Pyth spot price. |
| `priceOption` | Bit-exact Black-Scholes premium and theta plus client-side Greeks for one unit of underlying. |
| `calculateRequiredCollateral` | Estimates Writer collateral in base units. Pass `"cash"` and Collateral Mint decimals. |
| `computeMinimumOpeningOwnCollateralBaseUnits` | Computes exact minimum own collateral for a Short leg to clear conservative opening margin (`OpeningMarginNotMet`, `6171`) and the vault leverage floor. |
| `calculateKinkImpliedVolatilityPpm` / `fairValuePerContractMicroUsd` / `stopOutFeeBaseUnits` | Integer kink-IV, capped fair value, and stop-out fee helpers mirroring onchain margin math. |
| `contractsToBaseUnits` / `baseUnitsToContracts` / `usdToMicroUsd` / `microUsdToUsd` / `fractionToPpm` / `ppmToFraction` | Scaling helpers for contract quantities (`1_000_000n` per contract), micro-USD prices, and ppm rates or volatility. |
| `requestTestUsdc` | Claims Devnet test USDC from the deployment faucet. |
| `OptionType` | `OptionType.Call` or `OptionType.Put`. |

## Errors

| Export | Purpose |
| - | - |
| `decodeSdkError` | Classifies any thrown error into an `SdkError` subclass. |
| `SdkValidationError` / `SdkOptionProgramError` / `SdkTransactionError` / `SdkRpcError` | Typed SDK error classes. |
| `getOptionProgramErrorInfo` | Looks up name and message metadata for a program error code (`6000`+). |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.