Skip to content

Commit

Permalink
revert in bonding curve if distributions enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 committed Jan 3, 2024
1 parent cf9834e commit 721ebb0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
9 changes: 9 additions & 0 deletions contracts/authorities/BondingCurveAuthority.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PartyFactory } from "../party/PartyFactory.sol";
import { IERC721 } from "../tokens/IERC721.sol";
import { MetadataProvider } from "../renderers/MetadataProvider.sol";
import { LibSafeCast } from "contracts/utils/LibSafeCast.sol";
import { ProposalStorage } from "contracts/proposals/ProposalStorage.sol";

contract BondingCurveAuthority {
using LibSafeCast for uint256;
Expand All @@ -23,6 +24,7 @@ contract BondingCurveAuthority {
error ExcessSlippage();
error AddAuthorityProposalNotSupported();
error SellZeroPartyCards();
error DistributionsNotSupported();

event TreasuryFeeUpdated(uint16 previousTreasuryFee, uint16 newTreasuryFee);
event PartyDaoFeeUpdated(uint16 previousPartyDaoFee, uint16 newPartyDaoFee);
Expand Down Expand Up @@ -229,6 +231,13 @@ contract BondingCurveAuthority {
if (partyOpts.proposalEngine.enableAddAuthorityProposal) {
revert AddAuthorityProposalNotSupported();
}

if (
partyOpts.proposalEngine.distributionsConfig !=
ProposalStorage.DistributionsConfig.NotAllowed
) {
revert DistributionsNotSupported();
}
}

/**
Expand Down
25 changes: 23 additions & 2 deletions test/authorities/BondingCurveAuthority.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { PartyFactory } from "../../contracts/party/PartyFactory.sol";
import { BondingCurveAuthority } from "../../contracts/authorities/BondingCurveAuthority.sol";
import { SetupPartyHelper } from "../utils/SetupPartyHelper.sol";
import { MetadataProvider } from "contracts/renderers/MetadataProvider.sol";
import { ProposalStorage } from "../../contracts/proposals/ProposalStorage.sol";

contract BondingCurveAuthorityTest is SetupPartyHelper {
event TreasuryFeeUpdated(uint16 previousTreasuryFee, uint16 newTreasuryFee);
Expand Down Expand Up @@ -59,6 +60,7 @@ contract BondingCurveAuthorityTest is SetupPartyHelper {
opts.governance.executionDelay = 4 days;
opts.governance.passThresholdBps = 1000;
opts.governance.totalVotingPower = 0;
opts.proposalEngine.distributionsConfig = ProposalStorage.DistributionsConfig.NotAllowed;

// Set a default treasury fee
vm.prank(globalDaoWalletAddress);
Expand Down Expand Up @@ -157,7 +159,7 @@ contract BondingCurveAuthorityTest is SetupPartyHelper {
);
}

function test_creatorParty_revertAddAuthorityProposalNotSupported() external {
function test_createParty_revertAddAuthorityProposalNotSupported() external {
opts.proposalEngine.enableAddAuthorityProposal = true;

vm.expectRevert(BondingCurveAuthority.AddAuthorityProposalNotSupported.selector);
Expand All @@ -174,7 +176,26 @@ contract BondingCurveAuthorityTest is SetupPartyHelper {
);
}

function test_creatorParty_revertBelowMinExecutionDelay() external {
function test_createParty_revertDistributionsNotSupported() external {
opts.proposalEngine.distributionsConfig = ProposalStorage
.DistributionsConfig
.AllowedWithoutVote;

vm.expectRevert(BondingCurveAuthority.DistributionsNotSupported.selector);
authority.createParty(
BondingCurveAuthority.BondingCurvePartyOptions({
partyFactory: partyFactory,
partyImpl: partyImpl,
opts: opts,
creatorFeeOn: true,
a: 50_000,
b: uint80(0.001 ether)
}),
1
);
}

function test_createParty_revertBelowMinExecutionDelay() external {
opts.governance.executionDelay = 0;

vm.expectRevert(BondingCurveAuthority.ExecutionDelayTooShort.selector);
Expand Down

0 comments on commit 721ebb0

Please sign in to comment.