OptionsMarket.sol
Last Updated At 30th Oct, 2024
OptionsMarket Interface Documentation
State-Changing Functions
addOptions
Adds new options for a specific underlying asset
Creates options with multiple strike prices
Sets expiration time for the options
addUnderlyingAsset
Registers a new underlying asset for options
Associates the asset with its options token
Assigns a new underlying asset index
removeOptions
Removes multiple options by their IDs
Deactivates the specified options
Updates the active options count
View Functions
activeOptionsCount
Returns the total number of active options
Used for system monitoring
getMainStableAsset
Returns the main stable asset address and decimals
Used for price calculations
getOptionDetail
Returns details of a specific option
Includes underlying asset index, address, expiry, and strike price
getOptionId
Generates a unique option ID from parameters
Pure function for consistent ID generation
getOptionTokenId
Generates token ID for option combinations
Used for complex option positions
Returns token ID and associated option IDs
getOptionsBatch
Returns details for multiple options in one call
Efficient batch retrieval of option information
getOptionsTokenByIndex
Returns the options token address for an underlying asset index
Used for token management
getUnderlyingAssetByIndex
Returns the underlying asset address and decimals for a given index
Used for asset management and calculations
indexToUnderlyingAsset
Maps an index to its underlying asset address
Used for asset lookup
isOptionAvailable
Checks if an option is active and available for trading
Used for validation
isUnderlyingAssetActive
Checks if an underlying asset is active in the system
Used for asset validation
mainStableAsset
Returns the address of the main stable asset
Used for price calculations and settlements
nextUnderlyingAssetIndex
Returns the next available index for underlying assets
Used when adding new assets
options
Returns complete details of an option
Includes all option parameters and status
optionsTokenToUnderlyingAsset
Maps an options token address to its underlying asset
Used for token-asset relationship lookup
registeredOptionsCount
Returns the total number of registered options
Includes both active and inactive options
underlyingAssetToIndex
Maps an underlying asset address to its index
Used for asset management
underlyingAssetToOptionsToken
Maps an underlying asset to its options token
Used for token management
validateOptionIds
Validates a set of option IDs
Checks consistency of underlying asset and expiry
Returns validation details
Administrative Functions
AuthorityUtil_init
Initializes the authority utility module
Sets up permission management system
initialize
Initializes the options market contract
Sets up initial parameters and authority
renounceOwnership
Allows owner to renounce their ownership
Security feature for decentralization
setAuthority
Updates the contract authority address
Used for permission management updates
setIsUnderlyingAsset
Sets the active status of an underlying asset
Controls which assets can be used for options
setMainStableAsset
Sets the main stable asset address
Used for price calculations and settlements
transferOwnership
Transfers contract ownership to a new address
Used for administrative control changes
Events
AddUnderlyingAsset
Emitted when a new underlying asset is added
Records the asset index, address, and associated options token
AuthorityUpdated
Emitted when the contract authority is updated
Records the new authority address
OptionStatusChanged
Emitted when an option's status changes
Records all relevant option details and new status
OwnershipTransferred
Emitted when contract ownership is transferred
Records both previous and new owner addresses
SetIsUnderlyingAsset
Emitted when an underlying asset's status is changed
Records the asset address and new active status
SetMainStableAsset
Emitted when the main stable asset is updated
Records the new stable asset address
UpdateOptionsToken
Emitted when an options token is updated for an asset
Records the underlying asset and new options token address