Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove zero address checks and tests (SC-501) #23

Merged
merged 2 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading