Skip to content

Commit

Permalink
added crvusd to oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
jpick713 committed Apr 22, 2024
1 parent 8c3e15e commit d2e3756
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions contracts/peer-to-peer/oracles/custom/MysoOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ contract MysoOracle is ChainlinkBase, Ownable {
address internal constant RSWETH =
0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0;
address internal constant RPL = 0xD33526068D116cE69F19A9ee46F0bd304F21A51f;
address internal constant CRVUSD =
0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E;
address internal constant ANKRETH =
0xE95A203B1a91a908F9B9CE46459d101078c2c3cb;
address internal constant METH_STAKING_CONTRACT =
Expand All @@ -52,6 +54,8 @@ contract MysoOracle is ChainlinkBase, Ownable {
0x86392dC19c0b719886221c78AB11eb8Cf5c52812;
address internal constant RPL_USD_CHAINLINK =
0x4E155eD98aFE9034b7A5962f6C84c86d869daA9d;
address internal constant CRVUSD_USD_CHAINLINK =
0xEEf0C605546958c1f899b6fB336C20671f9cD49F;

uint256 internal constant MYSO_PRICE_TIME_LOCK = 5 minutes;

Expand Down Expand Up @@ -174,6 +178,8 @@ contract MysoOracle is ChainlinkBase, Ownable {
tokenPriceRaw = _getFXUSDPriceInEth();
} else if (token == RSWETH) {
tokenPriceRaw = IRSWETH(RSWETH).rswETHToETHRate();
} else if (token == CRVUSD) {
tokenPriceRaw = _getCRVUSDPriceInEth();
} else {
tokenPriceRaw = super._getPriceOfToken(token);
}
Expand Down Expand Up @@ -232,6 +238,20 @@ contract MysoOracle is ChainlinkBase, Ownable {
rplPriceRaw = Math.mulDiv(rplPriceInUSD, 1e18, ethPriceInUsd);
}

function _getCRVUSDPriceInEth()
internal
view
returns (uint256 crvUsdPriceRaw)
{
uint256 crvUsdPriceInUSD = _checkAndReturnLatestRoundData(
(CRVUSD_USD_CHAINLINK)
);
uint256 ethPriceInUsd = _checkAndReturnLatestRoundData(
ETH_USD_CHAINLINK
);
crvUsdPriceRaw = Math.mulDiv(crvUsdPriceInUSD, 1e18, ethPriceInUsd);
}

function _getFXUSDPriceInEth()
internal
view
Expand Down
3 changes: 3 additions & 0 deletions test/peer-to-peer/mainnet-myso-oracle-forked-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ describe('Peer-to-Peer: Myso Recent Forked Mainnet Tests', function () {
const ankreth = '0xE95A203B1a91a908F9B9CE46459d101078c2c3cb'
const fxusd = '0x085780639CC2cACd35E474e71f4d000e2405d8f6'
const rsweth = '0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0'
const crvusd = '0xf939E0A03FB07F59A73314E73794Be0E57ac1b4E'
const usdcToEthChainlinkAddr = '0x986b5E1e1755e3C2440e960477f25201B0a8bbD4'
//const daiToEthChainlinkAddr = '0x773616E4d11A78F511299002da57A0a94577F1f4'
const usdtToEthChainlinkAddr = '0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46'
Expand Down Expand Up @@ -253,6 +254,7 @@ describe('Peer-to-Peer: Myso Recent Forked Mainnet Tests', function () {
// const mysoCollFxUsdLoanPrice = await mysoOracle.getPrice(myso, fxusd)
const mysoCollRswethLoanPrice = await mysoOracle.getPrice(myso, rsweth)
//const mysoCollDaiLoanPrice = await mysoOracle.getPrice(myso, dai)
const mysoCollCrvusdLoanPrice = await mysoOracle.getPrice(myso, crvusd)

//toggle to show logs
const showLogs = true
Expand Down Expand Up @@ -304,6 +306,7 @@ describe('Peer-to-Peer: Myso Recent Forked Mainnet Tests', function () {
// console.log('myso coll, fxUsd', ethers.utils.formatUnits(mysoCollFxUsdLoanPrice, 18))
console.log('rsweth coll myso loan', ethers.utils.formatUnits(rswethCollMysoLoanPrice, 18))
console.log('myso coll rswEth', ethers.utils.formatUnits(mysoCollRswethLoanPrice, 18))
console.log('myso coll crvUsd', ethers.utils.formatUnits(mysoCollCrvusdLoanPrice, 18))
}

await mysoOracle.connect(team).setMysoPriceParams(70000000, ethers.BigNumber.from('800000000000000000'), 1770, 1000)
Expand Down

0 comments on commit d2e3756

Please sign in to comment.