# ClubDeal Registry

[https://github.com/Paracosm-Labs/mintdeals-contracts/blob/main/contracts/ClubDealRegistry.sol](https://github.com/Paracosm-Labs/mintdeals-contracts/blob/main/contracts/ClubDealRegistry.sol)

The ClubDealRegistry contract is another crucial component of the MintDeals platform. It manages the registration, membership, and deal processing for clubs, integrating with a credit facility  and credit manager to provide financial benefits to businesses.

### Key Functions

#### 1. Club Creation and Management

**`createClub(address _paymentTokenAddress, uint256 _membershipFee, bool _sendToCreditFacility)`**

* Creates a new club with specified membership fee and payment token.
* Charges a club creation fee from the owner.
* Registers the club owner with the Credit Manager.

**`updateClub(uint256 _clubId, uint256 _membershipFee, bool _active, bool _sendToCreditFacility)`**

* Allows club owners to update club details such as membership fee, active status, and whether to send fees to the credit facility or directly to their own wallet.

#### 2. Membership Management

**`addClubMember(uint256 _clubId, address _newMember, address _paymentTokenAddress)`**

* Adds a new member to a club.
* Processes membership fee payment, splitting it between the credit facility and the club owner.

**`isMember(uint256 _clubId, address _address)`**

* Checks if an address is a member of a specific club.

#### 3. Deal Creation and Management

**`createDeal(uint256 _clubId, uint256 _maxSupply, uint256 _expiryDate, string memory _metadataURI, uint256 _maxMintPerMember)`**

* Allows club owners to create new deals with specified supply, expiry date, and minting limits.

**`mintDeal(uint256 _clubId, uint256 _dealId)`**

* Enables club members to mint deal NFTs.

**`confirmRedemption(uint256 _clubId, uint256 _dealId, uint256 tokenId)`**

* Allows club owners to confirm when a deal has been redeemed.

#### 4. Information Retrieval

**`getClubCount()`**

* Returns the total number of clubs created.

**`getClubMemberCount(uint256 _clubId)`**

* Returns the number of members in a specific club.

**`getDealDetails(uint256 _clubId, uint256 _dealId)`**

* Retrieves details of a specific deal.

**`getClubsForMember(address _user)`**

* Returns all clubs a user is a member of.

#### 5. Financial Operations

**`swapViaCEX(address tokenIn, address tokenOut, address to)`**

* Facilitates token swaps via a centralized exchange (CEX).

**`withdrawCollectedFees(address _tokenAddress, address to)`**

* Allows admins to withdraw collected club creation fees.

### Key Concepts

1. **Club Creation**: Businesses can create clubs by paying a creation fee, setting membership fees, and choosing payment tokens.
2. **Membership**: Users can join clubs by paying the membership fee, which is split between the credit manager and the credit facility or club owner  directly.
3. **Deals**: Club owners can create deals as NFTs, which members can mint and redeem.
4. **Credit Facility Integration**: The contract integrates with a credit facility, allowing a portion of membership fees to be used as collateral for business loans.
5. **Admin Functions**: The contract includes administrative functions for fee management and system updates.

By leveraging this contract, MintDeals creates a ecosystem where businesses can offer exclusive deals, build member communities, and access credit facilities, all within a decentralized framework.
