LogoLogo
WebsiteGithubCommunity Docs
  • Developer Docs
  • Smart Contracts
    • Bond System
      • Auctioneer
        • Auctioneer Interfaces
        • Sequential Dutch Auctioneer (SDA)
          • Auction Pricing
          • Fixed-Term SDA
          • Fixed-Expiry SDA
        • Fixed Price Auctioneer (FPA)
          • Fixed-Term FPA
          • Fixed-Expiry FPA
        • Oracle-based Auctioneers
          • Oracle Interface
        • Oracle Fixed Discount Auctioneer (OFDA)
          • Fixed-Term OFDA
          • Fixed-Expiry OFDA
        • Oracle Sequential Dutch Auctioneer (OSDA)
          • Fixed-Term OSDA
          • Fixed-Expiry OSDA
      • Teller
        • Teller Interfaces
        • Base Teller
        • Fixed-Expiry Teller
        • Fixed-Term Teller
      • Callback
        • Callback Interface
        • Base Callback
        • Sample Callback Contract
      • Aggregator
        • Aggregator Interface
        • Aggregator Contract
      • Intended User Actions
      • Limit Orders
    • Option System
      • Fixed Strike oTokens
      • Fixed Strike Option Teller
      • Options Liquidity Mining (OLM)
        • Manual Strike OLM
        • Oracle Strike OLM
      • OLM Factories
  • Developers
    • Subgraph
    • Market Calculations
    • Purchases & Redemptions
    • User Balances
    • Options Library
      • Helper Functions
      • Types
  • References
    • Technical Resources
      • Audits
    • Community Resources
    • Brand Assets
    • Contact Us
Powered by GitBook
On this page
  • getAddressesForChain
  • getAbisForChain
  • getOLMInitializeBytecode
  • getOLMPricing
  • getOLMTokenList
  • getOTokenData
  1. Developers
  2. Options Library

Helper Functions

Functions providing data commonly required by frontend displays.

PreviousOptions LibraryNextTypes

See

getAddressesForChain

Gets the addresses of pre-deployed contracts for the Option system on the specified chain.

At launch, these should be identical across all chains, but this is included in case they diverge for some reason in the future.

Parameters:

  • chainId (number) - the chain id to get addresses for.

Returns:

  • A object, containing the addresses of contracts deployed on the specified chain.

getAbisForChain

Gets the ABIs of Option system contracts on the specified chain.

At launch, these should be identical across all chains, but this is included in case they diverge for some reason in the future.

Parameters:

  • chainId (number) - the chain id to get ABIs for.

Returns:

  • A object, containing the ABIs of contracts deployed on the specified chain.

getOLMInitializeBytecode

Hex encodes the provided parameters in the correct format for the OLM's initialize function. This is compatible with both MOLM and OOLM contracts.

Parameters:

  • quoteTokenAddress (0x${string}) - Token that stakers must pay to exercise the call options they receive.

  • timeUntilEligible (number) - Amount of time (in seconds) from option token deployment to when it can be exercised.

  • eligibleDuration (number) - Amount of time (in seconds) from when the option token is eligible to when it expires.

  • receiver (0x${string}) - Address that will receive the quote tokens when an option is exercised. IMPORTANT: receiver is the only address that can retrieve payout token collateral from expired options. It must be able to call the reclaim function on the Option Teller contract.

  • epochDuration (number) - Staking epoch duration (in seconds).

  • epochTransitionReward (number) - Amount of option tokens that are rewarded for starting a new epoch.

  • rewardRate (string) - Amount of option tokens rewarded per reward period (1 day).

  • allowlistAddress (0x${string}) - Address of the allowlist contract that can be used to restrict who can stake in the OLM contract. If the zero address, then no allow list is used.

  • allowlistParams (string) - Parameters that are passed to the allowlist contract when this contract registers with it.

  • other (string) - Additional parameters that are required by specific implementations of the OLM contract.

  • chainId (number) - The chain id on which the transaction will be executed.

Returns:

  • A 0x${string} consisting of the hex-encoded bytecode for the OLM initialize function. This can be copied and executed manually.

getOLMPricing

Calculates OLM pricing information which is commonly required for front end displays.

Parameters:

  • olmAddress (0x${string}) - Address of the OLM contract to get pricing for.

  • payoutPriceUSD (number) - The current price of the Payout Token in USD.

  • quotePriceUSD (number) - The current price of the Quote Token in USD.

  • stakedTokenPriceUSD (number) - The current price of the Staked Token in USD.

  • publicClient (PublicClient) - A Viem PublicClient.

Returns:

getOLMTokenList

Returns a list of addresses for Option Tokens created by an OLM, in order of epoch.

Parameters:

  • olmAddress (0x${string}) - Address of the OLM contract to get a token list for.

  • publicClient (PublicClient) - A Viem PublicClient.

Returns:

  • Promise<string[]> containing a list of addresses for Option Tokens created by the specified OLM, in order of epoch.

getOTokenData

Gathers Option Token data commonly required by front end displays.

Parameters:

  • oTokenAddress (0x${string}) - Address of the Option Token to get data for.

  • publicClient (PublicClient) - A Viem PublicClient.

  • userAddress (0x${string}) [OPTIONAL] - The address of a user to check Option Token balances for. If not provided, a balance of 0 will be returned for all Option Tokens.

Returns:

Promise<> containing pricing data for the specified OLM.

Promise<> containing data commonly required by frontend displays.

helpers.ts
ChainAddresses
ChainAbis
OLMPricing
OTokenData