Skip to content

Commit

Permalink
ruleset flag for allowing crosschain sucker extension
Browse files Browse the repository at this point in the history
  • Loading branch information
mejango committed Aug 19, 2024
1 parent 52b8ecd commit 9a0ec6d
Show file tree
Hide file tree
Showing 42 changed files with 114 additions and 33 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,13 @@ For example, if `alice.eth` owns project ID #5, she can queue new rulesets for t
| 20 | `ADJUST_721_TIERS` | Permission to call `JB721TiersHook.adjustTiers`. | [`nana-721-hook`](https://github.com/Bananapus/nana-721-hook) |
| 21 | `SET_721_METADATA` | Permission to call `JB721TiersHook.setMetadata`. | [`nana-721-hook`](https://github.com/Bananapus/nana-721-hook) |
| 22 | `MINT_721` | Permission to call `JB721TiersHook.mintFor`. | [`nana-721-hook`](https://github.com/Bananapus/nana-721-hook) |
| 23 | `SET_BUYBACK_TWAP` | Permission to call `JBBuybackHook.setTwapWindowOf` and `JBBuybackHook.setTwapSlippageToleranceOf`. | [`nana-buyback-hook`](https://github.com/Bananapus/nana-buyback-hook) |
| 24 | `SET_BUYBACK_POOL` | Permission to call `JBBuybackHook.setPoolFor`. | [`nana-buyback-hook`](https://github.com/Bananapus/nana-buyback-hook) |
| 25 | `ADD_SWAP_TERMINAL_POOL` | Permission to call `JBSwapTerminal.addDefaultPool`. | [`nana-swap-terminal`](https://github.com/Bananapus/nana-swap-terminal) |
| 26 | `ADD_SWAP_TERMINAL_TWAP_PARAMS` | Permission to call `JBSwapTerminal.addTwapParamsFor`. | [`nana-swap-terminal`](https://github.com/Bananapus/nana-swap-terminal) |
| 27 | `MAP_SUCKER_TOKEN` | Permission to call `BPSucker.mapToken`. | [`nana-suckers`](https://github.com/Bananapus/nana-suckers) |
| 28 | `DEPLOY_SUCKERS` | Permission to call `BPSuckerRegistry.deploySuckersFor`. | [`nana-suckers`](https://github.com/Bananapus/nana-suckers) |
| 23 | `SET_721_DISCOUNT_PERCENT` | Permission to call `JB721TiersHook.setDiscountPercentOf`. | [`nana-721-hook`](https://github.com/Bananapus/nana-721-hook) |
| 24 | `SET_BUYBACK_TWAP` | Permission to call `JBBuybackHook.setTwapWindowOf` and `JBBuybackHook.setTwapSlippageToleranceOf`. | [`nana-buyback-hook`](https://github.com/Bananapus/nana-buyback-hook) |
| 25 | `SET_BUYBACK_POOL` | Permission to call `JBBuybackHook.setPoolFor`. | [`nana-buyback-hook`](https://github.com/Bananapus/nana-buyback-hook) |
| 26 | `ADD_SWAP_TERMINAL_POOL` | Permission to call `JBSwapTerminal.addDefaultPool`. | [`nana-swap-terminal`](https://github.com/Bananapus/nana-swap-terminal) |
| 27 | `ADD_SWAP_TERMINAL_TWAP_PARAMS` | Permission to call `JBSwapTerminal.addTwapParamsFor`. | [`nana-swap-terminal`](https://github.com/Bananapus/nana-swap-terminal) |
| 28 | `MAP_SUCKER_TOKEN` | Permission to call `BPSucker.mapToken`. | [`nana-suckers`](https://github.com/Bananapus/nana-suckers) |
| 29 | `DEPLOY_SUCKERS` | Permission to call `BPSuckerRegistry.deploySuckersFor`. | [`nana-suckers`](https://github.com/Bananapus/nana-suckers) |

</details>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bananapus/core",
"version": "0.0.26",
"version": "0.0.27",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
49 changes: 28 additions & 21 deletions src/libraries/JBRulesetMetadataResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,36 @@ library JBRulesetMetadataResolver {
return ((ruleset.metadata >> 76) & 1) == 1;
}

function ownerMustSendPayouts(JBRuleset memory ruleset) internal pure returns (bool) {
function allowCrosschainSuckerExtension(JBRuleset memory ruleset) internal pure returns (bool) {
return ((ruleset.metadata >> 77) & 1) == 1;
}

function holdFees(JBRuleset memory ruleset) internal pure returns (bool) {
function ownerMustSendPayouts(JBRuleset memory ruleset) internal pure returns (bool) {
return ((ruleset.metadata >> 78) & 1) == 1;
}

function useTotalSurplusForRedemptions(JBRuleset memory ruleset) internal pure returns (bool) {
function holdFees(JBRuleset memory ruleset) internal pure returns (bool) {
return ((ruleset.metadata >> 79) & 1) == 1;
}

function useTotalSurplusForRedemptions(JBRuleset memory ruleset) internal pure returns (bool) {
return ((ruleset.metadata >> 80) & 1) == 1;
}

function useDataHookForPay(JBRuleset memory ruleset) internal pure returns (bool) {
return (ruleset.metadata >> 80) & 1 == 1;
return (ruleset.metadata >> 81) & 1 == 1;
}

function useDataHookForRedeem(JBRuleset memory ruleset) internal pure returns (bool) {
return (ruleset.metadata >> 81) & 1 == 1;
return (ruleset.metadata >> 82) & 1 == 1;
}

function dataHook(JBRuleset memory ruleset) internal pure returns (address) {
return address(uint160(ruleset.metadata >> 82));
return address(uint160(ruleset.metadata >> 83));
}

function metadata(JBRuleset memory ruleset) internal pure returns (uint16) {
return uint16(ruleset.metadata >> 242);
return uint16(ruleset.metadata >> 243);
}

/// @notice Pack the funding cycle metadata.
Expand Down Expand Up @@ -115,20 +119,22 @@ library JBRulesetMetadataResolver {
if (rulesetMetadata.allowAddAccountingContext) packed |= 1 << 75;
// allow add price feed in bit 76.
if (rulesetMetadata.allowAddPriceFeed) packed |= 1 << 76;
// allow controller migration in bit 77.
if (rulesetMetadata.ownerMustSendPayouts) packed |= 1 << 77;
// hold fees in bit 78.
if (rulesetMetadata.holdFees) packed |= 1 << 78;
// useTotalSurplusForRedemptions in bit 79.
if (rulesetMetadata.useTotalSurplusForRedemptions) packed |= 1 << 79;
// use pay data source in bit 80.
if (rulesetMetadata.useDataHookForPay) packed |= 1 << 80;
// use redeem data source in bit 81.
if (rulesetMetadata.useDataHookForRedeem) packed |= 1 << 81;
// data source address in bits 82-241.
packed |= uint256(uint160(address(rulesetMetadata.dataHook))) << 82;
// metadata in bits 242-255 (14 bits).
packed |= (uint256(rulesetMetadata.metadata) >> 2) << 242;
// allow crosschain sucker extension in bit 77.
if (rulesetMetadata.allowCrosschainSuckerExtension) packed |= 1 << 77;
// allow controller migration in bit 78.
if (rulesetMetadata.ownerMustSendPayouts) packed |= 1 << 78;
// hold fees in bit 79.
if (rulesetMetadata.holdFees) packed |= 1 << 79;
// useTotalSurplusForRedemptions in bit 80.
if (rulesetMetadata.useTotalSurplusForRedemptions) packed |= 1 << 80;
// use pay data source in bit 81.
if (rulesetMetadata.useDataHookForPay) packed |= 1 << 81;
// use redeem data source in bit 82.
if (rulesetMetadata.useDataHookForRedeem) packed |= 1 << 82;
// data source address in bits 83-242.
packed |= uint256(uint160(address(rulesetMetadata.dataHook))) << 83;
// metadata in bits 243-255 (13 bits).
packed |= (uint256(rulesetMetadata.metadata) >> 3) << 243;
}

/// @notice Expand the funding cycle metadata.
Expand All @@ -148,6 +154,7 @@ library JBRulesetMetadataResolver {
allowSetController(ruleset),
allowAddAccountingContext(ruleset),
allowAddPriceFeed(ruleset),
allowCrosschainSuckerExtension(ruleset),
ownerMustSendPayouts(ruleset),
holdFees(ruleset),
useTotalSurplusForRedemptions(ruleset),
Expand Down
3 changes: 3 additions & 0 deletions src/structs/JBRulesetMetadata.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ pragma solidity ^0.8.0;
/// terminals to use.
/// @custom:member allowAddPriceFeed A flag indicating if a project can add new price feeds to calculate exchange rates
/// between its tokens.
/// @custom:member allowCrosschainSuckerExtension A flag indicating if the crosschain sucker extension should be
/// allowed during this ruleset.
/// @custom:member ownerMustSendPayouts A flag indicating if privileged payout distribution should be
/// enforced, otherwise payouts can be distributed by anyone.
/// @custom:member holdFees A flag indicating if fees should be held during this ruleset.
Expand All @@ -44,6 +46,7 @@ struct JBRulesetMetadata {
bool allowSetController;
bool allowAddAccountingContext;
bool allowAddPriceFeed;
bool allowCrosschainSuckerExtension;
bool ownerMustSendPayouts;
bool holdFees;
bool useTotalSurplusForRedemptions;
Expand Down
1 change: 1 addition & 0 deletions test/TestAccessToFunds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ contract TestAccessToFunds_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: true,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: true,
useDataHookForPay: false,
Expand Down
2 changes: 2 additions & 0 deletions test/TestFees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ contract TestFees_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: true,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand All @@ -67,6 +68,7 @@ contract TestFees_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: true,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestJBERC20Inheritance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contract JBERC20Inheritance_Local is JBERC20, TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: true,
Expand Down
1 change: 1 addition & 0 deletions test/TestLaunchProject.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ contract TestLaunchProject_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestMetaTx.sol
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ contract TestMetaTx_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
2 changes: 2 additions & 0 deletions test/TestMintTokensOf.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ contract TestMintTokensOf_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: true,
Expand Down Expand Up @@ -91,6 +92,7 @@ contract TestMintTokensOf_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: true,
Expand Down
1 change: 1 addition & 0 deletions test/TestMultipleAccessLimits.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ contract TestMultipleAccessLimits_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: true,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestPayBurnRedeemFlow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract TestPayBurnRedeemFlow_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestPayHooks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract TestPayHooks_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: true,
Expand Down
1 change: 1 addition & 0 deletions test/TestPermissions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ contract TestPermissions_Local is TestBaseWorkflow, JBTest {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestPermit2Terminal.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ contract TestPermit2Terminal_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: true,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestRedeem.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract TestRedeem_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestRedeemHooks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract TestRedeemHooks_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestRulesetQueueing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ contract TestRulesetQueuing_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestRulesetWeightCaching.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ contract TestRulesetWeightCaching_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: true,
useDataHookForPay: false,
Expand Down
2 changes: 2 additions & 0 deletions test/TestSplits.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ contract TestSplits_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down Expand Up @@ -232,6 +233,7 @@ contract TestSplits_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/TestTokenFlow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ contract TestTokenFlow_Local is TestBaseWorkflow {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: false,
useDataHookForPay: false,
Expand Down
3 changes: 3 additions & 0 deletions test/units/static/JBController/TestLaunchProjectFor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ contract TestLaunchProjectFor_Local is JBControllerSetup {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: true,
useDataHookForPay: false,
Expand Down Expand Up @@ -101,6 +102,7 @@ contract TestLaunchProjectFor_Local is JBControllerSetup {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: true,
useDataHookForPay: false,
Expand Down Expand Up @@ -144,6 +146,7 @@ contract TestLaunchProjectFor_Local is JBControllerSetup {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: true,
useDataHookForPay: false,
Expand Down
3 changes: 2 additions & 1 deletion test/units/static/JBController/TestLaunchRulesetsFor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ contract TestLaunchRulesetsFor_Local is JBControllerSetup {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: true,
useDataHookForPay: false,
Expand Down Expand Up @@ -279,7 +280,7 @@ contract TestLaunchRulesetsFor_Local is JBControllerSetup {
// Mock call to rulesets queueFor
bytes memory _queueForCall = abi.encodeCall(
IJBRulesets.queueFor,
(_projectId, 0, 0, 0, _rulesetConfigs[0].approvalHook, 642_241_845_873_572_506_056_833, 0)
(_projectId, 0, 0, 0, _rulesetConfigs[0].approvalHook, 1246704755680887093409921, 0)
);
bytes memory _queueReturn = abi.encode(data);
mockExpect(address(rulesets), _queueForCall, _queueReturn);
Expand Down
2 changes: 2 additions & 0 deletions test/units/static/JBController/TestMigrateController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ contract TestMigrateController_Local is JBControllerSetup {
allowSetController: true,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: true,
useDataHookForPay: false,
Expand Down Expand Up @@ -81,6 +82,7 @@ contract TestMigrateController_Local is JBControllerSetup {
allowSetController: true,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: true,
useDataHookForPay: false,
Expand Down
1 change: 1 addition & 0 deletions test/units/static/JBController/TestMintTokensOfUnits.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ contract TestMintTokensOfUnits_Local is JBControllerSetup {
allowSetController: false,
allowAddAccountingContext: true,
allowAddPriceFeed: false,
allowCrosschainSuckerExtension: false,
holdFees: false,
useTotalSurplusForRedemptions: true,
useDataHookForPay: false,
Expand Down
Loading

0 comments on commit 9a0ec6d

Please sign in to comment.