Created
May 9, 2023 23:31
-
-
Save bzpassersby/30229b2d9551c3e9b243a9d96e152aa6 to your computer and use it in GitHub Desktop.
JUSDView reverts when oracle adaptor is replaced with a secondary adaptor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: UNLICENSED | |
| pragma solidity ^0.8.9; | |
| import "./JUSDBankInit4.t.sol"; | |
| import "../../src/utils/JUSDError.sol"; | |
| import "../../src/oracle/UniswapPriceAdaptor.sol"; | |
| import "../mocks/MockUniswapOracle.sol"; | |
| import "../mocks/MockEmergencyOracle.sol"; | |
| contract SecondaryOracleRevertsTest is JUSDBankInitTest { | |
| MockUniswapOracle public mockUniswapOracle; | |
| MockEmergencyOracle public mockEmergencyOracle; | |
| UniswapPriceAdaptor public uniswapPriceAdaptor; | |
| function test_secondaryOracle_reverts() public { | |
| uniswapPriceAdaptor = new UniswapPriceAdaptor( | |
| address(mockUniswapOracle), | |
| 18, | |
| address(mockToken1), | |
| address(USDC), | |
| 600, | |
| address(mockEmergencyOracle), | |
| 1e17 | |
| ); | |
| mockToken1.transfer(alice, 10 * ONE); | |
| vm.startPrank(alice); | |
| mockToken1.approve(address(jusdBank), 10 * ONE); | |
| jusdBank.deposit(alice, address(mockToken1), 10 * ONE, alice); //Alice deposited 10 weth | |
| vm.warp(1000); | |
| jusdBank.borrow(100e6, alice, false); // Alice borrowed 100 JUSD | |
| vm.stopPrank(); | |
| jusdBank.updateOracle( | |
| address(mockToken1), | |
| address(uniswapPriceAdaptor) | |
| ); // Update JusdBank with uniswapPriceAdaptor | |
| vm.startPrank(alice); | |
| vm.expectRevert(); | |
| jusdBank.withdraw(address(mockToken1), 1e18, alice, false); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment