Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cleanup external oracle #6

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"prettier-plugin-solidity": "^1.1.1"
},
"dependencies": {
"@bgd-labs/aave-cli": "^0.16.2",
"@bgd-labs/aave-cli": "^0.16.3",
"catapulta-verify": "^1.1.1"
}
}
21 changes: 3 additions & 18 deletions src/periphery/contracts/static-a-token/StataOracle.sol
Original file line number Diff line number Diff line change
@@ -1,40 +1,25 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.10;

import {IPool} from '../../../core/contracts/interfaces/IPool.sol';
import {IPoolAddressesProvider} from '../../../core/contracts/interfaces/IPoolAddressesProvider.sol';
import {IAaveOracle} from '../../../core/contracts/interfaces/IAaveOracle.sol';
import {IStaticATokenLM} from './interfaces/IStaticATokenLM.sol';
import {IStataOracle} from './interfaces/IStataOracle.sol';
import {IERC4626} from './interfaces/IERC4626.sol';

/**
* @title StataOracle
* @author BGD Labs
* @notice Contract to get asset prices of stata tokens
*/
contract StataOracle is IStataOracle {
/// @inheritdoc IStataOracle
IPool public immutable POOL;
/// @inheritdoc IStataOracle
IAaveOracle public immutable AAVE_ORACLE;

constructor(IPoolAddressesProvider provider) {
POOL = IPool(provider.getPool());
AAVE_ORACLE = IAaveOracle(provider.getPriceOracle());
}

/// @inheritdoc IStataOracle
function getAssetPrice(address asset) public view returns (uint256) {
address underlying = IERC4626(asset).asset();
return
(AAVE_ORACLE.getAssetPrice(underlying) * POOL.getReserveNormalizedIncome(underlying)) / 1e27;
return uint256(IStaticATokenLM(asset).latestAnswer());
}

/// @inheritdoc IStataOracle
function getAssetsPrices(address[] calldata assets) external view returns (uint256[] memory) {
uint256[] memory prices = new uint256[](assets.length);
for (uint256 i = 0; i < assets.length; i++) {
prices[i] = getAssetPrice(assets[i]);
prices[i] = uint256(IStaticATokenLM(assets[i]).latestAnswer());
}
return prices;
}
Expand Down
13 changes: 0 additions & 13 deletions src/periphery/contracts/static-a-token/interfaces/IStataOracle.sol
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import {IPool} from '../../../../core/contracts/interfaces/IPool.sol';
import {IAaveOracle} from '../../../../core/contracts/interfaces/IAaveOracle.sol';

interface IStataOracle {
/**
* @return The pool used for fetching the rate on the aggregator oracle
*/
function POOL() external view returns (IPool);

/**
* @return The aave oracle used for fetching the price of the underlying
*/
function AAVE_ORACLE() external view returns (IAaveOracle);

/**
* @notice Returns the prices of an asset address
* @param asset The asset address
Expand Down
2 changes: 1 addition & 1 deletion tests/periphery/static-a-token/StataOracle.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ contract StataOracleTest is BaseTest {

function setUp() public override {
super.setUp();
oracle = new StataOracle(contracts.poolAddressesProvider);
oracle = new StataOracle();

vm.prank(address(roleList.marketOwner));
contracts.poolConfiguratorProxy.setSupplyCap(UNDERLYING, 1_000_000);
Expand Down
2 changes: 1 addition & 1 deletion tests/utils/DiffUtils.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ contract DiffUtils is Test {

string[] memory inputs = new string[](7);
inputs[0] = 'npx';
inputs[1] = '@bgd-labs/aave-cli@^0.16.2';
inputs[1] = '@bgd-labs/aave-cli@^0.16.3';
inputs[2] = 'diff-snapshots';
inputs[3] = beforePath;
inputs[4] = afterPath;
Expand Down