-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathITokenDistributor.sol
169 lines (154 loc) · 6.75 KB
/
ITokenDistributor.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// SPDX-License-Identifier: Beta Software
pragma solidity ^0.8;
import "../tokens/IERC20.sol";
import "./ITokenDistributorParty.sol";
/// @notice Creates token distributions for parties.
interface ITokenDistributor {
enum TokenType {
Native,
Erc20
}
// Info on a distribution, created by createDistribution().
struct DistributionInfo {
// Type of distribution/token.
TokenType tokenType;
// ID of the distribution. Assigned by createDistribution().
uint256 distributionId;
// The party whose members can claim the distribution.
ITokenDistributorParty party;
// Who can claim `fee`.
address payable feeRecipient;
// The token being distributed.
address token;
// Total amount of `token` that can be claimed by party members.
uint128 memberSupply;
// Amount of `token` to be redeemed by `feeRecipient`.
uint128 fee;
}
event DistributionCreated(
ITokenDistributorParty indexed party,
DistributionInfo info
);
event DistributionFeeClaimed(
ITokenDistributorParty indexed party,
address indexed feeRecipient,
TokenType tokenType,
address token,
uint256 amount
);
event DistributionClaimedByPartyToken(
ITokenDistributorParty indexed party,
uint256 indexed partyTokenId,
address indexed owner,
TokenType tokenType,
address token,
uint256 amountClaimed
);
/// @notice Create a new distribution for an outstanding native token balance
/// governed by a party.
/// @dev Native tokens should be transferred directly into this contract
/// immediately prior (same tx) to calling `createDistribution()` or
/// attached to the call itself.
/// @param party The party whose members can claim the distribution.
/// @param feeRecipient Who can claim `fee`.
/// @param feeBps Percentage (in bps) of the distribution `feeRecipient` receives.
/// @param info Information on the created distribution.
function createNativeDistribution(
ITokenDistributorParty party,
address payable feeRecipient,
uint16 feeBps
)
external
payable
returns (DistributionInfo memory info);
/// @notice Create a new distribution for an outstanding ERC20 token balance
/// governed by a party.
/// @dev ERC20 tokens should be transferred directly into this contract
/// immediately prior (same tx) to calling `createDistribution()` or
/// attached to the call itself.
/// @param token The ERC20 token to distribute.
/// @param party The party whose members can claim the distribution.
/// @param feeRecipient Who can claim `fee`.
/// @param feeBps Percentage (in bps) of the distribution `feeRecipient` receives.
/// @param info Information on the created distribution.
function createErc20Distribution(
IERC20 token,
ITokenDistributorParty party,
address payable feeRecipient,
uint16 feeBps
)
external
returns (DistributionInfo memory info);
/// @notice Claim a portion of a distribution owed to a `partyTokenId` belonging
/// to the party that created the distribution. The caller
/// must own this token.
/// @param info Information on the distribution being claimed.
/// @param partyTokenId The ID of the party token to claim for.
/// @param amountClaimed The amount of the distribution claimed.
function claim(DistributionInfo calldata info, uint256 partyTokenId)
external
returns (uint128 amountClaimed);
/// @notice Claim the fee for a distribution. Only a distribution's `feeRecipient`
/// can call this.
/// @param info Information on the distribution being claimed.
/// @param recipient The address to send the fee to.
function claimFee(DistributionInfo calldata info, address payable recipient)
external;
/// @notice Batch version of `claim()`.
/// @param infos Information on the distributions being claimed.
/// @param partyTokenIds The ID of the party tokens to claim for.
/// @param amountsClaimed The amount of the distributions claimed.
function batchClaim(DistributionInfo[] calldata infos, uint256[] calldata partyTokenIds)
external
returns (uint128[] memory amountsClaimed);
/// @notice Batch version of `claimFee()`.
/// @param infos Information on the distributions to claim fees for.
/// @param recipients The addresses to send the fees to.
function batchClaimFee(DistributionInfo[] calldata infos, address payable[] calldata recipients)
external;
/// @notice Compute the amount of a distribution's token are owed to a party
/// member, identified by the `partyTokenId`.
/// @param party The party to use for computing the claim amount.
/// @param memberSupply Total amount of tokens that can be claimed in the distribution.
/// @param partyTokenId The ID of the party token to claim for.
/// @return claimAmount The amount of the distribution owed to the party member.
function getClaimAmount(
ITokenDistributorParty party,
uint256 memberSupply,
uint256 partyTokenId
)
external
view
returns (uint128);
/// @notice Check whether the fee has been claimed for a distribution.
/// @param party The party to use for checking whether the fee has been claimed.
/// @param distributionId The ID of the distribution to check.
/// @return feeClaimed Whether the fee has been claimed.
function wasFeeClaimed(ITokenDistributorParty party, uint256 distributionId)
external
view
returns (bool);
/// @notice Check whether a `partyTokenId` has claimed their share of a distribution.
/// @param party The party to use for checking whether the `partyTokenId` has claimed.
/// @param partyTokenId The ID of the party token to check.
/// @param distributionId The ID of the distribution to check.
/// @return hasClaimed Whether the `partyTokenId` has claimed.
function hasPartyTokenIdClaimed(
ITokenDistributorParty party,
uint256 partyTokenId,
uint256 distributionId
)
external
view returns (bool);
/// @notice Get how much unclaimed member tokens are left in a distribution.
/// @param party The party to use for checking the unclaimed member tokens.
/// @param distributionId The ID of the distribution to check.
/// @return remainingMemberSupply The amount of distribution supply remaining.
function getRemainingMemberSupply(
ITokenDistributorParty party,
uint256 distributionId
)
external
view
returns (uint128);
}