diff --git a/contracts/fast/Crowdfund.sol b/contracts/fast/Crowdfund.sol index b3d2b4bf..c441bf8f 100644 --- a/contracts/fast/Crowdfund.sol +++ b/contracts/fast/Crowdfund.sol @@ -79,6 +79,8 @@ contract Crowdfund { IERC20 token; /// @notice An arbitrary reference string to keep track of. string ref; + /// @notice The cap of the crowdfund if specified. + uint256 cap; } /// @notice A version identifier for us to track what's deployed. diff --git a/contracts/fast/FastCrowdfundsFacet.sol b/contracts/fast/FastCrowdfundsFacet.sol index 437220a7..1cdb9b9c 100644 --- a/contracts/fast/FastCrowdfundsFacet.sol +++ b/contracts/fast/FastCrowdfundsFacet.sol @@ -22,8 +22,16 @@ contract FastCrowdfundsFacet is AFastFacet { /** * @notice Creates a crowdfund contract. * @param token is the address of the ERC20 token that should be collected. + * @param beneficiary is the address that will receive the funds. + * @param ref is a reference for the crowdfund. + * @param cap is the maximum amount of tokens that can be collected (this is a hard cap). */ - function createCrowdfund(IERC20 token, address beneficiary, string memory ref) external onlyGovernor(msg.sender) { + function createCrowdfund( + IERC20 token, + address beneficiary, + string memory ref, + uint256 cap + ) external onlyGovernor(msg.sender) { address issuer = FastTopFacet(address(this)).issuerAddress(); // Deploy a new Crowdfund contract. Crowdfund crowdfund = new Crowdfund( @@ -34,7 +42,8 @@ contract FastCrowdfundsFacet is AFastFacet { beneficiary: beneficiary, basisPointsFee: LibFastCrowdfunds.data().crowdfundsDefaultBasisPointsFee, token: token, - ref: ref + ref: ref, + cap: cap }) ); // Register our newly created crowdfund and keep track of it. diff --git a/test/fast/Crowdfund.test.ts b/test/fast/Crowdfund.test.ts index 6b1dce4e..afc6b107 100644 --- a/test/fast/Crowdfund.test.ts +++ b/test/fast/Crowdfund.test.ts @@ -93,6 +93,7 @@ describe("Crowdfunds", () => { fast: fast.address, token: erc20.address, ref: "Some reference", + cap: BigNumber.from(32_000_000_000) }; deployCrowdfund = async (params) => { @@ -128,6 +129,7 @@ describe("Crowdfunds", () => { fast: validParams.fast, token: validParams.token, ref: validParams.ref, + cap: validParams.cap }); }); @@ -167,6 +169,7 @@ describe("Crowdfunds", () => { fast: validParams.fast, token: validParams.token, ref: validParams.ref, + cap: validParams.cap }); }); diff --git a/test/fast/FastCrowdfundsFacet.test.ts b/test/fast/FastCrowdfundsFacet.test.ts index e62dcf0a..a3ef6755 100644 --- a/test/fast/FastCrowdfundsFacet.test.ts +++ b/test/fast/FastCrowdfundsFacet.test.ts @@ -153,7 +153,8 @@ describe("FastCrowdfundsFacet", () => { const subject = crowdfunds.createCrowdfund( erc20.address, alice.address, - "Blah" + "Blah", + /* cap */ 2_000_000 ); await expect(subject).to.have.revertedWith("RequiresFastGovernorship"); }); @@ -162,7 +163,8 @@ describe("FastCrowdfundsFacet", () => { await crowdfundsAsGovernor.createCrowdfund( erc20.address, alice.address, - "Blah" + "Blah", + /* cap */ 2_000_000 ); const [page] = await crowdfundsAsGovernor.paginateCrowdfunds(0, 1); expect(page.length).to.eq(1); @@ -175,7 +177,8 @@ describe("FastCrowdfundsFacet", () => { await (tx = crowdfundsAsGovernor.createCrowdfund( erc20.address, alice.address, - "Blah" + "Blah", + /* cap */ 310_000 )); const [crowdfundings] = await crowdfunds.paginateCrowdfunds(0, 1); crowdfundAddr = crowdfundings[0]; @@ -191,7 +194,8 @@ describe("FastCrowdfundsFacet", () => { crowdfundsAsGovernor.createCrowdfund( erc20.address, alice.address, - "Blah" + "Blah", + /* cap */ 30_000 ) ) ); @@ -199,7 +203,16 @@ describe("FastCrowdfundsFacet", () => { expect(page.length).to.eq(3); }); - it("sets the fee to the FAST-level default one"); + it("sets the fee to the FAST-level default one", async () => { + const defaultFee = await crowdfunds.crowdfundsDefaultBasisPointFee(); + const subject = await crowdfund.paramsStruct(); + expect(subject.basisPointsFee).to.eq(defaultFee); + }); + + it("sets the cap to the passed cap amount", async () => { + const subject = await crowdfund.paramsStruct(); + expect(subject.cap).to.eq(310_000); + }); it("emits a CrowdfundDeployed event", async () => { await expect(tx) @@ -227,7 +240,8 @@ describe("FastCrowdfundsFacet", () => { await crowdfundsAsGovernor.createCrowdfund( erc20.address, alice.address, - "Blah" + "Blah", + /* cap */ 300_000 ); }); @@ -253,7 +267,8 @@ describe("FastCrowdfundsFacet", () => { await crowdfundsAsGovernor.createCrowdfund( erc20.address, alice.address, - "Blah" + "Blah", + /* cap */ 300_000 ); }); @@ -268,7 +283,8 @@ describe("FastCrowdfundsFacet", () => { await crowdfundsAsGovernor.createCrowdfund( erc20.address, alice.address, - "Blah" + "Blah", + /* cap */ 300_000 ); }); diff --git a/test/marketplace/MarketplaceFastDeploymentRequestsFacet.test.ts b/test/marketplace/MarketplaceFastDeploymentRequestsFacet.test.ts index f6abd5a3..ea11af9d 100644 --- a/test/marketplace/MarketplaceFastDeploymentRequestsFacet.test.ts +++ b/test/marketplace/MarketplaceFastDeploymentRequestsFacet.test.ts @@ -14,7 +14,7 @@ import { abiStructToObj } from "../utils"; chai.use(solidity); chai.use(smock.matchers); -describe.only("MarketplaceFastDeploymentRequestsFacet", () => { +describe("MarketplaceFastDeploymentRequestsFacet", () => { let deployer: SignerWithAddress, issuerMember: SignerWithAddress, alice: SignerWithAddress,