diff --git a/src/Vault.sol b/src/Vault.sol index 9a8fc49..0e8a342 100644 --- a/src/Vault.sol +++ b/src/Vault.sol @@ -507,32 +507,6 @@ contract Vault is ERC4626, ERC20Permit, ILiquidationSource, Ownable { return _assets; } - /** - * @notice Approve underlying asset with permit, deposit into the Vault and mint Vault shares to `_receiver`. - * @param _shares Amount of shares to mint to `_receiver` - * @param _receiver Address of the receiver of the vault shares - * @param _deadline Timestamp after which the approval is no longer valid - * @param _v V part of the secp256k1 signature - * @param _r R part of the secp256k1 signature - * @param _s S part of the secp256k1 signature - * @return uint256 Amount of assets deposited into the Vault. - */ - function mintWithPermit( - uint256 _shares, - address _receiver, - uint256 _deadline, - uint8 _v, - bytes32 _r, - bytes32 _s - ) external returns (uint256) { - uint256 _assets = _convertToAssets(_shares, Math.Rounding.Up); - - _permit(IERC20Permit(asset()), msg.sender, address(this), _assets, _deadline, _v, _r, _s); - _deposit(msg.sender, _receiver, _assets, _shares); - - return _assets; - } - /** * @notice Deposit assets into the Vault and delegate to the sponsorship address. * @param _assets Amount of assets to deposit diff --git a/test/unit/Vault/Deposit.feature b/test/unit/Vault/Deposit.feature index 5affed2..27cfdab 100644 --- a/test/unit/Vault/Deposit.feature +++ b/test/unit/Vault/Deposit.feature @@ -105,30 +105,6 @@ Feature: Deposit Then the YieldVault must mint to the Vault an amount of shares equivalent to the amount of underlying assets deposited Then the Vault `totalSupply` must be equal to 1,000 - # Mint with permit - Scenario: Alice mints with permit from the Vault - Given Alice owns 0 Vault shares - When Alice signs her transaction and mints 1,000 underlying assets - Then Alice must receive the amount of Vault shares requested - Then Alice `balance` must be equal to 1,000 - Then Alice `delegateBalance` must be equal to 1,000 - Then the YieldVault balance of underlying assets must increase by 1,000 - Then the YieldVault must mint to the Vault an amount of shares equivalent to the amount of underlying assets deposited - Then the Vault `totalSupply` must be equal to 1,000 - - Scenario: Alice mints with permit from the Vault on behalf of Bob - Given Alice owns 0 Vault shares and Bob owns 0 Vault shares - When Alice signs her transaction and mints 1,000 shares - Then Bob must receive 1,000 Vault shares - Then Alice must not receive any Vault shares - Then Alice `balance` must be equal to 0 - Then Alice `delegateBalance` must be equal to 0 - Then Bob `balance` must be equal to 1,000 - Then Bob `delegateBalance` must be equal to 1,000 - Then the YieldVault balance of underlying assets must increase by 1,000 - Then the YieldVault must mint to the Vault an amount of shares equivalent to the amount of underlying assets deposited - Then the Vault `totalSupply` must be equal to 1,000 - # Mint - Errors Scenario: Alice mints shares from the Vault Given Alice owns 0 Vault shares diff --git a/test/unit/Vault/Deposit.t.sol b/test/unit/Vault/Deposit.t.sol index ce04ee0..871a2ff 100644 --- a/test/unit/Vault/Deposit.t.sol +++ b/test/unit/Vault/Deposit.t.sol @@ -353,62 +353,6 @@ contract VaultDepositTest is UnitBaseSetup, BrokenToken { vm.stopPrank(); } - function testMintWithPermit() external { - vm.startPrank(alice); - - uint256 _amount = 1000e18; - underlyingAsset.mint(alice, _amount); - - vm.expectEmit(); - emit Transfer(address(0), alice, _amount); - - vm.expectEmit(); - emit Deposit(alice, alice, _amount, _amount); - - _mintWithPermit(underlyingAsset, vault, _amount, alice, alice, alicePrivateKey); - - assertEq(vault.balanceOf(alice), _amount); - - assertEq(twabController.balanceOf(address(vault), alice), _amount); - assertEq(twabController.delegateBalanceOf(address(vault), alice), _amount); - - assertEq(underlyingAsset.balanceOf(address(yieldVault)), _amount); - assertEq(yieldVault.balanceOf(address(vault)), _amount); - assertEq(yieldVault.totalSupply(), _amount); - - vm.stopPrank(); - } - - function testMintWithPermitOnBehalf() external { - vm.startPrank(alice); - - uint256 _amount = 1000e18; - underlyingAsset.mint(alice, _amount); - - vm.expectEmit(); - emit Transfer(address(0), bob, _amount); - - vm.expectEmit(); - emit Deposit(alice, bob, _amount, _amount); - - _mintWithPermit(underlyingAsset, vault, _amount, bob, alice, alicePrivateKey); - - assertEq(vault.balanceOf(alice), 0); - assertEq(vault.balanceOf(bob), _amount); - - assertEq(twabController.balanceOf(address(vault), alice), 0); - assertEq(twabController.delegateBalanceOf(address(vault), alice), 0); - - assertEq(twabController.balanceOf(address(vault), bob), _amount); - assertEq(twabController.delegateBalanceOf(address(vault), bob), _amount); - - assertEq(underlyingAsset.balanceOf(address(yieldVault)), _amount); - assertEq(yieldVault.balanceOf(address(vault)), _amount); - assertEq(yieldVault.totalSupply(), _amount); - - vm.stopPrank(); - } - /* ============ Mint - Errors ============ */ function testMintMoreThanMax() external { vm.startPrank(alice); diff --git a/test/utils/Helpers.t.sol b/test/utils/Helpers.t.sol index e96e639..dfbc9dd 100644 --- a/test/utils/Helpers.t.sol +++ b/test/utils/Helpers.t.sol @@ -83,34 +83,6 @@ contract Helpers is Test { return _vault.mint(_shares, _user); } - function _mintWithPermit( - IERC20Permit _underlyingAsset, - Vault _vault, - uint256 _shares, - address _user, - address _owner, - uint256 _ownerPrivateKey - ) internal returns (uint256) { - uint256 _nonce = _underlyingAsset.nonces(_owner); - uint256 _assets = _vault.convertToAssets(_shares); - address _vaultAddress = address(_vault); - - (uint8 _v, bytes32 _r, bytes32 _s) = vm.sign( - _ownerPrivateKey, - keccak256( - abi.encodePacked( - "\x19\x01", - _underlyingAsset.DOMAIN_SEPARATOR(), - keccak256( - abi.encode(_PERMIT_TYPEHASH, _owner, _vaultAddress, _assets, _nonce, block.timestamp) - ) - ) - ) - ); - - return _vault.mintWithPermit(_shares, _user, block.timestamp, _v, _r, _s); - } - /* ============ Sponsor ============ */ function _sponsor( IERC20 _underlyingAsset,