# Event Reference

The IFÁ Labs price oracle contract emits events whenever a price update is successfully pushed onchain. These events enable offchain monitoring, indexing, and real-time alerts for protocols relying on fresh data.

#### Emitted Events

**`PriceUpdated(bytes32 indexed assetId, int256 price, int8 decimal, uint64 timestamp)`**

Primary event emitted on every successful price update.

* **Parameters**:
  * `assetId` (indexed): The `bytes32` asset identifier (searchable in explorers).
  * `price`: The new scaled price value.
  * `decimal`: The scaling exponent (negative, e.g., -18).
  * `timestamp`: The block timestamp when the update was recorded (matches `lastUpdateTime`).

**Use Cases**:

* Indexing services (e.g., The Graph, Subsquid) track price history.
* Offchain monitors alert on updates or lack thereof.
* Protocols log price changes for analytics.

**Additional Internal Events (if present)**

Some deployments may include:

* `RelayerUpdate(address relayer, uint256 roundId)` — Tracks which decentralized relayer submitted the update.
* `SourceDataAdded(bytes32 assetId, address source)` — For advanced transparency (future expansions).

Check the verified contract source on Basescan for the exact events in your target deployment.

#### Example: Listening in JavaScript (ethers.js)

```javascript
const oracleAddress = "0xA9F17344689C2c2328F94464998db1d3e35B80dC";
const oracleABI = [ "event PriceUpdated(bytes32 indexed assetId, int256 price, int8 decimal, uint64 timestamp)" ];

const provider = new ethers.providers.WebSocketProvider("wss://mainnet.base.org");
const contract = new ethers.Contract(oracleAddress, oracleABI, provider);

contract.on("PriceUpdated", (assetId, price, decimal, timestamp, event) => {
    console.log(`Price update for ${assetId}: ${price / 10n ** -BigInt(decimal)} USD at ${timestamp}`);
});
```

Monitoring these events is a best practice for production systems to detect update frequency and potential delays.

Next: Download the **ABI** for seamless integration in your tools and contracts.
