# Affiliate Contract

### Contract Structure

The contract is structured to handle affiliate-related functionalities, including checking conditions, managing bonuses, and setting parameters.

The Affiliate smart contract manages an affiliate program within the application. It:

* Checks if a member can invite new members based on specific conditions.
* Checks if a member is eligible to receive matching bonuses based on their staking and invitee activities.
* Stores and manages matching bonuses for members.
* Allows authorized users to set various conditions and parameters for the affiliate program.

### Role-based Access Control

The contract implements role-based access control with two roles:

* `BINAR`: Allows setting matching bonuses.
* `TIMELOCK`: Allows setting various contract parameters.

#### Constants

* `TOTAL_MATCHING_PART`: Total matching bonus allocation.
* `BETTING_MATCHING_PART`: Matching bonus allocated for betting.
* `STAKING_MATCHING_PART`: Matching bonus allocated for staking.

#### Storage

* `inviteStakingCondition`: Minimum staking condition required for inviting new members.
* `matchingStakingCondition`: Minimum staking condition required for receiving matching bonuses.
* `matchingInviteeCondition`: Minimum staking condition required for invitees to trigger matching bonuses.

### Events

* `NewMatchingBonus`: Triggered when a new matching bonus is set.
* `NewPass`: Triggered when a new instance of Pass contract is set.
* `NewConservativeStaking`: Triggered when a new instance of ConservativeStaking contract is set.
* `NewDynamicStaking`: Triggered when a new instance of DynamicStaking contract is set.
* `NewBetsMemory`: Triggered when a new instance of BetsMemory contract is set.
* `NewInviteStakingCondition`: Triggered when the invite staking condition is updated.
* `NewMatchingStakingCondition`: Triggered when the matching staking condition is updated.
* `NewMatchingInviteeCondition`: Triggered when the matching invitee condition is updated.
