Skip to content

Commit

Permalink
feat: Remove zero address checks and tests (SC-501) (#23)
Browse files Browse the repository at this point in the history
* feat: rm zero address checks and tests

* fix: update to use zero address for burning in tests
  • Loading branch information
lucas-manuel authored Jul 5, 2024
1 parent 74cec31 commit e62dac2
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 16 deletions.
4 changes: 1 addition & 3 deletions src/PSM3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ contract PSM3 is IPSM3 {
function deposit(address asset, address receiver, uint256 assetsToDeposit)
external override returns (uint256 newShares)
{
require(receiver != address(0), "PSM3/invalid-receiver");
require(assetsToDeposit != 0, "PSM3/invalid-amount");
require(assetsToDeposit != 0, "PSM3/invalid-amount");

newShares = previewDeposit(asset, assetsToDeposit);

Expand All @@ -122,7 +121,6 @@ contract PSM3 is IPSM3 {
function withdraw(address asset, address receiver, uint256 maxAssetsToWithdraw)
external override returns (uint256 assetsWithdrawn)
{
require(receiver != address(0), "PSM3/invalid-receiver");
require(maxAssetsToWithdraw != 0, "PSM3/invalid-amount");

uint256 sharesToBurn;
Expand Down
2 changes: 1 addition & 1 deletion test/invariant/Invariants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract contract PSMInvariantTestBase is PSMTestBase {
TransferHandler public transferHandler;
TimeBasedRateHandler public timeBasedRateHandler;

address BURN_ADDRESS = makeAddr("burn-address");
address BURN_ADDRESS = address(0);

// NOTE [CRITICAL]: All invariant tests are operating under the assumption that the initial seed
// deposit of 1e18 shares has been made. This is a key requirement and
Expand Down
5 changes: 0 additions & 5 deletions test/unit/Deposit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ contract PSMDepositTests is PSMTestBase {
address receiver1 = makeAddr("receiver1");
address receiver2 = makeAddr("receiver2");

function test_deposit_zeroReceiver() public {
vm.expectRevert("PSM3/invalid-receiver");
psm.deposit(address(usdc), address(0), 100e6);
}

function test_deposit_zeroAmount() public {
vm.expectRevert("PSM3/invalid-amount");
psm.deposit(address(usdc), user1, 0);
Expand Down
7 changes: 0 additions & 7 deletions test/unit/Withdraw.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@ contract PSMWithdrawTests is PSMTestBase {
address receiver1 = makeAddr("receiver1");
address receiver2 = makeAddr("receiver2");

function test_withdraw_zeroReceiver() public {
_deposit(address(usdc), user1, 100e6);

vm.expectRevert("PSM3/invalid-receiver");
psm.withdraw(address(usdc), address(0), 100e6);
}

function test_withdraw_zeroAmount() public {
_deposit(address(usdc), user1, 100e6);

Expand Down

0 comments on commit e62dac2

Please sign in to comment.