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: add mock oracle #11

Merged
merged 3 commits into from
Feb 15, 2024
Merged

feat: add mock oracle #11

merged 3 commits into from
Feb 15, 2024

Conversation

md0x
Copy link
Contributor

@md0x md0x commented Feb 13, 2024

Changes proposed in this PR:

  • Add Mock Chainlink Oracle
  • Fix naming inconsistencies in events

md0x added 2 commits February 13, 2024 19:15
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>

// This function is part of the AccessControlledOffchainAggregator interface. It is used to
// update the new price and look like a transmit function from a real Chainlink Aggregator
function transmit(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the transmit function from the AccessControlledOffchainAggregator so we don't need a second mock oracle.

By setting aggregator = address(this) in the constructor we mock the aggregator as well. This is useful for monitoring transmit calls in the backrunner mempool technique.

constructor(uint8 _decimals, int256 _initialAnswer) {
decimals = _decimals;
updateAnswer(_initialAnswer);
aggregator = address(this); // For simplicity, we set the aggregator address to the contract address
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this mock contract as the aggregator where new prices are pushed

@md0x md0x marked this pull request as ready for review February 13, 2024 19:28
Signed-off-by: Pablo Maldonado <pablo@umaproject.org>
Copy link

@Reinis-FRP Reinis-FRP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

contract HoneyPotDeploymentScript is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address chainlink = vm.envAddress("SOURCE_ADDRESS");
address chainlink = vm.envOr("SOURCE_ADDRESS", address(0));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the app run with address 0? if not just throw if not provided

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not provided it deploys a mock oracle

@md0x md0x merged commit 858038c into master Feb 15, 2024
3 checks passed
@md0x md0x deleted the pablo/add-mock-oracle branch February 15, 2024 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants