From d87a3d4537c13957d8d6ff2650ecb9d740035e0c Mon Sep 17 00:00:00 2001 From: ichristwin Date: Sat, 6 Apr 2024 18:03:00 +0100 Subject: [PATCH] removed m3ter requirement --- src/Solaxy.sol | 9 --------- src/interfaces/ISolaxy.sol | 1 - test/Solaxy.invariant.t.sol | 2 -- test/Solaxy.t.sol | 23 ++--------------------- 4 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/Solaxy.sol b/src/Solaxy.sol index c86c522..38af5c5 100644 --- a/src/Solaxy.sol +++ b/src/Solaxy.sol @@ -16,7 +16,6 @@ contract Solaxy is ERC20ABC, ISolaxy { UD60x18 public constant SLOPE = UD60x18.wrap(0.0025e18); UD60x18 public constant HALF_SLOPE = UD60x18.wrap(0.00125e18); ERC20 public constant SDAI = ERC20(0xaf204776c7245bF4147c2612BF6e5972Ee483701); - IERC721 public constant M3TER = IERC721(0xbCFeFea1e83060DbCEf2Ed0513755D049fDE952C); // TODO: M3ter Address /** * @dev Constructs the Solaxy contract, initializing the sDAI token and the fee address. @@ -32,7 +31,6 @@ contract Solaxy is ERC20ABC, ISolaxy { * @dev See {IERC4626-deposit}. */ function deposit(uint256 assets, address receiver) external returns (uint256 shares) { - if (M3TER.balanceOf(msg.sender) < 1) revert RequiresM3ter(); shares = computeDeposit(assets, totalSupply()); _deposit(receiver, assets, shares); } @@ -41,7 +39,6 @@ contract Solaxy is ERC20ABC, ISolaxy { * @dev See {IERC4626-withdraw}. */ function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares) { - if (M3TER.balanceOf(msg.sender) < 1) revert RequiresM3ter(); uint256 fee; (shares, fee) = computeWithdraw(assets, totalSupply()); _withdraw(receiver, owner, assets, shares, fee); @@ -51,7 +48,6 @@ contract Solaxy is ERC20ABC, ISolaxy { * @dev See {IERC4626-mint}. */ function mint(uint256 shares, address receiver) external returns (uint256 assets) { - if (M3TER.balanceOf(msg.sender) < 1) revert RequiresM3ter(); assets = computeMint(shares, totalSupply()); _deposit(receiver, assets, shares); } @@ -60,7 +56,6 @@ contract Solaxy is ERC20ABC, ISolaxy { * @dev See {IERC4626-redeem}. */ function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets) { - if (M3TER.balanceOf(msg.sender) < 1) revert RequiresM3ter(); uint256 fee; (shares, assets, fee) = computeRedeem(shares, totalSupply()); _withdraw(receiver, owner, assets, shares, fee); @@ -71,7 +66,6 @@ contract Solaxy is ERC20ABC, ISolaxy { * @param minSharesOut The minimum number of shares the sender expects to receive. */ function safeDeposit(uint256 assets, address receiver, uint256 minSharesOut) external returns (uint256 shares) { - if (M3TER.balanceOf(msg.sender) < 1) revert RequiresM3ter(); shares = computeDeposit(assets, totalSupply()); if (shares < minSharesOut) revert SlippageError(); _deposit(receiver, assets, shares); @@ -85,7 +79,6 @@ contract Solaxy is ERC20ABC, ISolaxy { external returns (uint256 shares) { - if (M3TER.balanceOf(msg.sender) < 1) revert RequiresM3ter(); uint256 fee; (shares, fee) = computeWithdraw(assets, totalSupply()); if (shares > maxSharesIn) revert SlippageError(); @@ -97,7 +90,6 @@ contract Solaxy is ERC20ABC, ISolaxy { * @param maxAssetsIn The maximum amount of assets the sender is willing to deposit. */ function safeMint(uint256 shares, address receiver, uint256 maxAssetsIn) external returns (uint256 assets) { - if (M3TER.balanceOf(msg.sender) < 1) revert RequiresM3ter(); assets = computeMint(shares, totalSupply()); if (assets > maxAssetsIn) revert SlippageError(); _deposit(receiver, assets, shares); @@ -111,7 +103,6 @@ contract Solaxy is ERC20ABC, ISolaxy { external returns (uint256 assets) { - if (M3TER.balanceOf(msg.sender) < 1) revert RequiresM3ter(); uint256 fee; (shares, assets, fee) = computeRedeem(shares, totalSupply()); if (assets < minAssetsOut) revert SlippageError(); diff --git a/src/interfaces/ISolaxy.sol b/src/interfaces/ISolaxy.sol index a39162c..f53eb76 100644 --- a/src/interfaces/ISolaxy.sol +++ b/src/interfaces/ISolaxy.sol @@ -8,7 +8,6 @@ error Undersupply(); error CannotBeZero(); error SlippageError(); error TransferError(); -error RequiresM3ter(); interface ISolaxy is IERC4626 { function safeDeposit(uint256 assets, address receiver, uint256 minSharesOut) external returns (uint256 shares); diff --git a/test/Solaxy.invariant.t.sol b/test/Solaxy.invariant.t.sol index 5cc1b0c..e7eb16a 100644 --- a/test/Solaxy.invariant.t.sol +++ b/test/Solaxy.invariant.t.sol @@ -71,8 +71,6 @@ contract SolaxyInvarantTest is Test { handlerAddress = address(handler); deal(sDAI_address, handlerAddress, sDAI_balanceOneBillion, true); - dealERC721(address(SLX.M3TER()), handlerAddress, 1); - targetContract(handlerAddress); } diff --git a/test/Solaxy.t.sol b/test/Solaxy.t.sol index 4d25d42..d2bc12a 100644 --- a/test/Solaxy.t.sol +++ b/test/Solaxy.t.sol @@ -3,7 +3,6 @@ pragma solidity ^0.8.19; import {Test} from "forge-std/Test.sol"; import {Solaxy} from "../src/Solaxy.sol"; -import {RequiresM3ter} from "../src/interfaces/ISolaxy.sol"; import {IERC20} from "@openzeppelin/contracts@5.0.2/interfaces/IERC20.sol"; import {IERC721} from "@openzeppelin/contracts@5.0.2/interfaces/IERC721.sol"; @@ -46,23 +45,7 @@ contract SolaxyUnitTest is Test { assertEq(SLX_address.balance, 0 ether, "asset ether balance is still equal to zero"); } - function testNonM3terHolder() public { - vm.expectRevert(RequiresM3ter.selector); - SLX.deposit(sDAI_amountDeposited, here); - - vm.expectRevert(RequiresM3ter.selector); - SLX.withdraw(sDAI_amountWithdrawn, here, here); - - vm.expectRevert(RequiresM3ter.selector); - SLX.mint(SLX_amountMinted, here); - - vm.expectRevert(RequiresM3ter.selector); - SLX.redeem(SLX_amountIn, here, here); - } - - function testM3terHolderDepositAndWithdraw() public { - dealERC721(address(SLX.M3TER()), here, 1); - + function testDepositAndWithdraw() public { uint256 SLX_InitialBalance = SLX.balanceOf(here); uint256 sDAI_initialBalance = sDAI.balanceOf(SLX_address); @@ -109,9 +92,7 @@ contract SolaxyUnitTest is Test { assertEq(SLX_feeBalance, 1795000000000000000); } - function testM3terHolderMintAndRedeem() public { - dealERC721(address(SLX.M3TER()), here, 1); - + function testMintAndRedeem() public { uint256 SLX_initialBalance = SLX.balanceOf(here); uint256 sDAI_initialBalance = sDAI.balanceOf(SLX_address);