---
# System prepended metadata

title: Overview

---

# Test Task "Cooking Oracles" for Full Stack Position 

## Overview

At Gearbox, we utilize oracles to calculate the price of each token used as collateral. Our primary sources are Chainlink and RedStone oracles. Additionally, we deploy LP oracles when pricing assets that rely on smart-contract values. 

Obtaining raw data directly from smart contracts (SC) poses inherent risks. To mitigate these risks, we manually set a range of acceptable values that the system retrieves from smart contracts. For further details, watch this video: https://www.youtube.com/watch?v=I46OGQDf6E4.

## Task

Your objective is to develop a robust script to update all lower bounds within the system. In the Gearbox Protocol, LP capped oracles extend `LPPriceFeed.sol`, which is found here: https://github.com/Gearbox-protocol/oracles-v3/blob/main/contracts/oracles/LPPriceFeed.sol.

To update the `lowerBound`, the script should retrieve the current value and use it as the new center for the range (set the `lowerBound` to `value - 1%`).

Steps:
1. Extract a list of oracles from the `PriceOracle` contract by listening to events: https://github.com/Gearbox-protocol/core-v3/blob/832fe64d7194ad74b93543b1314da38aa6d413ea/contracts/core/PriceOracleV3.sol#L216.
2. Load their types from: https://github.com/Gearbox-protocol/core-v2/blob/98a984d37fa590e89ff976fe9e2a523b217d50ef/contracts/interfaces/IPriceFeedType.sol#L8. Use the provided enum for type classification: https://github.com/Gearbox-protocol/sdk-gov/blob/bff27a133f155c064be61a52ba3aa4552d8df978/src/oracles/pricefeedType.ts#L12-L32.
3. Retrieve the current price using the Chainlink `latestRoundData()` method, then subtract 1% from it.
4. Update the lower bound via: https://github.com/Gearbox-protocol/oracles-v3/blob/f53f67cb303e1de2788a6f844c50847c553b9d1b/contracts/oracles/LPPriceFeed.sol#L135.

## Output

The result should be a JSON file containing a list of operations formatted as follows:

```typescript
export interface RawTx {
	target: string;
	value: string;
	signature: string;
	data: string;
}
```

example:

![Screenshot 2024-05-01 at 12.57.42](https://hackmd.io/_uploads/SJgYXjkfR.png)


## Requirements

1. Use TypeScript, TypeChain, and Ethers 6.
2. Avoid hardcoded values except for the priceOracle address; all other values should be dynamically retrieved. Optimise data load when it's possible.
3. Adding automation to load transactions into @Safe would be a significant (HUGE!) advantage.
4. Please use this template repository: https://github.com/Gearbox-protocol/template-repository.
5. We love when candidates implement comprehensive error handling, a CLI interface, a README.txt, etc.