Helper Functions

Functions providing data commonly required by frontend displays.

See helpers.ts

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 ChainAddresses 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 ChainAbis 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:

  • Promise<OLMPricing> containing pricing data for the specified OLM.

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<OTokenData> containing data commonly required by frontend displays.