@bananapus/core-v6 0.0.33 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/ADMINISTRATION.md +75 -348
  2. package/ARCHITECTURE.md +86 -44
  3. package/AUDIT_INSTRUCTIONS.md +29 -42
  4. package/README.md +22 -3
  5. package/RISKS.md +45 -1
  6. package/SKILLS.md +16 -4
  7. package/USER_JOURNEYS.md +130 -30
  8. package/foundry.toml +2 -0
  9. package/package.json +2 -2
  10. package/references/entrypoints.md +1 -1
  11. package/script/Deploy.s.sol +2 -1
  12. package/src/JBERC20.sol +100 -30
  13. package/src/JBTerminalStore.sol +64 -23
  14. package/src/JBTokens.sol +1 -1
  15. package/src/abstract/JBPermissioned.sol +28 -0
  16. package/src/interfaces/IJBRulesetDataHook.sol +6 -1
  17. package/src/interfaces/IJBToken.sol +3 -3
  18. package/src/structs/JBAccountingContext.sol +0 -1
  19. package/src/structs/JBAfterCashOutRecordedContext.sol +0 -1
  20. package/src/structs/JBAfterPayRecordedContext.sol +0 -1
  21. package/src/structs/JBBeforeCashOutRecordedContext.sol +0 -1
  22. package/src/structs/JBBeforePayRecordedContext.sol +0 -1
  23. package/src/structs/JBCashOutHookSpecification.sol +0 -1
  24. package/src/structs/JBCurrencyAmount.sol +0 -1
  25. package/src/structs/JBFee.sol +0 -1
  26. package/src/structs/JBFundAccessLimitGroup.sol +0 -1
  27. package/src/structs/JBPayHookSpecification.sol +0 -1
  28. package/src/structs/JBPermissionsData.sol +0 -1
  29. package/src/structs/JBRuleset.sol +0 -1
  30. package/src/structs/JBRulesetConfig.sol +0 -1
  31. package/src/structs/JBRulesetMetadata.sol +0 -1
  32. package/src/structs/JBRulesetWeightCache.sol +0 -1
  33. package/src/structs/JBRulesetWithMetadata.sol +0 -1
  34. package/src/structs/JBSingleAllowance.sol +0 -1
  35. package/src/structs/JBSplit.sol +0 -1
  36. package/src/structs/JBSplitGroup.sol +0 -1
  37. package/src/structs/JBSplitHookContext.sol +0 -1
  38. package/src/structs/JBTerminalConfig.sol +0 -1
  39. package/src/structs/JBTokenAmount.sol +0 -1
  40. package/test/TestCashOutHooks.sol +12 -2
  41. package/test/TestDataHookFuzzing.sol +4 -4
  42. package/test/TestForwardedTokenConsumption.sol +7 -1
  43. package/test/TestJBERC20Inheritance.sol +3 -1
  44. package/test/TestTokenFlow.sol +2 -2
  45. package/test/audit/CashOutReenterPay.t.sol +5 -0
  46. package/test/audit/CodexHeldFeeRounding.t.sol +159 -0
  47. package/test/helpers/TestBaseWorkflow.sol +1 -1
  48. package/test/units/static/JBERC20/JBERC20Setup.sol +8 -3
  49. package/test/units/static/JBERC20/TestInitialize.sol +12 -13
  50. package/test/units/static/JBERC20/TestName.sol +1 -1
  51. package/test/units/static/JBERC20/TestNonces.sol +2 -1
  52. package/test/units/static/JBERC20/TestSymbol.sol +1 -1
  53. package/test/units/static/JBTerminalStore/TestPreviewCashOutFrom.sol +1 -1
  54. package/test/units/static/JBTerminalStore/TestRecordCashOutsFor.sol +4 -4
  55. package/test/units/static/JBTokens/JBTokensSetup.sol +5 -1
@@ -4,7 +4,6 @@ pragma solidity 0.8.28;
4
4
  import {IERC20Metadata} from "@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol";
5
5
  import {JBERC20} from "../../../../src/JBERC20.sol";
6
6
  import {JBERC20Setup} from "./JBERC20Setup.sol";
7
- import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
8
7
 
9
8
  contract TestInitialize_Local is JBERC20Setup {
10
9
  string _name = "Nana";
@@ -17,21 +16,21 @@ contract TestInitialize_Local is JBERC20Setup {
17
16
  function test_ImplementationCannotBeInitialized() external {
18
17
  // The implementation has _name = "invalid" set in constructor, so initialize() must revert.
19
18
  vm.expectRevert(JBERC20.JBERC20_AlreadyInitialized.selector);
20
- _implementation.initialize(_name, _symbol, _owner);
19
+ _implementation.initialize(_name, _symbol, _tokens);
21
20
  }
22
21
 
23
22
  function test_WhenANameIsAlreadySet() external {
24
23
  // it will revert
25
24
 
26
- _erc20.initialize(_name, _symbol, _owner);
25
+ _erc20.initialize(_name, _symbol, _tokens);
27
26
 
28
- // ensure ownership transferred
29
- address newOwner = Ownable(address(_erc20)).owner();
30
- assertEq(newOwner, _owner);
27
+ // ensure TOKENS is set
28
+ address setTokens = address(JBERC20(address(_erc20)).TOKENS());
29
+ assertEq(setTokens, _tokens);
31
30
 
32
31
  // will fail as internal name is no longer zero length
33
32
  vm.expectRevert();
34
- _erc20.initialize(_name, _symbol, _owner);
33
+ _erc20.initialize(_name, _symbol, _tokens);
35
34
  }
36
35
 
37
36
  function test_WhenName_EQNothing() external {
@@ -39,17 +38,17 @@ contract TestInitialize_Local is JBERC20Setup {
39
38
 
40
39
  // will fail as internal name is no longer than zero length
41
40
  vm.expectRevert();
42
- _erc20.initialize("", _symbol, _owner);
41
+ _erc20.initialize("", _symbol, _tokens);
43
42
  }
44
43
 
45
44
  function test_WhenNameIsValidAndNotAlreadySet() external {
46
- // it will set the name and symbol and transfer ownership
45
+ // it will set the name, symbol, and store references
47
46
 
48
- _erc20.initialize(_name, _symbol, _owner);
47
+ _erc20.initialize(_name, _symbol, _tokens);
49
48
 
50
- // ensure ownership transferred
51
- address newOwner = Ownable(address(_erc20)).owner();
52
- assertEq(newOwner, _owner);
49
+ // ensure TOKENS is set
50
+ address setTokens = address(JBERC20(address(_erc20)).TOKENS());
51
+ assertEq(setTokens, _tokens);
53
52
 
54
53
  // name is set
55
54
  string memory _setName = IERC20Metadata(address(_erc20)).name();
@@ -15,7 +15,7 @@ contract TestName_Local is JBERC20Setup {
15
15
 
16
16
  function test_WhenANameIsSet() external {
17
17
  // it will return the name
18
- _erc20.initialize("NANAPUS", "NANA", _owner);
18
+ _erc20.initialize("NANAPUS", "NANA", _tokens);
19
19
 
20
20
  string memory _setName = _token.name();
21
21
  assertEq(_setName, "NANAPUS");
@@ -6,6 +6,7 @@ import {JBERC20Setup} from "./JBERC20Setup.sol";
6
6
  import {SigUtils} from "./SigUtils.sol";
7
7
 
8
8
  contract TestNonces_Local is JBERC20Setup {
9
+ address _user = makeAddr("user");
9
10
  IERC20Permit _token;
10
11
  SigUtils sigUtils;
11
12
 
@@ -30,7 +31,7 @@ contract TestNonces_Local is JBERC20Setup {
30
31
  function test_WhenAUserHasNotCalledPermit() external view {
31
32
  // it will return zero
32
33
 
33
- uint256 _nonce = _token.nonces(_owner);
34
+ uint256 _nonce = _token.nonces(_user);
34
35
 
35
36
  assertEq(_nonce, 0);
36
37
  }
@@ -16,7 +16,7 @@ contract TestSymbol_Local is JBERC20Setup {
16
16
  function test_WhenASymbolIsSet() external {
17
17
  // it will return a non-empty string
18
18
 
19
- _erc20.initialize("NANAPUS", "NANA", _owner);
19
+ _erc20.initialize("NANAPUS", "NANA", _tokens);
20
20
 
21
21
  string memory _setSymbol = _token.symbol();
22
22
  assertEq(_setSymbol, "NANA");
@@ -453,7 +453,7 @@ contract TestPreviewCashOutFor_Local is JBTerminalStoreSetup {
453
453
  mockExpect(
454
454
  address(_dataHook),
455
455
  abi.encodeCall(IJBRulesetDataHook.beforeCashOutRecordedWith, (_context)),
456
- abi.encode(0, 10e18, _totalSupply, _spec)
456
+ abi.encode(0, 10e18, _totalSupply, 3e18, _spec)
457
457
  );
458
458
 
459
459
  (, uint256 reclaimAmount, uint256 cashOutTaxRate, JBCashOutHookSpecification[] memory hookSpecifications) = _store.previewCashOutFrom({
@@ -417,7 +417,7 @@ contract TestRecordCashOutsFor_Local is JBTerminalStoreSetup {
417
417
  mockExpect(
418
418
  address(_dataHook),
419
419
  abi.encodeCall(IJBRulesetDataHook.beforeCashOutRecordedWith, (_context)),
420
- abi.encode(0, 1e18, _totalSupply, _spec)
420
+ abi.encode(0, 1e18, _totalSupply, 3e18, _spec)
421
421
  );
422
422
 
423
423
  uint256 balanceBefore = _store.balanceOf(address(this), _projectId, _accountingContexts.token);
@@ -521,7 +521,7 @@ contract TestRecordCashOutsFor_Local is JBTerminalStoreSetup {
521
521
  mockExpect(
522
522
  address(_dataHook),
523
523
  abi.encodeCall(IJBRulesetDataHook.beforeCashOutRecordedWith, (_context)),
524
- abi.encode(0, 1e18, _totalSupply, _spec)
524
+ abi.encode(0, 1e18, _totalSupply, 3e18, _spec)
525
525
  );
526
526
 
527
527
  (, uint256 reclaimed,,) = _store.recordCashOutFor({
@@ -576,7 +576,7 @@ contract TestRecordCashOutsFor_Local is JBTerminalStoreSetup {
576
576
  mockExpect(
577
577
  address(_dataHook),
578
578
  abi.encodeCall(IJBRulesetDataHook.beforeCashOutRecordedWith, (_context)),
579
- abi.encode(0, 1e18, _totalSupply, _spec)
579
+ abi.encode(0, 1e18, _totalSupply, 3e18, _spec)
580
580
  );
581
581
 
582
582
  vm.expectRevert(abi.encodeWithSelector(JBTerminalStore.JBTerminalStore_NoopHookSpecHasAmount.selector, 1));
@@ -631,7 +631,7 @@ contract TestRecordCashOutsFor_Local is JBTerminalStoreSetup {
631
631
  mockExpect(
632
632
  address(_dataHook),
633
633
  abi.encodeCall(IJBRulesetDataHook.beforeCashOutRecordedWith, (_context)),
634
- abi.encode(0, 1e18, _totalSupply, _spec)
634
+ abi.encode(0, 1e18, _totalSupply, 3e18, _spec)
635
635
  );
636
636
 
637
637
  vm.expectRevert(abi.encodeWithSelector(JBTerminalStore.JBTerminalStore_NoopHookSpecHasAmount.selector, 1));
@@ -4,6 +4,8 @@ pragma solidity 0.8.28;
4
4
  import {JBERC20} from "../../../../src/JBERC20.sol";
5
5
  import {JBTokens} from "../../../../src/JBTokens.sol";
6
6
  import {IJBDirectory} from "../../../../src/interfaces/IJBDirectory.sol";
7
+ import {IJBPermissions} from "../../../../src/interfaces/IJBPermissions.sol";
8
+ import {IJBProjects} from "../../../../src/interfaces/IJBProjects.sol";
7
9
  import {IJBToken} from "../../../../src/interfaces/IJBToken.sol";
8
10
  import {IJBTokens} from "../../../../src/interfaces/IJBTokens.sol";
9
11
  import {JBTest} from "../../../helpers/JBTest.sol";
@@ -15,6 +17,8 @@ Tests relative to this contract will be dependent on mock calls/emits and stdSto
15
17
  contract JBTokensSetup is JBTest {
16
18
  // Mocks
17
19
  IJBDirectory public directory = IJBDirectory(makeAddr("directory"));
20
+ IJBPermissions public permissions = IJBPermissions(makeAddr("permissions"));
21
+ IJBProjects public projects = IJBProjects(makeAddr("projects"));
18
22
  IJBToken public jbToken;
19
23
 
20
24
  // Target Contract
@@ -22,7 +26,7 @@ contract JBTokensSetup is JBTest {
22
26
 
23
27
  function tokensSetup() public virtual {
24
28
  // Instantiate the contract being tested
25
- jbToken = new JBERC20();
29
+ jbToken = new JBERC20(permissions, projects);
26
30
  _tokens = new JBTokens(directory, jbToken);
27
31
  }
28
32
  }