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

Add USD to ETH Chainlink oracle connector for LUSD #843

Merged
merged 1 commit into from
Apr 13, 2023
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
19 changes: 19 additions & 0 deletions packages/contracts/contracts/Integrations/LSUDUsdToLUSDEth.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.11;


interface IPriceFeed {
function latestAnswer() external view returns (int256);
}


contract LSUDUsdToLUSDEth is IPriceFeed {
IPriceFeed public constant LUSD_USD = IPriceFeed(0x3D7aE7E594f2f2091Ad8798313450130d0Aba3a0);
IPriceFeed public constant ETH_USD = IPriceFeed(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);

constructor() public {}

function latestAnswer() external view override returns (int256) {
return (LUSD_USD.latestAnswer() * 1 ether) / ETH_USD.latestAnswer();
}
}
5 changes: 3 additions & 2 deletions packages/contracts/hardhat.config.mainnet-fork.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ module.exports = {
},
networks: {
hardhat: {
accounts: accountsList,
// https://github.com/NomicFoundation/hardhat/issues/1226#issuecomment-774492503
//accounts: accountsList,
gas: 10000000, // tx gas limit
blockGasLimit: 12500000,
blockGasLimit: 12500000,
gasPrice: process.env.GAS_PRICE ? parseInt(process.env.GAS_PRICE) : 20000000000,
forking: {
url: alchemyUrl(),
Expand Down
36 changes: 36 additions & 0 deletions packages/contracts/mainnetDeployment/aaveEthOracleDeployment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Test with:
// GAS_PRICE=70832172907 BLOCK_NUMBER=15122486 npx hardhat run mainnetDeployment/aaveEthOracleDeployment.js --config hardhat.config.mainnet-fork.js

// Deploy on mainnet with:
// GAS_PRICE=40000000000 npx hardhat run mainnetDeployment/aaveEthOracleDeployment.js --network mainnet
// make sure you have the right private key for DEPLOYER_PRIVATEKEY in secrets.js

async function main() {
// Uncomment for testing:
/*
const impersonateAddress = "0x31c57298578f7508B5982062cfEc5ec8BD346247";
await hre.network.provider.request({
method: "hardhat_impersonateAccount",
params: [ impersonateAddress ]
});
const deployerWallet = await ethers.provider.getSigner(impersonateAddress);
const deployerWalletAddress = impersonateAddress;
*/

const deployerWallet = (await ethers.getSigners())[0];
const deployerWalletAddress = deployerWallet.address;
console.log('Deployer: ', deployerWalletAddress);

const LSUDUsdToLUSDEthEthersFactory = await ethers.getContractFactory("LSUDUsdToLUSDEth", deployerWallet)
const lsudUsdToLUSDEth = await LSUDUsdToLUSDEthEthersFactory.deploy()
console.log(`LSUDUsdToLUSDEth address: ${lsudUsdToLUSDEth.address}`)
console.log(`LSUDUsdToLUSDEth price: ${await lsudUsdToLUSDEth.latestAnswer()}`)

}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
});