OptionsToken

The OptionsToken class provides read helpers and calldata builders for converting oHYDX option tokens into either liquid HYDX or locked veNFT positions.


Read Helpers

typescript
import { OptionsToken, OptionsTokenInfo, ExerciseQuote } from '@hydrexfi/hydrex-sdk';

// Read current options token config
const info: OptionsTokenInfo = await OptionsToken.getOptionsTokenInfo(readContracts);
// info.discount, .twapSeconds, .paymentToken, .underlyingToken, .isPaused

// Quote the payment cost for a given oHYDX amount
const quote: ExerciseQuote = await OptionsToken.getExerciseQuote(
  '1000000000000000000', // 1 oHYDX (raw)
  readContracts,
);
// quote.amount, .paymentAmount, .twapAmount, .paymentToken

Exercise to Liquid HYDX

Converts oHYDX into liquid HYDX. The caller must first approve the payment token to the options token contract.

typescript
// Approve the payment token (e.g. USDC) first, then:
const { calldata } = OptionsToken.exerciseToLiquidHydxCallParameters({
  amount: '1000000000000000000',        // oHYDX amount (raw)
  maxPaymentAmount: quote.paymentAmount, // from getExerciseQuote
  recipient: '0xYourWallet',
  deadlineSeconds: 600,                  // optional, defaults to 10 min
});
// Send tx to the options token contract

Exercise to Protocol Account (veNFT)

Converts oHYDX into a new locked veNFT position. The contract returns the minted NFT ID in the receipt.

typescript
// Convert oHYDX to a new locked veNFT
const { calldata } = OptionsToken.exerciseToProtocolAccountCallParameters({
  amount: '1000000000000000000',
  recipient: '0xYourWallet',
});

Exercise & Merge

Mints a new veNFT from oHYDX and immediately merges it into an existing one. Returns two sequential calls.

typescript
// Read the next veNFT id immediately before building (minimise race window)
const nextVeTokenId = await OptionsToken.getNextVeTokenId(veTokenReadContract);

// Returns two MethodParameters — submit as sequential transactions
const [exerciseCall, mergeCall] =
  OptionsToken.exerciseToProtocolAccountAndMergeCallParameters({
    amount: '1000000000000000000',
    recipient: '0xYourWallet',
    nextVeTokenId,       // id that will be minted by tx 1
    targetTokenId: 42n,  // existing veNFT to merge into
  });

// tx 1: exerciseCall  → options token contract
// tx 2: mergeCall     → veToken contract

Race condition

Read getNextVeTokenId immediately before building the merge parameters to minimize the window where another transaction could mint the same token ID first.
Hydrex

Hydrex is an Omni-Liquidity MetaDEX built on Base for Base, designed to bring new users onchain.

Paragraph

© 2026 Hydrex. All rights reserved.