Distribution
The Distribution contract provides a comprehensive process for project owners to create and manage distributions...
The Distribution
contract provides a comprehensive process for project owners to create and manage distributions, while also offering interfaces for users to participate in distributions and claim earnings.
Contract Functions
The Distribution
contract, as an extension of the Target contract, provides functionalities including creating distributions, user participation in distributions, cancelling distributions, liquidating distributions, users claiming dividends and distribution tokens. Distribution is a method for project owners to raise funds and allocate tokens through smart contracts.
Contract Structure
The Distribution
contract inherits from the Target
contract and utilizes the SafeMath library
to ensure the security of numerical operations.
Important Variables
distributionIndex
:
Index ID for distributions, starting from 1.distributions
:
Mapping storing details of each distribution.distribution2Owner
:
Records the owner of each distribution.distribution2Funding
:
Records the funding amount for each distribution.distribution2Shares
:
Records the number of shares for each distribution.distribution2TargetId
:
Associates distribution IDs with target IDs.userDistributions
:
Records the list of distributions in which users participate.user2disPending
:
Records the amount of tokens pending for users in distributions.user2disHarvest
:
Records the amount of tokens harvested by users.dis2EndTime
:
Records the end time of distributions.
The Functions:
Events
NewDistributionCreated
:
Triggered when a new distribution is created.NewJoin
:
Triggered when a user participates in a distribution.HarvestDividends
:
Triggered when a user harvests dividends.HarvestDisToken
:
Triggered when a user harvests distribution tokens.
Distribution Management
createDistribution
:
Creates a new distribution, subject to specific conditions such as project status and user permissions.cancelDistribution
:
Allows the owner to cancel a distribution, transitioning its status to310
.ownerLiquidation
:
Allows the owner to liquidate a distribution after it fails, transitioning its status to330
.
User Participation
userJoin
:
Allows users to participate in a distribution using native tokens, recording the participation amount and token quantity.
Claiming Dividends and Tokens
pendingDividends
:
Checks the dividends available for a user to claim.harvestDividends
:
Allows a user to claim their dividends.pendingDisToken
:
Checks the distribution tokens available for a user to claim.harvestDisToken
:
Allows a user to claim their distribution tokens.
Project Payment
payToken
:
Allows the project owner to make a payment, transferring assets to the contract and updating the status to250
.
Whitelist Management
setCheckWhitelist
:
Allows the distribution owner to set whitelist addresses.
Query Functions
getUserDisIds
:
Retrieves a list of all distribution IDs in which a user has participated.getDis2WhiteList
:
Retrieves the whitelist status of a user in a specific distribution.getDisPrice
:
Calculates the premium for a distribution.
Logic
The creator of a distribution must be a Contractor of the project, and the project status needs to be valid.
Users can participate in a distribution using the
userJoin
function with Native Token, earning corresponding token shares based on distribution rules.Distribution owners can cancel a distribution or perform liquidation under certain conditions.
Users can claim dividends and distribution tokens after a successful distribution.
Interface
Last updated