Oracle
Initialization
constructor
constructor(address to)
Description
The constructor initializes the smart contract and sets the default roles. It also transfers ownership to the specified address and calculates the domain separator for EIP-712 signatures.
Parameters
to
address
The address to which ownership of the contract will be transferred during initialization.
Write Methods
updateObservation
function updateObservation(
uint144 value,
address[] calldata signers,
uint256[] calldata deadline,
uint8[] calldata v,
bytes32[] calldata r,
bytes32[] calldata s
) external
Description
The updateObservation
function is used to update the Oracle price if the following conditions are satisfied
All signers must reach a consensus and produce a signed message containing the same price observation
Each signed message must be created by a different signer
Each signed message must have a deadline not already passed
The number of signers is equal to or greater than the signer threshold
The cooldown period has elapsed since the last update
The percentage change between the old and new price observation is within an allowed delta
Parameters
value
uint144
The new observation value to be updated
signers
address[]
An array of addresses representing the signers involved in the update
deadline
uint256[]
An array of deadlines corresponding to each signatures
v
uint8[]
An array of the 'v' components of the ECDSA signatures
r
bytes32[]
An array of the 'r' components of the ECDSA signatures
s
bytes32[]
An array of the s' components of the ECDSA signatures
Emits
freeze
function freeze() external onlyOperators
Description
The freeze
function is an external function that allows designated operators to freeze the contract in case of emergency.
Emits
unfreeze
function unfreeze() external onlyOwner
Description
The unfreeze
function is an external function that allows the contract owner operators to unfreeze the contract to resume normal operativity.
Emits
setMaximumDeltaPercentage
function setMaximumDeltaPercentage(
uint32 maximumDeltaPercentage
) external onlyOwner
Description
The setMaximumDeltaPercentage
function is an external function that allows the owner of the contract to set the maximum allowed delta percentage for updates to the price observation.
Parameters
maximumDeltaPercentage
uint32
The new maximum allowed delta percentage for updates
Emits
setThreshold
function setThreshold(uint8 threshold) external onlyOwner
Description
The setThreshold
function is an external function that allows the owner of the contract to set the minimum required number of signers for updates to the observation state.
Parameters
theshold
uint8
The new minimum required number of signers
Emit
View Methods
PRECISION
uint256 public constant PRECISION
Description
The precision used by the contract to handle the observation value
HEARTBEAT
uint256 public constant HEARTBEAT
Description
The number of seconds the latest price observation is considered valid and up to date
get
function get(bytes memory) public view override returns (bool, uint256)
Description
The get
function is a public view function that allows external callers to retrieve information about the current observation state stored in the contract. It returns a boolean indicating the validity of the observation and the actual observation value.
Parameters
*
bytes
The function does not take any input parameters
Returns
observation
uint256
Latest price observation
Events
LogUpdateObservation
event LogUpdateObservation(
uint256 timestamp,
uint144 observation
)
Parameters
timestamp
uint256
No
observation
uint144
No
LogFrozenChanged
event LogFrozenChanged(
uint256 timestamp,
uint8 frozen
)
Parameters
timestamp
uint256
No
frozen
uint8
No
LogMaxDeltaPercentageChanged
event LogMaxDeltaPercentageChanged(
uint256 timestamp,
uint32 maxDeltaPercentage
)
Parameters
timestamp
uint256
No
maxDeltaPercentage
uint32
No
LogSignerThresholdChanged
event LogSignerThresholdChanged(
uint256 timestamp,
uint8 signerThreshold
)
Parameters
timestamp
uint256
No
signerThreshold
uint8
No
Last updated