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

Added link price feed integration #31

Merged
merged 7 commits into from
Nov 27, 2021
Merged
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
32 changes: 32 additions & 0 deletions packages/hardhat/contracts/PriceConsumerV3.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract PriceConsumer {

AggregatorV3Interface internal priceFeed;

/**
* Network: Rinkeby
* Aggregator: LINK/USD
* Address: 0xd8bD0a1cB028a31AA859A21A3758685a95dE4623
*/
constructor() {
priceFeed = AggregatorV3Interface(0xd8bD0a1cB028a31AA859A21A3758685a95dE4623);
}

/**
* Returns the latest price
*/
function getLatestPrice() public view returns (int) {
(
uint80 roundID,
int price,
uint startedAt,
uint timeStamp,
uint80 answeredInRound
) = priceFeed.latestRoundData();
return price;
}
}
12 changes: 8 additions & 4 deletions packages/hardhat/deploy/00_deploy_your_contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ module.exports = async ({ getNamedAccounts, getChainId, deployments }) => {
const frontendAddress = process.env.FRONTENDADDRESS;
const receiverAddress = process.env.RECEIVERADDRESS;


const { deploy } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = await getChainId();
const deployerWallet = ethers.provider.getSigner();

const confirmationRequirement = chainId === "31337" ? 1 : 3;

console.log("Deployer Address: ", deployer);

await deploy("MoonSwap", {
// Learn more about args here: https://www.npmjs.com/package/hardhat-deploy#deploymentsdeploy
from: deployer,
// args: [ "Hello", ethers.utils.parseEther("1.5") ],
log: true,
});

await deploy("PriceConsumer", {
from: deployer,
log: true,
});

Expand Down Expand Up @@ -81,4 +85,4 @@ module.exports = async ({ getNamedAccounts, getChainId, deployments }) => {
});
}
};
module.exports.tags = ["MoonSwapV1"];
module.exports.tags = ["MoonSwapV1", "PriceConsumerV3"];
1 change: 1 addition & 0 deletions packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"eslint-plugin-prettier": "^3.4.0"
},
"dependencies": {
"@chainlink/contracts": "^0.2.2",
"@eth-optimism/hardhat-ovm": "^0.2.2",
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers",
"@nomiclabs/hardhat-waffle": "^2.0.0",
Expand Down
Loading