@namehash/ens-referrals 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +492 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +437 -7
- package/dist/index.d.ts +437 -7
- package/dist/index.js +485 -10
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Address, Hex } from 'viem';
|
|
2
|
+
|
|
3
|
+
declare const validateLowercaseAddress: (address: Address) => void;
|
|
4
|
+
declare const normalizeAddress: (address: Address) => Address;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a quantity of USD.
|
|
8
|
+
*
|
|
9
|
+
* @invariant Guaranteed to be a finite non-negative number (>= 0)
|
|
10
|
+
*/
|
|
11
|
+
type USDQuantity = number;
|
|
12
|
+
declare function isValidUSDQuantity(value: USDQuantity): boolean;
|
|
13
|
+
declare function validateUSDQuantity(value: USDQuantity): void;
|
|
2
14
|
|
|
3
15
|
/**
|
|
4
16
|
* Unix timestamp value
|
|
5
17
|
*
|
|
6
18
|
* Represents the number of seconds that have elapsed
|
|
7
|
-
* since January 1, 1970 (midnight UTC/GMT).
|
|
8
|
-
*
|
|
9
|
-
* Guaranteed to be an integer. May be zero or negative to represent a time at or
|
|
19
|
+
* since January 1, 1970 (midnight UTC/GMT). May be zero or negative to represent a time at or
|
|
10
20
|
* before Jan 1, 1970.
|
|
21
|
+
*
|
|
22
|
+
* @invariant Guaranteed to be an integer.
|
|
11
23
|
*/
|
|
12
24
|
type UnixTimestamp = number;
|
|
25
|
+
declare const validateUnixTimestamp: (timestamp: UnixTimestamp) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Duration
|
|
28
|
+
*
|
|
29
|
+
* Represents a duration in seconds.
|
|
30
|
+
*
|
|
31
|
+
* Guaranteed to be a non-negative integer.
|
|
32
|
+
*/
|
|
33
|
+
type Duration = number;
|
|
34
|
+
/**
|
|
35
|
+
* The number of seconds in a year.
|
|
36
|
+
*
|
|
37
|
+
* (60 seconds per minute * 60 minutes per hour *
|
|
38
|
+
* 24 hours per day * 365.2425 days on average per year).
|
|
39
|
+
*/
|
|
40
|
+
declare const SECONDS_PER_YEAR: Duration;
|
|
41
|
+
declare function isValidDuration(duration: Duration): boolean;
|
|
42
|
+
declare function validateDuration(duration: Duration): void;
|
|
43
|
+
|
|
13
44
|
/**
|
|
14
45
|
* Start date for the ENS Holiday Awards referral program.
|
|
15
46
|
* 2025-12-01T00:00:00Z (December 1, 2025 at 00:00:00 UTC)
|
|
@@ -20,6 +51,263 @@ declare const ENS_HOLIDAY_AWARDS_START_DATE: UnixTimestamp;
|
|
|
20
51
|
* 2025-12-31T23:59:59Z (December 31, 2025 at 23:59:59 UTC)
|
|
21
52
|
*/
|
|
22
53
|
declare const ENS_HOLIDAY_AWARDS_END_DATE: UnixTimestamp;
|
|
54
|
+
/**
|
|
55
|
+
* The maximum number of qualified referrers for ENS Holiday Awards.
|
|
56
|
+
*/
|
|
57
|
+
declare const ENS_HOLIDAY_AWARDS_MAX_QUALIFIED_REFERRERS = 10;
|
|
58
|
+
/**
|
|
59
|
+
* The total value of the award pool in USD.
|
|
60
|
+
*/
|
|
61
|
+
declare const ENS_HOLIDAY_AWARDS_TOTAL_AWARD_POOL_VALUE: USDQuantity;
|
|
62
|
+
/**
|
|
63
|
+
* Chain ID
|
|
64
|
+
*
|
|
65
|
+
* Represents a unique identifier for a chain.
|
|
66
|
+
* Guaranteed to be a positive integer.
|
|
67
|
+
**/
|
|
68
|
+
type ChainId = number;
|
|
69
|
+
/**
|
|
70
|
+
* Represents an account (contract or EOA) at `address` on chain `chainId`.
|
|
71
|
+
*
|
|
72
|
+
* @see https://chainagnostic.org/CAIPs/caip-10
|
|
73
|
+
*/
|
|
74
|
+
interface AccountId {
|
|
75
|
+
chainId: ChainId;
|
|
76
|
+
address: Address;
|
|
77
|
+
}
|
|
78
|
+
interface ReferralProgramRules {
|
|
79
|
+
/**
|
|
80
|
+
* The total value of the award pool in USD.
|
|
81
|
+
*
|
|
82
|
+
* NOTE: Awards will actually be distributed in $ENS tokens.
|
|
83
|
+
*/
|
|
84
|
+
totalAwardPoolValue: USDQuantity;
|
|
85
|
+
/**
|
|
86
|
+
* The maximum number of referrers that will qualify to receive a non-zero `awardPoolShare`.
|
|
87
|
+
*
|
|
88
|
+
* @invariant Guaranteed to be a non-negative integer (>= 0)
|
|
89
|
+
*/
|
|
90
|
+
maxQualifiedReferrers: number;
|
|
91
|
+
/**
|
|
92
|
+
* The start time of the referral program.
|
|
93
|
+
*/
|
|
94
|
+
startTime: UnixTimestamp;
|
|
95
|
+
/**
|
|
96
|
+
* The end time of the referral program.
|
|
97
|
+
* @invariant Guaranteed to be greater than or equal to `startTime`
|
|
98
|
+
*/
|
|
99
|
+
endTime: UnixTimestamp;
|
|
100
|
+
/**
|
|
101
|
+
* The account ID of the subregistry for the referral program.
|
|
102
|
+
*/
|
|
103
|
+
subregistryId: AccountId;
|
|
104
|
+
}
|
|
105
|
+
declare const validateReferralProgramRules: (rules: ReferralProgramRules) => void;
|
|
106
|
+
declare const buildReferralProgramRules: (totalAwardPoolValue: USDQuantity, maxQualifiedReferrers: number, startTime: UnixTimestamp, endTime: UnixTimestamp, subregistryId: AccountId) => ReferralProgramRules;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The score of a referrer.
|
|
110
|
+
*
|
|
111
|
+
* @invariant Guaranteed to be a finite non-negative number (>= 0)
|
|
112
|
+
*/
|
|
113
|
+
type ReferrerScore = number;
|
|
114
|
+
declare const isValidReferrerScore: (score: ReferrerScore) => boolean;
|
|
115
|
+
declare const validateReferrerScore: (score: ReferrerScore) => void;
|
|
116
|
+
/**
|
|
117
|
+
* Calculate the score of a referrer based on the total incremental duration
|
|
118
|
+
* (in seconds) of registrations and renewals for direct subnames of .eth
|
|
119
|
+
* referrered by the referrer within the ENS Holiday Awards period.
|
|
120
|
+
*
|
|
121
|
+
* @param totalIncrementalDuration - The total incremental duration (in seconds)
|
|
122
|
+
* of referrals made by a referrer within the {@link ReferralProgramRules}.
|
|
123
|
+
* @returns The score of the referrer.
|
|
124
|
+
*/
|
|
125
|
+
declare const calcReferrerScore: (totalIncrementalDuration: Duration) => ReferrerScore;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The rank of a referrer relative to all other referrers, where 1 is the
|
|
129
|
+
* top-ranked referrer.
|
|
130
|
+
*
|
|
131
|
+
* @invariant Guaranteed to be a positive integer (> 0)
|
|
132
|
+
*/
|
|
133
|
+
type ReferrerRank = number;
|
|
134
|
+
declare const validateReferrerRank: (rank: ReferrerRank) => void;
|
|
135
|
+
/**
|
|
136
|
+
* Determine if a referrer with the given `rank` is qualified to receive a non-zero `awardPoolShare` according to the given `rules`.
|
|
137
|
+
*
|
|
138
|
+
* @param rank - The rank of the referrer relative to all other referrers on a {@link ReferrerLeaderboard}.
|
|
139
|
+
* @param rules - The rules of the referral program that generated the `rank`.
|
|
140
|
+
*/
|
|
141
|
+
declare function isReferrerQualified(rank: ReferrerRank, rules: ReferralProgramRules): boolean;
|
|
142
|
+
/**
|
|
143
|
+
* Calculate the final score boost of a referrer based on their rank.
|
|
144
|
+
*
|
|
145
|
+
* @param rank - The rank of the referrer relative to all other referrers, where 1 is the
|
|
146
|
+
* top-ranked referrer.
|
|
147
|
+
* @returns The final score boost of the referrer as a number between 0 and 1 (inclusive).
|
|
148
|
+
*/
|
|
149
|
+
declare function calcReferrerFinalScoreBoost(rank: ReferrerRank, rules: ReferralProgramRules): number;
|
|
150
|
+
/**
|
|
151
|
+
* Calculate the final score multiplier of a referrer based on their rank.
|
|
152
|
+
*
|
|
153
|
+
* @param rank - The rank of the referrer relative to all other referrers, where 1 is the
|
|
154
|
+
* top-ranked referrer.
|
|
155
|
+
* @returns The final score multiplier of the referrer as a number between 1 and 2 (inclusive).
|
|
156
|
+
*/
|
|
157
|
+
declare function calcReferrerFinalScoreMultiplier(rank: ReferrerRank, rules: ReferralProgramRules): number;
|
|
158
|
+
/**
|
|
159
|
+
* Calculate the final score of a referrer based on their score and final score boost.
|
|
160
|
+
*
|
|
161
|
+
* @param rank - The rank of the referrer relative to all other referrers.
|
|
162
|
+
* @param totalIncrementalDuration - The total incremental duration (in seconds)
|
|
163
|
+
* of referrals made by the referrer within the `rules`.
|
|
164
|
+
* @param rules - The rules of the referral program that generated the `rank`.
|
|
165
|
+
* @returns The final score of the referrer.
|
|
166
|
+
*/
|
|
167
|
+
declare function calcReferrerFinalScore(rank: ReferrerRank, totalIncrementalDuration: Duration, rules: ReferralProgramRules): ReferrerScore;
|
|
168
|
+
interface ReferrerMetricsForComparison {
|
|
169
|
+
/**
|
|
170
|
+
* The total incremental duration (in seconds) of all referrals made by the referrer within
|
|
171
|
+
* the {@link ReferralProgramRules}.
|
|
172
|
+
*/
|
|
173
|
+
totalIncrementalDuration: Duration;
|
|
174
|
+
/**
|
|
175
|
+
* The fully lowercase Ethereum address of the referrer.
|
|
176
|
+
*
|
|
177
|
+
* @invariant Guaranteed to be a valid EVM address in lowercase format.
|
|
178
|
+
*/
|
|
179
|
+
referrer: Address;
|
|
180
|
+
}
|
|
181
|
+
declare const compareReferrerMetrics: (a: ReferrerMetricsForComparison, b: ReferrerMetricsForComparison) => number;
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Represents metrics for a single referrer independent of other referrers.
|
|
185
|
+
*/
|
|
186
|
+
interface ReferrerMetrics {
|
|
187
|
+
/**
|
|
188
|
+
* The fully lowercase Ethereum address of the referrer.
|
|
189
|
+
*
|
|
190
|
+
* @invariant Guaranteed to be a valid EVM address in lowercase format
|
|
191
|
+
*/
|
|
192
|
+
referrer: Address;
|
|
193
|
+
/**
|
|
194
|
+
* The total number of referrals made by the referrer within the {@link ReferralProgramRules}.
|
|
195
|
+
* @invariant Guaranteed to be a non-negative integer (>= 0)
|
|
196
|
+
*/
|
|
197
|
+
totalReferrals: number;
|
|
198
|
+
/**
|
|
199
|
+
* The total incremental duration (in seconds) of all referrals made by the referrer within
|
|
200
|
+
* the {@link ReferralProgramRules}.
|
|
201
|
+
*/
|
|
202
|
+
totalIncrementalDuration: Duration;
|
|
203
|
+
}
|
|
204
|
+
declare const buildReferrerMetrics: (referrer: Address, totalReferrals: number, totalIncrementalDuration: Duration) => ReferrerMetrics;
|
|
205
|
+
declare const validateReferrerMetrics: (metrics: ReferrerMetrics) => void;
|
|
206
|
+
declare const sortReferrerMetrics: (referrers: ReferrerMetrics[]) => ReferrerMetrics[];
|
|
207
|
+
/**
|
|
208
|
+
* Represents metrics for a single referrer independent of other referrers,
|
|
209
|
+
* including a calculation of the referrer's score.
|
|
210
|
+
*/
|
|
211
|
+
interface ScoredReferrerMetrics extends ReferrerMetrics {
|
|
212
|
+
/**
|
|
213
|
+
* The referrer's score.
|
|
214
|
+
*
|
|
215
|
+
* @invariant Guaranteed to be `calcReferrerScore(totalIncrementalDuration)`
|
|
216
|
+
*/
|
|
217
|
+
score: ReferrerScore;
|
|
218
|
+
}
|
|
219
|
+
declare const buildScoredReferrerMetrics: (referrer: ReferrerMetrics) => ScoredReferrerMetrics;
|
|
220
|
+
declare const validateScoredReferrerMetrics: (metrics: ScoredReferrerMetrics) => void;
|
|
221
|
+
/**
|
|
222
|
+
* Extends {@link ScoredReferrerMetrics} to include additional metrics
|
|
223
|
+
* relative to all other referrers on a {@link ReferrerLeaderboard} and {@link ReferralProgramRules}.
|
|
224
|
+
*/
|
|
225
|
+
interface RankedReferrerMetrics extends ScoredReferrerMetrics {
|
|
226
|
+
/**
|
|
227
|
+
* The referrer's rank on the {@link ReferrerLeaderboard} relative to all other referrers.
|
|
228
|
+
*/
|
|
229
|
+
rank: ReferrerRank;
|
|
230
|
+
/**
|
|
231
|
+
* Identifies if the referrer meets the qualifications of the {@link ReferralProgramRules} to receive a non-zero `awardPoolShare`.
|
|
232
|
+
*
|
|
233
|
+
* @invariant true if and only if `rank` is less than or equal to {@link ReferralProgramRules.maxQualifiedReferrers}
|
|
234
|
+
*/
|
|
235
|
+
isQualified: boolean;
|
|
236
|
+
/**
|
|
237
|
+
* The referrer's final score boost.
|
|
238
|
+
*
|
|
239
|
+
* @invariant Guaranteed to be a number between 0 and 1 (inclusive)
|
|
240
|
+
* @invariant Calculated as: `1-((rank-1)/({@link ReferralProgramRules.maxQualifiedReferrers}-1))` if `isQualified` is `true`, else `0`
|
|
241
|
+
*/
|
|
242
|
+
finalScoreBoost: number;
|
|
243
|
+
/**
|
|
244
|
+
* The referrer's final score.
|
|
245
|
+
*
|
|
246
|
+
* @invariant Calculated as: `score * (1 + finalScoreBoost)`
|
|
247
|
+
*/
|
|
248
|
+
finalScore: ReferrerScore;
|
|
249
|
+
}
|
|
250
|
+
declare const validateRankedReferrerMetrics: (metrics: RankedReferrerMetrics, rules: ReferralProgramRules) => void;
|
|
251
|
+
declare const buildRankedReferrerMetrics: (referrer: ScoredReferrerMetrics, rank: ReferrerRank, rules: ReferralProgramRules) => RankedReferrerMetrics;
|
|
252
|
+
/**
|
|
253
|
+
* Calculate the share of the award pool for a referrer.
|
|
254
|
+
* @param referrer - The referrer to calculate the award pool share for.
|
|
255
|
+
* @param aggregatedMetrics - Aggregated metrics for all referrers.
|
|
256
|
+
* @param rules - The rules of the referral program.
|
|
257
|
+
* @returns The referrer's share of the award pool as a number between 0 and 1 (inclusive).
|
|
258
|
+
*/
|
|
259
|
+
declare const calcReferrerAwardPoolShare: (referrer: RankedReferrerMetrics, aggregatedMetrics: AggregatedReferrerMetrics, rules: ReferralProgramRules) => number;
|
|
260
|
+
/**
|
|
261
|
+
* Extends {@link RankedReferrerMetrics} to include additional metrics
|
|
262
|
+
* relative to {@link AggregatedRankedReferrerMetrics}.
|
|
263
|
+
*/
|
|
264
|
+
interface AwardedReferrerMetrics extends RankedReferrerMetrics {
|
|
265
|
+
/**
|
|
266
|
+
* The referrer's share of the award pool.
|
|
267
|
+
*
|
|
268
|
+
* @invariant Guaranteed to be a number between 0 and 1 (inclusive)
|
|
269
|
+
* @invariant Calculated as: `finalScore / {@link AggregatedRankedReferrerMetrics.grandTotalQualifiedReferrersFinalScore}` if `isQualified` is `true`, else `0`
|
|
270
|
+
*/
|
|
271
|
+
awardPoolShare: number;
|
|
272
|
+
/**
|
|
273
|
+
* The approximate {@link USDQuantity} of the referrer's share of the {@link ReferralProgramRules.totalAwardPoolValue}.
|
|
274
|
+
*
|
|
275
|
+
* @invariant Guaranteed to be a number between 0 and {@link ReferralProgramRules.totalAwardPoolValue} (inclusive)
|
|
276
|
+
* @invariant Calculated as: `awardPoolShare` * {@link ReferralProgramRules.totalAwardPoolValue}
|
|
277
|
+
*/
|
|
278
|
+
awardPoolApproxValue: USDQuantity;
|
|
279
|
+
}
|
|
280
|
+
declare const validateAwardedReferrerMetrics: (referrer: AwardedReferrerMetrics, rules: ReferralProgramRules) => void;
|
|
281
|
+
declare const buildAwardedReferrerMetrics: (referrer: RankedReferrerMetrics, aggregatedMetrics: AggregatedReferrerMetrics, rules: ReferralProgramRules) => AwardedReferrerMetrics;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Represents aggregated metrics for a list of `RankedReferrerMetrics`.
|
|
285
|
+
*/
|
|
286
|
+
interface AggregatedReferrerMetrics {
|
|
287
|
+
/**
|
|
288
|
+
* @invariant The sum of `totalReferrals` across all `RankedReferrerMetrics` in the list.
|
|
289
|
+
* @invariant Guaranteed to be a non-negative integer (>= 0)
|
|
290
|
+
*/
|
|
291
|
+
grandTotalReferrals: number;
|
|
292
|
+
/**
|
|
293
|
+
* @invariant The sum of `totalIncrementalDuration` across all `RankedReferrerMetrics` in the list.
|
|
294
|
+
*/
|
|
295
|
+
grandTotalIncrementalDuration: Duration;
|
|
296
|
+
/**
|
|
297
|
+
* @invariant The sum of `finalScore` across all `RankedReferrerMetrics` where `isQualified` is `true`.
|
|
298
|
+
*/
|
|
299
|
+
grandTotalQualifiedReferrersFinalScore: ReferrerScore;
|
|
300
|
+
/**
|
|
301
|
+
* @invariant Identifies the minimum final score required to become a qualified referrer.
|
|
302
|
+
* @invariant If `rules.maxQualifiedReferrers` is 0, then `minFinalScoreToQualify` is guaranteed to
|
|
303
|
+
* be `Number.MAX_SAFE_INTEGER`.
|
|
304
|
+
* @invariant If `rules.maxQualifiedReferrers` is greater than 0, and there are no current referrers
|
|
305
|
+
* matching the `rules`, then `minFinalScoreToQualify` is guaranteed to be `0`.
|
|
306
|
+
*/
|
|
307
|
+
minFinalScoreToQualify: ReferrerScore;
|
|
308
|
+
}
|
|
309
|
+
declare const validateAggregatedReferrerMetrics: (metrics: AggregatedReferrerMetrics) => void;
|
|
310
|
+
declare const buildAggregatedReferrerMetrics: (referrers: RankedReferrerMetrics[], rules: ReferralProgramRules) => AggregatedReferrerMetrics;
|
|
23
311
|
|
|
24
312
|
/**
|
|
25
313
|
* Encoded Referrer
|
|
@@ -48,13 +336,13 @@ declare const ENCODED_REFERRER_BYTE_LENGTH = 32;
|
|
|
48
336
|
*
|
|
49
337
|
* The initial bytes of correctly encoded referrer value for ENS Holiday Awards.
|
|
50
338
|
*/
|
|
51
|
-
declare const
|
|
339
|
+
declare const EXPECTED_ENCODED_REFERRER_PADDING: Hex;
|
|
52
340
|
/**
|
|
53
341
|
* Zero Encoded Referrer
|
|
54
342
|
*
|
|
55
343
|
* Guaranteed to be a hex string representation of a 32-byte zero value.
|
|
56
344
|
*/
|
|
57
|
-
declare const
|
|
345
|
+
declare const ZERO_ENCODED_REFERRER: EncodedReferrer;
|
|
58
346
|
/**
|
|
59
347
|
* Build an {@link EncodedReferrer} value for the given {@link Address}
|
|
60
348
|
* according to the subjective referrer encoding used for ENS Holiday Awards.
|
|
@@ -71,10 +359,152 @@ declare function buildEncodedReferrer(address: Address): EncodedReferrer;
|
|
|
71
359
|
* @throws when decodedReferrer is not a valid EVM address.
|
|
72
360
|
*/
|
|
73
361
|
declare function decodeEncodedReferrer(encodedReferrer: EncodedReferrer): Address;
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* Represents a leaderboard for any number of referrers.
|
|
365
|
+
*/
|
|
366
|
+
interface ReferrerLeaderboard {
|
|
367
|
+
/**
|
|
368
|
+
* The rules of the referral program that generated the {@link ReferrerLeaderboard}.
|
|
369
|
+
*/
|
|
370
|
+
rules: ReferralProgramRules;
|
|
371
|
+
/**
|
|
372
|
+
* The {@link AggregatedReferrerMetrics} for all `RankedReferrerMetrics` values in `leaderboard`.
|
|
373
|
+
*/
|
|
374
|
+
aggregatedMetrics: AggregatedReferrerMetrics;
|
|
375
|
+
/**
|
|
376
|
+
* Ordered map containing `AwardedReferrerMetrics` for all referrers with 1 or more
|
|
377
|
+
* `totalReferrals` within the `rules` as of `updatedAt`.
|
|
378
|
+
*
|
|
379
|
+
* @invariant Map entries are ordered by `rank` (ascending).
|
|
380
|
+
* @invariant Map is empty if there are no referrers with 1 or more `totalReferrals`
|
|
381
|
+
* within the `rules` as of `updatedAt`.
|
|
382
|
+
* @invariant If a fully-lowercase `Address` is not a key in this map then that `Address` had
|
|
383
|
+
* 0 `totalReferrals`, `totalIncrementalDuration`, and `score` within the
|
|
384
|
+
* `rules` as of `updatedAt`.
|
|
385
|
+
* @invariant Each value in this map is guaranteed to have a non-zero
|
|
386
|
+
* `totalReferrals`, `totalIncrementalDuration`, and `score`.
|
|
387
|
+
*/
|
|
388
|
+
referrers: Map<Address, AwardedReferrerMetrics>;
|
|
389
|
+
/**
|
|
390
|
+
* The {@link UnixTimestamp} of when the data used to build the {@link ReferrerLeaderboard} was accurate as of.
|
|
391
|
+
*/
|
|
392
|
+
accurateAsOf: UnixTimestamp;
|
|
393
|
+
}
|
|
394
|
+
declare const buildReferrerLeaderboard: (allReferrers: ReferrerMetrics[], rules: ReferralProgramRules, accurateAsOf: UnixTimestamp) => ReferrerLeaderboard;
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* The default number of referrers per leaderboard page.
|
|
398
|
+
*/
|
|
399
|
+
declare const REFERRERS_PER_LEADERBOARD_PAGE_DEFAULT = 25;
|
|
400
|
+
/**
|
|
401
|
+
* The maximum number of referrers per leaderboard page.
|
|
402
|
+
*/
|
|
403
|
+
declare const REFERRERS_PER_LEADERBOARD_PAGE_MAX = 100;
|
|
404
|
+
/**
|
|
405
|
+
* Pagination params for leaderboard queries.
|
|
406
|
+
*/
|
|
407
|
+
interface ReferrerLeaderboardPaginationParams {
|
|
408
|
+
/**
|
|
409
|
+
* Requested referrer leaderboard page number (1-indexed)
|
|
410
|
+
* @invariant Must be a positive integer (>= 1)
|
|
411
|
+
* @default 1
|
|
412
|
+
*/
|
|
413
|
+
page?: number;
|
|
414
|
+
/**
|
|
415
|
+
* Maximum number of referrers to return per leaderboard page
|
|
416
|
+
* @invariant Must be a positive integer (>= 1) and less than or equal to {@link REFERRERS_PER_LEADERBOARD_PAGE_MAX}
|
|
417
|
+
* @default {@link REFERRERS_PER_LEADERBOARD_PAGE_DEFAULT}
|
|
418
|
+
*/
|
|
419
|
+
itemsPerPage?: number;
|
|
420
|
+
}
|
|
421
|
+
declare const buildReferrerLeaderboardPaginationParams: (params: ReferrerLeaderboardPaginationParams) => Required<ReferrerLeaderboardPaginationParams>;
|
|
422
|
+
interface ReferrerLeaderboardPaginationContext extends Required<ReferrerLeaderboardPaginationParams> {
|
|
423
|
+
/**
|
|
424
|
+
* Total number of referrers across all leaderboard pages
|
|
425
|
+
* @invariant Guaranteed to be a non-negative integer (>= 0)
|
|
426
|
+
*/
|
|
427
|
+
totalRecords: number;
|
|
428
|
+
/**
|
|
429
|
+
* Total number of pages in the leaderboard
|
|
430
|
+
* @invariant Guaranteed to be a positive integer (>= 1)
|
|
431
|
+
*/
|
|
432
|
+
totalPages: number;
|
|
433
|
+
/**
|
|
434
|
+
* Indicates if there is a next page available
|
|
435
|
+
* @invariant true if and only if (`page` * `itemsPerPage` < `total`)
|
|
436
|
+
*/
|
|
437
|
+
hasNext: boolean;
|
|
438
|
+
/**
|
|
439
|
+
* Indicates if there is a previous page available
|
|
440
|
+
* @invariant true if and only if (`page` > 1)
|
|
441
|
+
*/
|
|
442
|
+
hasPrev: boolean;
|
|
443
|
+
/**
|
|
444
|
+
* The start index of the referrers on the page (0-indexed)
|
|
445
|
+
*
|
|
446
|
+
* `undefined` if and only if `totalRecords` is 0.
|
|
447
|
+
*
|
|
448
|
+
* @invariant Guaranteed to be a non-negative integer (>= 0)
|
|
449
|
+
*/
|
|
450
|
+
startIndex?: number;
|
|
451
|
+
/**
|
|
452
|
+
* The end index of the referrers on the page (0-indexed)
|
|
453
|
+
*
|
|
454
|
+
* `undefined` if and only if `totalRecords` is 0.
|
|
455
|
+
*
|
|
456
|
+
* @invariant Guaranteed to be a non-negative integer (>= 0)
|
|
457
|
+
* @invariant If `totalRecords` is > 0:
|
|
458
|
+
* - Guaranteed to be greater than or equal to `startIndex`.
|
|
459
|
+
* - Guaranteed to be less than `totalRecords`.
|
|
460
|
+
*/
|
|
461
|
+
endIndex?: number;
|
|
462
|
+
}
|
|
463
|
+
declare const validateReferrerLeaderboardPaginationContext: (context: ReferrerLeaderboardPaginationContext) => void;
|
|
464
|
+
declare const buildReferrerLeaderboardPaginationContext: (optionalParams: ReferrerLeaderboardPaginationParams, leaderboard: ReferrerLeaderboard) => ReferrerLeaderboardPaginationContext;
|
|
465
|
+
/**
|
|
466
|
+
* A page of referrers from the referrer leaderboard.
|
|
467
|
+
*/
|
|
468
|
+
interface ReferrerLeaderboardPage {
|
|
469
|
+
/**
|
|
470
|
+
* The {@link ReferralProgramRules} used to generate the {@link ReferrerLeaderboard}
|
|
471
|
+
* that this {@link ReferrerLeaderboardPage} comes from.
|
|
472
|
+
*/
|
|
473
|
+
rules: ReferralProgramRules;
|
|
474
|
+
/**
|
|
475
|
+
* Ordered list of {@link AwardedReferrerMetrics} for the {@link ReferrerLeaderboardPage}
|
|
476
|
+
* described by `paginationContext` within the related {@link ReferrerLeaderboard}.
|
|
477
|
+
*
|
|
478
|
+
* @invariant Array will be empty if `paginationContext.totalRecords` is 0.
|
|
479
|
+
* @invariant Array entries are ordered by `rank` (descending).
|
|
480
|
+
*/
|
|
481
|
+
referrers: AwardedReferrerMetrics[];
|
|
482
|
+
/**
|
|
483
|
+
* Aggregated metrics for all referrers on the leaderboard.
|
|
484
|
+
*/
|
|
485
|
+
aggregatedMetrics: AggregatedReferrerMetrics;
|
|
486
|
+
/**
|
|
487
|
+
* The {@link ReferrerLeaderboardPaginationContext} of this {@link ReferrerLeaderboardPage} relative to the overall
|
|
488
|
+
* {@link ReferrerLeaderboard}.
|
|
489
|
+
*/
|
|
490
|
+
paginationContext: ReferrerLeaderboardPaginationContext;
|
|
491
|
+
/**
|
|
492
|
+
* The {@link UnixTimestamp} of when the data used to build the {@link ReferrerLeaderboardPage} was accurate as of.
|
|
493
|
+
*/
|
|
494
|
+
accurateAsOf: UnixTimestamp;
|
|
495
|
+
}
|
|
496
|
+
declare const getReferrerLeaderboardPage: (paginationParams: ReferrerLeaderboardPaginationParams, leaderboard: ReferrerLeaderboard) => ReferrerLeaderboardPage;
|
|
497
|
+
|
|
74
498
|
/**
|
|
75
499
|
* Build a URL to the official ENS manager app
|
|
76
500
|
* where the given {@link Address} is set as the referrer.
|
|
77
501
|
*/
|
|
78
502
|
declare function buildEnsReferralUrl(address: Address): URL;
|
|
79
503
|
|
|
80
|
-
|
|
504
|
+
declare const isInteger: (value: number) => boolean;
|
|
505
|
+
declare const isNonNegativeInteger: (value: number) => boolean;
|
|
506
|
+
declare const isPositiveInteger: (value: number) => boolean;
|
|
507
|
+
declare const validateNonNegativeInteger: (value: number) => void;
|
|
508
|
+
declare const isFiniteNonNegativeNumber: (value: number) => boolean;
|
|
509
|
+
|
|
510
|
+
export { type AccountId, type AggregatedReferrerMetrics, type AwardedReferrerMetrics, type ChainId, type Duration, ENCODED_REFERRER_BYTE_LENGTH, ENCODED_REFERRER_BYTE_OFFSET, ENS_HOLIDAY_AWARDS_END_DATE, ENS_HOLIDAY_AWARDS_MAX_QUALIFIED_REFERRERS, ENS_HOLIDAY_AWARDS_START_DATE, ENS_HOLIDAY_AWARDS_TOTAL_AWARD_POOL_VALUE, EXPECTED_ENCODED_REFERRER_PADDING, type EncodedReferrer, REFERRERS_PER_LEADERBOARD_PAGE_DEFAULT, REFERRERS_PER_LEADERBOARD_PAGE_MAX, type RankedReferrerMetrics, type ReferralProgramRules, type ReferrerLeaderboard, type ReferrerLeaderboardPage, type ReferrerLeaderboardPaginationContext, type ReferrerLeaderboardPaginationParams, type ReferrerMetrics, type ReferrerMetricsForComparison, type ReferrerRank, type ReferrerScore, SECONDS_PER_YEAR, type ScoredReferrerMetrics, type USDQuantity, type UnixTimestamp, ZERO_ENCODED_REFERRER, buildAggregatedReferrerMetrics, buildAwardedReferrerMetrics, buildEncodedReferrer, buildEnsReferralUrl, buildRankedReferrerMetrics, buildReferralProgramRules, buildReferrerLeaderboard, buildReferrerLeaderboardPaginationContext, buildReferrerLeaderboardPaginationParams, buildReferrerMetrics, buildScoredReferrerMetrics, calcReferrerAwardPoolShare, calcReferrerFinalScore, calcReferrerFinalScoreBoost, calcReferrerFinalScoreMultiplier, calcReferrerScore, compareReferrerMetrics, decodeEncodedReferrer, getReferrerLeaderboardPage, isFiniteNonNegativeNumber, isInteger, isNonNegativeInteger, isPositiveInteger, isReferrerQualified, isValidDuration, isValidReferrerScore, isValidUSDQuantity, normalizeAddress, sortReferrerMetrics, validateAggregatedReferrerMetrics, validateAwardedReferrerMetrics, validateDuration, validateLowercaseAddress, validateNonNegativeInteger, validateRankedReferrerMetrics, validateReferralProgramRules, validateReferrerLeaderboardPaginationContext, validateReferrerMetrics, validateReferrerRank, validateReferrerScore, validateScoredReferrerMetrics, validateUSDQuantity, validateUnixTimestamp };
|