Skip to content

Commit

Permalink
removed m3ter requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
iChristwin committed Apr 6, 2024
1 parent 6a8dad1 commit d87a3d4
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 33 deletions.
9 changes: 0 additions & 9 deletions src/Solaxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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();
Expand All @@ -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);
Expand All @@ -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();
Expand Down
1 change: 0 additions & 1 deletion src/interfaces/ISolaxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions test/Solaxy.invariant.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
23 changes: 2 additions & 21 deletions test/Solaxy.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]/interfaces/IERC20.sol";
import {IERC721} from "@openzeppelin/[email protected]/interfaces/IERC721.sol";

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit d87a3d4

Please sign in to comment.