Oracle

Retrieves underlying asset prices used for settling options.

setExternalOracle

Defines the underlying asset symbol and oracle address for a pool. Only called by the owner.

function setExternalOracle(string[] calldata symbols, address[] calldata oracles_) external onlyOwner 

Params:

Name

Type

Description

symbols

string

The asset symbol for which to retrieve price feed

oracles_

address

The external oracle address

setFixPrice

Sets the price for an asset.

function setFixPrice(string memory symbol, uint256 ts, uint256 price) external onlyOwner 

Params:

Name

Type

Description

symbol

string The symbol of the asset for which the price is being set

ts

uint256

The timestamp associated with the asset price

price

uint256

The retrieved price of the asset

getPriceByExternal

Gets and computes price from external oracles

function getPriceByExternal(address cOracleAddr, uint256 ts) external view returns (uint256 price, uint256 actualTs)

Params:

Name

Type

Description

cOracleAddr

address

The contract address for a chainlink price feed

ts

uint256

Timestamp for the asset price

Returns:

Name

Type

Description

price

uint256

The retrieved price

actualTs

uint256

The timestamp at which the price is updated by the oracle

_getPrice

This internal helper function retrieves the underlying price from an external oracle.

    function _getPrice(
        AggregatorV3Interface cOracle,
        uint80 id,
        uint256 ts,
        uint256 decimalDiff
    )
        private
        view
        returns (uint256 finalPrice, uint256 finalTs)

Params:

Name

Type

Description

cOracle

AggregatorV3Interface

Oracle interface for retrieving price feed

id

uint80

The roundId using which price is retrieved

ts

uint256

Timestamp for the asset price

decimalDiff

uint256

Precision differences for the number of decimal places

Returns:

Name

Type

Description

finalPrice

uint256

The computed price

finalTs

uint256

The timestamp at which the price is updated by the oracle

getCOracle

Returns the address of the chainlink oracle for an underlying asset

function getCOracle(string memory symbol) public view returns (address)

Params:

Name

Type

Description

symbol

string

The symbol of the asset for which the price is being set

Returns:

Type

Description

address

The contract address for a chainlink price feed

_getPhaseIdFromRoundId

Returns the phaseId from the given roundId used by the external oracle

function _getPhaseIdFromRoundId(uint80 roundId) internal pure returns (uint80) 

Params:

Name

Type

Description

roundId

uint80

The given roundId

Returns:

Type

Description

uint80

The phaseId for the given round

_getStartRoundId

Returns the start roundId given a phaseId

function _getStartRoundId(uint80 phaseId) internal pure returns (uint80)

Params:

Name

Type

Description

phaseId

uint80

The given phaseId

Returns:

Type

Description

uint80

The start roundId

_getPriceInPhase

Helper for getting the

    function _getPriceInPhase(
        AggregatorV3Interface cOracle,
        uint80 start,
        uint80 end,
        uint256 ts,
        uint256 decimalDiff
    )
        internal
        view
        returns (uint256 price, uint256 actualTs)

Params:

Name

Type

Description

cOracle

AggregatorV3Interface

Oracle interface for retrieving price feed

start

uint80

The start phaseId

end

uint80

The end phaseId

ts

uint256

Timestamp for the underlying price

decimalDiff

uint256

Precision differences for the number of decimal places

Returns:

Name

Type

Description

Price

uint256

The computed price

actualTs

uint256

The timestamp at which the price is updated by the oracle

Last updated