Skip to content

Commit

Permalink
chore: update invariant handler and licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
r0ohafza committed Jan 30, 2024
1 parent c29cadd commit ae51304
Show file tree
Hide file tree
Showing 33 changed files with 99 additions and 33 deletions.
2 changes: 1 addition & 1 deletion packages/splits-v2/script/Base.s.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { ICreateX } from "./ICreateX.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/script/SplitFactoryV2.s.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { SplitFactoryV2 } from "../src/splitters/SplitFactoryV2.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/script/SplitsWarehouse.s.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { SplitsWarehouse } from "../src/SplitsWarehouse.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/SplitsWarehouse.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: GPL-3.0-or-later
// license?
pragma solidity ^0.8.18;

Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/interfaces/IERC165.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

interface IERC165 {
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/interfaces/IERC6909.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { IERC165 } from "./IERC165.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/interfaces/IERC6909X.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { IERC5267 } from "@openzeppelin/contracts/interfaces/IERC5267.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/interfaces/IERC6909XCallback.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

interface IERC6909XCallback {
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/interfaces/ISplitsWarehouse.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { IERC6909 } from "./IERC6909.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/interfaces/IWETH9.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

interface IWETH9 {
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/libraries/Cast.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

library Cast {
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/libraries/Math.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

library Math {
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/libraries/SplitV2.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

library SplitV2Lib {
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/tokens/ERC6909.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { IERC165 } from "../interfaces/IERC165.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/tokens/ERC6909X.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { IERC6909X } from "../interfaces/IERC6909X.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/src/utils/Nonces.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/Base.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { SplitsWarehouse } from "../src/SplitsWarehouse.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/erc6909/ERC6909.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { BaseTest } from "../Base.t.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/erc6909/ERC6909Test.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { Cast } from "../../src/libraries/Cast.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/splitters/SplitFactoryV2.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { SplitV2Lib } from "../../src/libraries/SplitV2.sol";
Expand Down
5 changes: 4 additions & 1 deletion packages/splits-v2/test/splitters/SplitWalletV2.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { Clone } from "../../src/libraries/Clone.sol";
Expand Down Expand Up @@ -229,6 +229,7 @@ contract SplitWalletV2Test is BaseTest {

vm.startPrank(ALICE.addr);
wallet.setPaused(true);
if (split.totalAllocation == 0 && split.recipients.length > 0) vm.expectRevert();
wallet.distribute(split, token, ALICE.addr);
vm.stopPrank();

Expand Down Expand Up @@ -256,6 +257,7 @@ contract SplitWalletV2Test is BaseTest {

wallet.distribute(split, token, ALICE.addr);

if (split.totalAllocation == 0 && split.recipients.length > 0) vm.expectRevert();
assertDistribute(split, token, _warehouseAmount, _splitAmount, ALICE.addr);
}

Expand All @@ -278,6 +280,7 @@ contract SplitWalletV2Test is BaseTest {

dealSplit(address(wallet), native, splitAmount, _warehouseAmount);

if (split.totalAllocation == 0 && split.recipients.length > 0) vm.expectRevert();
wallet.distribute(split, native, ALICE.addr);
assertDistribute(split, native, _warehouseAmount, splitAmount, ALICE.addr);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/utils/Address.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/utils/ERC20.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { ERC20 as AbstractERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/utils/ERC6909XUtils.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { MessageHashUtils } from "./MessageHashUtils.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/utils/Fuzzer.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

contract Fuzzer {
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/utils/MessageHashUtils.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.18;

Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/utils/Ownable.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { Ownable } from "../../src/utils/Ownable.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/utils/Pausable.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { Pausable } from "../../src/utils/Pausable.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/utils/ReentrantReceiver.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { SplitsWarehouse } from "../../src/SplitsWarehouse.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/utils/Wallet.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { Ownable } from "../../src/utils/Ownable.sol";
Expand Down
2 changes: 1 addition & 1 deletion packages/splits-v2/test/warehouse/SplitsWarehouse.t.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { SplitsWarehouse } from "../../src/SplitsWarehouse.sol";
Expand Down
65 changes: 64 additions & 1 deletion packages/splits-v2/test/warehouse/SplitsWarehouseHandler.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { SplitsWarehouse } from "../../src/SplitsWarehouse.sol";
Expand Down Expand Up @@ -100,6 +100,33 @@ contract SplitsWarehouseHandler is CommonBase, StdCheats, StdUtils {
warehouseBalance[token] -= balance - 1;
}

function withdraw(uint256 _user, uint256[2] memory _amounts, uint256 _withdrawer) public {
_user = bound(_user, 0, users.length - 1);
address user = users[_user];

_withdrawer = bound(_withdrawer, 0, users.length - 1);
address withdrawer = users[_withdrawer];

address[] memory _tokens = new address[](2);
uint256[] memory amounts = new uint256[](2);

for (uint256 i = 0; i < 2; i++) {
_tokens[i] = tokens[i];
amounts[i] = bound(_amounts[i], 0, warehouse.balanceOf(user, _tokens[i].toUint256()));
}

(, bool paused) = warehouse.withdrawConfig(user);

vm.prank(withdrawer);
if (user == badActor || paused) {
return;
}
warehouse.withdraw(user, _tokens, amounts, withdrawer);

warehouseBalance[tokens[0]] -= amounts[0];
warehouseBalance[tokens[1]] -= amounts[1];
}

function transfer(uint256 _sender, uint256 _receiver, uint256 _token, uint256 _amount) public mockUser(_sender) {
_sender = bound(_sender, 0, users.length - 1);
_receiver = bound(_receiver, 0, users.length - 1);
Expand Down Expand Up @@ -192,6 +219,42 @@ contract SplitsWarehouseHandler is CommonBase, StdCheats, StdUtils {
warehouse.batchTransfer(receiverAddresses, token, amounts);
}

function batchDeposit(
uint256 _sender,
uint256[5] memory _receivers,
uint256[5] memory _amounts,
uint256 _token
)
public
mockUser(_sender)
{
address[] memory receiverAddresses = new address[](5);
uint256[] memory amounts = new uint256[](5);
_sender = bound(_sender, 0, users.length - 1);
_token = bound(_token, 0, tokens.length - 1);
address token = tokens[_token];

uint256 balance = token == native ? address(this).balance : IERC20(tokens[_token]).balanceOf(address(this));
uint256 amount = 0;
for (uint256 i = 0; i < 5; i++) {
_receivers[i] = bound(_receivers[i], 0, users.length - 1);
receiverAddresses[i] = users[_receivers[i]];

amounts[i] = bound(_amounts[i], 0, balance);
balance -= amounts[i];
amount += amounts[i];
}

if (token == native) {
warehouse.batchDeposit{ value: amount }(receiverAddresses, token, amounts);
} else {
IERC20(token).approve(address(warehouse), amount);
warehouse.batchDeposit(receiverAddresses, token, amounts);
}

warehouseBalance[token] += amount;
}

function filter(
address[5] memory owners,
uint96[5] memory amounts
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.18;

import { Cast } from "../../src/libraries/Cast.sol";
Expand Down

0 comments on commit ae51304

Please sign in to comment.