# PriceFeed

## **Write Methods**

```
function fetchPrice(address _token) public returns (uint256)
```

Fetches the latest price for a token, updating storage if needed.

| Parameter | Type    | Description                    |
| --------- | ------- | ------------------------------ |
| `_token`  | address | Token address to get price for |

**Returns:**

| Value | Type    | Description                  |
| ----- | ------- | ---------------------------- |
| price | uint256 | Latest valid price for token |

## **View Methods**

```
function loadPrice(address _token) public view returns (uint256)
```

View-only function to fetch the current oracle price without updating storage.

| Parameter | Type    | Description            |
| --------- | ------- | ---------------------- |
| `_token`  | address | Token address to query |

**Returns:**

| Value | Type    | Description           |
| ----- | ------- | --------------------- |
| rate  | uint256 | Raw price from oracle |

**Note:** View function, doesn't update storage

## Structs

```
struct OracleRecord {
        IStdReference bandOracle;
        string base;
        string quote;
        uint32 heartbeat;
        bool isFeedWorking;
    }
```

```
struct PriceRecord {
        uint96 price;
        uint32 timestamp;
        uint32 lastUpdated;
    }
```

```
struct FeedResponse {
        uint256 rate;
        uint256 lastUpdatedBase;
        uint256 lastUpdatedQuote;
        bool success;
    }
```

## Events

```
event NewOracleRegistered(address token, address bandAggregator)
```

```
event PriceFeedStatusUpdated(address token, address oracle, bool isWorking)
```

```
event PriceRecordUpdated(address indexed token, uint256 _price)
```
