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

✦ Fix RiseTokenVaultExternal.t.sol #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dimasriat
Copy link
Contributor

✦ Fix RiseTokenVaultExternal.t.sol at testFail_ETHRISERebalanceInRangeShouldBeReverted

reason:
The test function should test the ETHRISE but it does the ERC20RISE instead.

before:

    function testFail_ETHRISERebalanceInRangeShouldBeReverted() public {
        // Create new price oracles for the collateral
        CustomizableOracle oracle = new CustomizableOracle();
        oracle.setPrice(15 * 1e6); // Set UNI price to 15 USDC

        // Create new swap contracts, with artificial slippage 0.05%
        CustomizableSwap swapContract = new CustomizableSwap(address(oracle), 0.005 ether);
        hevm.setUNIBalance(address(swapContract), 1_000_000 ether); // 1_000_000 UNI token
        hevm.setUSDCBalance(address(swapContract), 1_000_000 * 1e6); // 1_000_000 USDC token

        // Create new vaults for UNIRISE
        uint256 initialPrice = 10 * 1e6; // Initial price is 10 USDC
        (RiseTokenVault vault, RisedleERC20 unirise) = createNewVault(oracle, swapContract, false, UNI_ADDRESS, initialPrice);

        // Create the dummy users
        DummyUser user = new DummyUser(vault);
        hevm.setUNIBalance(address(user), 10 ether);

        // Mint UNIRISE
        user.mintWithERC20(address(unirise), 10 ether); // Mint UNIRISE with 10 UNI

        // Execute the rebalance; This should be failed
        vault.rebalance(address(unirise));
    }

after:

function testFail_ETHRISERebalanceInRangeShouldBeReverted() public {
        // Create new price oracles for the collateral
        CustomizableOracle oracle = new CustomizableOracle();
        oracle.setPrice(4_000 * 1e6); // Set ETH price to 4K USDC

        // Create new swap contracts, with artificial slippage 0.05%
        CustomizableSwap swapContract = new CustomizableSwap(address(oracle), 0.005 ether);
        hevm.setUSDCBalance(address(swapContract), 1_000_000 * 1e6); // 1_000_000 USDC
        hevm.setWETHBalance(address(swapContract), 1_000_000 ether); // 1_000_000 WETH

         // Create new vaults for ETHRISE
        uint256 initialPrice = 100 * 1e6; // Initial price is 100 USDC
        (RiseTokenVault vault, RisedleERC20 ethrise) = createNewVault(oracle, swapContract, true, WETH_ADDRESS, initialPrice);

        // Create the dummy users
        DummyUser user = new DummyUser(vault);
        sendETH(payable(address(user)), 1 ether);

        // Mint ETHRISE
        user.mintWithETH(address(ethrise), 1 ether);

        // Execute the rebalance; This should be failed
        vault.rebalance(address(ethrise));
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant