Skip to content

Commit

Permalink
added ankrEth to oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
jpick713 committed Mar 27, 2024
1 parent e7d218f commit 9e84949
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
11 changes: 11 additions & 0 deletions contracts/peer-to-peer/interfaces/oracles/IANKRETH.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

interface IANKRETH {
/**
* @notice gets amount of Eth for given ankrEth
* @param amount of ankrEth
* @return amount of eth
*/
function sharesToBonds(uint256 amount) external view returns (uint256);
}
5 changes: 5 additions & 0 deletions contracts/peer-to-peer/oracles/custom/MysoOracle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pragma solidity 0.8.19;
import {ChainlinkBase} from "../chainlink/ChainlinkBase.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IWSTETH} from "../../interfaces/oracles/IWSTETH.sol";
import {IANKRETH} from "../../interfaces/oracles/IANKRETH.sol";
import {IMETH} from "../../interfaces/oracles/IMETH.sol";
import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
Expand All @@ -26,6 +27,8 @@ contract MysoOracle is ChainlinkBase, Ownable {
0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0;
address internal constant METH = 0xd5F7838F5C461fefF7FE49ea5ebaF7728bB0ADfa;
address internal constant RPL = 0xD33526068D116cE69F19A9ee46F0bd304F21A51f;
address internal constant ANKRETH =
0xE95A203B1a91a908F9B9CE46459d101078c2c3cb;
address internal constant METH_STAKING_CONTRACT =
0xe3cBd06D7dadB3F4e6557bAb7EdD924CD1489E8f;
uint256 internal constant MYSO_IOO_BASE_CURRENCY_UNIT = 1e18; // 18 decimals for ETH based oracles
Expand Down Expand Up @@ -139,6 +142,8 @@ contract MysoOracle is ChainlinkBase, Ownable {
tokenPriceRaw = IMETH(METH_STAKING_CONTRACT).mETHToETH(1e18);
} else if (token == RPL) {
tokenPriceRaw = _getRPLPriceInEth();
} else if (token == ANKRETH) {
tokenPriceRaw = IANKRETH(ANKRETH).sharesToBonds(1e18);
} else {
tokenPriceRaw = super._getPriceOfToken(token);
}
Expand Down
11 changes: 11 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 @@ -175,6 +175,7 @@ describe('Peer-to-Peer: Myso Recent Forked Mainnet Tests', function () {
const usdc = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'
const dai = '0x6B175474E89094C44Da98b954EedeAC495271d0F'
const usdt = '0xdAC17F958D2ee523a2206206994597C13D831ec7'
const ankreth = '0xE95A203B1a91a908F9B9CE46459d101078c2c3cb'
const usdcToEthChainlinkAddr = '0x986b5E1e1755e3C2440e960477f25201B0a8bbD4'
const daiToEthChainlinkAddr = '0x773616E4d11A78F511299002da57A0a94577F1f4'
const usdtToEthChainlinkAddr = '0xEe9F2375b4bdF6387aa8265dD4FB8F16512A1d46'
Expand Down Expand Up @@ -219,6 +220,7 @@ describe('Peer-to-Peer: Myso Recent Forked Mainnet Tests', function () {
const daiCollMysoLoanPrice = await mysoOracle.getPrice(dai, myso)
const rplCollMysoLoanPrice = await mysoOracle.getPrice(rpl, myso)
const methCollMysoLoanPrice = await mysoOracle.getPrice(meth, myso)
const ankrethCollMysoLoanPrice = await mysoOracle.getPrice(ankreth, myso)

const mysoCollWethLoanPrice = await mysoOracle.getPrice(myso, weth.address)
const mysoCollWstEthLoanPrice = await mysoOracle.getPrice(myso, wsteth.address)
Expand Down Expand Up @@ -257,6 +259,10 @@ describe('Peer-to-Peer: Myso Recent Forked Mainnet Tests', function () {
'usdcCollMysoLoanPrice',
Math.round(1000000 * Number(ethers.utils.formatUnits(usdcCollMysoLoanPrice, 18).slice(0, 8))) / 1000000
)
console.log(
'ankrethCollMysoLoanPrice',
Math.round(1000000 * Number(ethers.utils.formatUnits(ankrethCollMysoLoanPrice, 18).slice(0, 8))) / 1000000
)
console.log(ethers.utils.formatUnits(wethCollMysoLoanPrice, 18))
console.log(ethers.utils.formatUnits(wstEthCollMysoLoanPrice, 18))
console.log(ethers.utils.formatUnits(rethCollMysoLoanPrice, 18))
Expand Down Expand Up @@ -296,6 +302,7 @@ describe('Peer-to-Peer: Myso Recent Forked Mainnet Tests', function () {
const rplCollMysoLoanPostPrice = await mysoOracle.getPrice(rpl, myso)
const methCollMysoLoanPostPrice = await mysoOracle.getPrice(meth, myso)
const usdcCollMysoLoanPostPrice = await mysoOracle.getPrice(usdc, myso)
const ankrethCollMysoLoanPostPrice = await mysoOracle.getPrice(ankreth, myso)
const mysoCollWethLoanPostPrice = await mysoOracle.getPrice(myso, weth.address)
const mysoCollWstEthLoanPostPrice = await mysoOracle.getPrice(myso, wsteth.address)
const mysoCollUsdcLoanPostPrice = await mysoOracle.getPrice(myso, usdc)
Expand Down Expand Up @@ -331,6 +338,10 @@ describe('Peer-to-Peer: Myso Recent Forked Mainnet Tests', function () {
'usdcCollMysoLoanPostPrice',
Math.round(1000000 * Number(ethers.utils.formatUnits(usdcCollMysoLoanPostPrice, 18).slice(0, 8))) / 1000000
)
console.log(
'ankrethCollMysoLoanPostPrice',
Math.round(1000000 * Number(ethers.utils.formatUnits(ankrethCollMysoLoanPostPrice, 18).slice(0, 8))) / 1000000
)
console.log(ethers.utils.formatUnits(wethCollMysoLoanPostPrice, 18))
console.log(ethers.utils.formatUnits(wstEthCollMysoLoanPostPrice, 18))
console.log(ethers.utils.formatUnits(rethCollMysoLoanPostPrice, 18))
Expand Down

0 comments on commit 9e84949

Please sign in to comment.