Skip to content

Conversation

@godzillaba
Copy link
Contributor

previously, the following scenario was possible:

  1. alice+bob each deposit 100 usdc and get 100 shares
  2. subVault doubles in price, so the mastervault has totalAssets == 400, totalPrincipal == 200
  3. alice withdraws her 100 shares for 200 usdc, now totalAssets == 200, totalPrincipal == 0
  4. fee manager withdraws profit of 200, now there are no assets left and bob is left with no money
    /**
     * @dev Withdraw/redeem common workflow.
     */
    function _withdraw(
        address caller,
        address receiver,
        address _owner,
        uint256 assets,
        uint256 shares
    ) internal virtual override whenNotPaused {
        totalPrincipal -= assets;

        IERC4626 _subVault = subVault;
        if (address(_subVault) != address(0)) {
            _subVault.withdraw(assets, address(this), address(this));
        }

        super._withdraw(caller, receiver, _owner, assets, shares);
    }

this is a WIP attempt to account for fees continuously. it works by changing the internal _convertToAssets and _convertToShares functions to calculate profit and set it aside before proceeding with calculation.

it still needs a function to actually withdraw the fees, but i'm focusing on the accounting for now.

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.

2 participants