Skip to content

Commit

Permalink
added arbitrum oracle tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpick713 committed Apr 22, 2024
1 parent 2561f3d commit 817fc96
Show file tree
Hide file tree
Showing 3 changed files with 501 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {IGTOKEN} from "../../interfaces/oracles/IGTOKEN.sol";
/**
* @dev supports oracles which are compatible with v2v3 or v3 interfaces
*/
contract MysoOracle is ChainlinkArbitrumSequencerUSD, Ownable {
contract MysoArbitrumUsdOracle is ChainlinkArbitrumSequencerUSD, Ownable {
struct PriceParams {
// maxPrice is in 8 decimals for chainlink consistency
uint96 maxPrice;
Expand Down Expand Up @@ -190,11 +190,6 @@ contract MysoOracle is ChainlinkArbitrumSequencerUSD, Ownable {
uint256 assetPriceInUsd = _checkAndReturnLatestRoundData(
chainlinkOracle
);
uint256 tokenPriceInUsd = _getPriceOfToken(token);
gTokenPriceRaw = Math.mulDiv(
tokenPriceInUsd * assetsPerGtoken,
1e8,
assetPriceInUsd * 1e18
);
gTokenPriceRaw = Math.mulDiv(assetsPerGtoken, assetPriceInUsd, 1e18);
}
}
11 changes: 11 additions & 0 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ export const getMysoOracleMainnetForkingConfig = () => {
return { chainId: chainId, url: url, blockNumber: blockNumber }
}

export const getMysoOracleArbitrumForkingConfig = () => {
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY
if (ALCHEMY_API_KEY === undefined) {
throw new Error('Invalid hardhat.config.ts! Need to set `ALCHEMY_API_KEY`!')
}
const chainId = 42161
const url = `https://arb-mainnet.g.alchemy.com/v2/${ALCHEMY_API_KEY}`
const blockNumber = 196000000 // 2024-03-31 (4AM UTC)
return { chainId: chainId, url: url, blockNumber: blockNumber }
}

export const getArbitrumForkingConfig = () => {
const ALCHEMY_API_KEY = process.env.ALCHEMY_API_KEY
if (ALCHEMY_API_KEY === undefined) {
Expand Down
Loading

0 comments on commit 817fc96

Please sign in to comment.