Skip to content

Instantly share code, notes, and snippets.

@m9800
Last active December 18, 2023 19:22
Show Gist options
  • Save m9800/fa0533ce16d242279cf157758f123426 to your computer and use it in GitHub Desktop.
Save m9800/fa0533ce16d242279cf157758f123426 to your computer and use it in GitHub Desktop.
failingBurnPOC
contract FailingBurn is Test {
    address alice = address(0x01);

    ERC20SnapshotRebase public snapshotRebase;
    DummyERC20 public underlying;
    Controller public controller;
    EigenSharePricer public sharePricer;

    function setUp() public {
        underlying = new DummyERC20("dummyUnderlying", "DU");

        snapshotRebase = new ERC20SnapshotRebase();
        controller = new Controller(underlying, snapshotRebase);
        sharePricer = new EigenSharePricer(controller, snapshotRebase);

        IBaseERC20.ERC20Config memory config;
        config.name = "snapshotRebase";
        config.symbol = "SR";

        IBaseERC20.Features memory features;
        features.mintable = true;
        features.pausable = true;
        features.initialSupply = 0;
        features.initialSupplyHolder = address(0);
        features.allowControlled = true;

        IBaseERC20.Roles memory roles;
        roles.admin = address(this);

        snapshotRebase.initialize(config, features, roles, address(sharePricer));
        snapshotRebase.grantRole(
            snapshotRebase.CONTROLLER_ROLE(),
            address(controller)
        );
        snapshotRebase.grantRole(
            snapshotRebase.MINTER_ROLE(),
            address(controller)
        );        
        vm.label(address(snapshotRebase), "SNAPSHOTREBASE");
        vm.label(alice, "alice");
    }

    function test_FailingBurn() external {

        uint256 aliceDeposit = 1e18;
        deal(address(underlying), alice, aliceDeposit );


        // Alice Deposit
        vm.startPrank(alice);
        underlying.approve(address(controller), type(uint256).max);
        assertEq(snapshotRebase.sharesOf(alice), 0);
        controller.deposit(aliceDeposit);
        assertEq(snapshotRebase.sharesOf(alice), 1e18);
        vm.stopPrank();



        // Alice request
        vm.startPrank(alice);
        controller.requestWithdraw(1e18);
        assertEq(snapshotRebase.sharesOf(alice), 0);
        assertEq(snapshotRebase.sharesOf(address(controller)), 1e18);
        vm.stopPrank();

        controller.processWithdrawals(10);

        // Alice Redemption

        vm.startPrank(alice);
        controller.redeemUnderlying(1);
        assertEq(underlying.balanceOf(alice), 1e18);
        assertEq(underlying.balanceOf(address(controller)), 0); 
        assertEq(snapshotRebase.sharesOf(address(controller)), 1e18);
        vm.stopPrank();
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment