Skip to content

Commit

Permalink
forge fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
noot committed Dec 12, 2024
1 parent e9a404e commit a12a19d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 26 deletions.
21 changes: 12 additions & 9 deletions src/MockAggregator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@ import {AstriaOracle} from "./AstriaOracle.sol";
// Mock currency pair aggregator contract for a single currency pair.
contract MockAggregator is AggregatorV2V3Interface {
// core oracle contract
AstriaOracle immutable public oracle;
AstriaOracle public immutable oracle;

// currency pair hash
bytes32 immutable public currencyPairHash;
bytes32 public immutable currencyPairHash;

constructor(AstriaOracle _oracle, bytes32 _currencyPairHash) {
oracle = _oracle;
currencyPairHash = _currencyPairHash;
}

/* v2 aggregator interface */

function latestAnswer() external view returns (int256) {
(uint128 price, ) = oracle.priceData(oracle.latestBlockNumber(), currencyPairHash);
(uint128 price,) = oracle.priceData(oracle.latestBlockNumber(), currencyPairHash);
return int256(uint256(price));
}

Expand All @@ -33,7 +33,7 @@ contract MockAggregator is AggregatorV2V3Interface {
}

function getAnswer(uint256 roundId) external view returns (int256) {
(uint128 price, ) = oracle.priceData(roundId, currencyPairHash);
(uint128 price,) = oracle.priceData(roundId, currencyPairHash);
return int256(uint256(price));
}

Expand All @@ -56,17 +56,20 @@ contract MockAggregator is AggregatorV2V3Interface {
return 0;
}

function getRoundData(
uint80 _roundId
) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) {
function getRoundData(uint80 _roundId)
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
{
(uint128 price, uint256 timestamp) = oracle.priceData(_roundId, currencyPairHash);
return (_roundId, int256(uint256(price)), timestamp, timestamp, _roundId);
}

function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound) {
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
{
roundId = uint80(oracle.latestBlockNumber());
(uint128 price, uint256 timestamp) = oracle.priceData(roundId, currencyPairHash);
return (roundId, int256(uint256(price)), timestamp, timestamp, roundId);
Expand Down
14 changes: 7 additions & 7 deletions src/interfaces/AggregatorInterface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ pragma solidity ^0.8.0;
// https://github.com/smartcontractkit/chainlink/blob/dde17518ff7f3dd3fe1d53614f211357944516f0/contracts/src/v0.8/shared/interfaces/AggregatorInterface.sol
// solhint-disable-next-line interface-starts-with-i
interface AggregatorInterface {
function latestAnswer() external view returns (int256);
function latestAnswer() external view returns (int256);

function latestTimestamp() external view returns (uint256);
function latestTimestamp() external view returns (uint256);

function latestRound() external view returns (uint256);
function latestRound() external view returns (uint256);

function getAnswer(uint256 roundId) external view returns (int256);
function getAnswer(uint256 roundId) external view returns (int256);

function getTimestamp(uint256 roundId) external view returns (uint256);
function getTimestamp(uint256 roundId) external view returns (uint256);

event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);
event AnswerUpdated(int256 indexed current, uint256 indexed roundId, uint256 updatedAt);

event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
event NewRound(uint256 indexed roundId, address indexed startedBy, uint256 startedAt);
}
21 changes: 11 additions & 10 deletions src/interfaces/AggregatorV3Interface.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ pragma solidity ^0.8.0;
// https://github.com/smartcontractkit/chainlink/blob/dde17518ff7f3dd3fe1d53614f211357944516f0/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol
// solhint-disable-next-line interface-starts-with-i
interface AggregatorV3Interface {
function decimals() external view returns (uint8);
function decimals() external view returns (uint8);

function description() external view returns (string memory);
function description() external view returns (string memory);

function version() external view returns (uint256);
function version() external view returns (uint256);

function getRoundData(
uint80 _roundId
) external view returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
function getRoundData(uint80 _roundId)
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);

function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
function latestRoundData()
external
view
returns (uint80 roundId, int256 answer, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound);
}

0 comments on commit a12a19d

Please sign in to comment.