@namehash/ens-referrals 1.0.1 → 1.2.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.d.cts CHANGED
@@ -1,15 +1,46 @@
1
- import { Hex, Address } from 'viem';
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,288 @@ 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
+ * Extends {@link AwardedReferrerMetrics} but with rank set to null to represent
284
+ * a referrer who is not on the leaderboard (has zero referrals within the rules associated with the leaderboard).
285
+ */
286
+ interface UnrankedReferrerMetrics extends Omit<AwardedReferrerMetrics, "rank" | "isQualified"> {
287
+ /**
288
+ * The referrer is not on the leaderboard and therefore has no rank.
289
+ */
290
+ rank: null;
291
+ /**
292
+ * Always false for unranked referrers.
293
+ */
294
+ isQualified: false;
295
+ }
296
+ declare const validateUnrankedReferrerMetrics: (metrics: UnrankedReferrerMetrics) => void;
297
+ /**
298
+ * Build an unranked zero-score referrer record for a referrer address that is not in the leaderboard.
299
+ *
300
+ * This is useful when you want to return a referrer record for an address that has no referrals
301
+ * and is not qualified for the leaderboard.
302
+ *
303
+ * @param referrer - The referrer address
304
+ * @returns An {@link UnrankedReferrerMetrics} with zero values for all metrics and null rank
305
+ */
306
+ declare const buildUnrankedReferrerMetrics: (referrer: Address) => UnrankedReferrerMetrics;
307
+
308
+ /**
309
+ * Represents aggregated metrics for a list of `RankedReferrerMetrics`.
310
+ */
311
+ interface AggregatedReferrerMetrics {
312
+ /**
313
+ * @invariant The sum of `totalReferrals` across all `RankedReferrerMetrics` in the list.
314
+ * @invariant Guaranteed to be a non-negative integer (>= 0)
315
+ */
316
+ grandTotalReferrals: number;
317
+ /**
318
+ * @invariant The sum of `totalIncrementalDuration` across all `RankedReferrerMetrics` in the list.
319
+ */
320
+ grandTotalIncrementalDuration: Duration;
321
+ /**
322
+ * @invariant The sum of `finalScore` across all `RankedReferrerMetrics` where `isQualified` is `true`.
323
+ */
324
+ grandTotalQualifiedReferrersFinalScore: ReferrerScore;
325
+ /**
326
+ * @invariant Identifies the minimum final score required to become a qualified referrer.
327
+ * @invariant If `rules.maxQualifiedReferrers` is 0, then `minFinalScoreToQualify` is guaranteed to
328
+ * be `Number.MAX_SAFE_INTEGER`.
329
+ * @invariant If `rules.maxQualifiedReferrers` is greater than 0, and there are no current referrers
330
+ * matching the `rules`, then `minFinalScoreToQualify` is guaranteed to be `0`.
331
+ */
332
+ minFinalScoreToQualify: ReferrerScore;
333
+ }
334
+ declare const validateAggregatedReferrerMetrics: (metrics: AggregatedReferrerMetrics) => void;
335
+ declare const buildAggregatedReferrerMetrics: (referrers: RankedReferrerMetrics[], rules: ReferralProgramRules) => AggregatedReferrerMetrics;
23
336
 
24
337
  /**
25
338
  * Encoded Referrer
@@ -48,13 +361,13 @@ declare const ENCODED_REFERRER_BYTE_LENGTH = 32;
48
361
  *
49
362
  * The initial bytes of correctly encoded referrer value for ENS Holiday Awards.
50
363
  */
51
- declare const encodedReferrerPadding: `0x${string}`;
364
+ declare const EXPECTED_ENCODED_REFERRER_PADDING: Hex;
52
365
  /**
53
366
  * Zero Encoded Referrer
54
367
  *
55
368
  * Guaranteed to be a hex string representation of a 32-byte zero value.
56
369
  */
57
- declare const zeroEncodedReferrer: `0x${string}`;
370
+ declare const ZERO_ENCODED_REFERRER: EncodedReferrer;
58
371
  /**
59
372
  * Build an {@link EncodedReferrer} value for the given {@link Address}
60
373
  * according to the subjective referrer encoding used for ENS Holiday Awards.
@@ -71,10 +384,257 @@ declare function buildEncodedReferrer(address: Address): EncodedReferrer;
71
384
  * @throws when decodedReferrer is not a valid EVM address.
72
385
  */
73
386
  declare function decodeEncodedReferrer(encodedReferrer: EncodedReferrer): Address;
387
+
388
+ /**
389
+ * Represents a leaderboard for any number of referrers.
390
+ */
391
+ interface ReferrerLeaderboard {
392
+ /**
393
+ * The rules of the referral program that generated the {@link ReferrerLeaderboard}.
394
+ */
395
+ rules: ReferralProgramRules;
396
+ /**
397
+ * The {@link AggregatedReferrerMetrics} for all `RankedReferrerMetrics` values in `leaderboard`.
398
+ */
399
+ aggregatedMetrics: AggregatedReferrerMetrics;
400
+ /**
401
+ * Ordered map containing `AwardedReferrerMetrics` for all referrers with 1 or more
402
+ * `totalReferrals` within the `rules` as of `updatedAt`.
403
+ *
404
+ * @invariant Map entries are ordered by `rank` (ascending).
405
+ * @invariant Map is empty if there are no referrers with 1 or more `totalReferrals`
406
+ * within the `rules` as of `updatedAt`.
407
+ * @invariant If a fully-lowercase `Address` is not a key in this map then that `Address` had
408
+ * 0 `totalReferrals`, `totalIncrementalDuration`, and `score` within the
409
+ * `rules` as of `updatedAt`.
410
+ * @invariant Each value in this map is guaranteed to have a non-zero
411
+ * `totalReferrals`, `totalIncrementalDuration`, and `score`.
412
+ */
413
+ referrers: Map<Address, AwardedReferrerMetrics>;
414
+ /**
415
+ * The {@link UnixTimestamp} of when the data used to build the {@link ReferrerLeaderboard} was accurate as of.
416
+ */
417
+ accurateAsOf: UnixTimestamp;
418
+ }
419
+ declare const buildReferrerLeaderboard: (allReferrers: ReferrerMetrics[], rules: ReferralProgramRules, accurateAsOf: UnixTimestamp) => ReferrerLeaderboard;
420
+
421
+ /**
422
+ * The default number of referrers per leaderboard page.
423
+ */
424
+ declare const REFERRERS_PER_LEADERBOARD_PAGE_DEFAULT = 25;
425
+ /**
426
+ * The maximum number of referrers per leaderboard page.
427
+ */
428
+ declare const REFERRERS_PER_LEADERBOARD_PAGE_MAX = 100;
429
+ /**
430
+ * Pagination params for leaderboard queries.
431
+ */
432
+ interface ReferrerLeaderboardPageParams {
433
+ /**
434
+ * Requested referrer leaderboard page number (1-indexed)
435
+ * @invariant Must be a positive integer (>= 1)
436
+ * @default 1
437
+ */
438
+ page?: number;
439
+ /**
440
+ * Maximum number of referrers to return per leaderboard page
441
+ * @invariant Must be a positive integer (>= 1) and less than or equal to {@link REFERRERS_PER_LEADERBOARD_PAGE_MAX}
442
+ * @default {@link REFERRERS_PER_LEADERBOARD_PAGE_DEFAULT}
443
+ */
444
+ itemsPerPage?: number;
445
+ }
446
+ declare const buildReferrerLeaderboardPageParams: (params: ReferrerLeaderboardPageParams) => Required<ReferrerLeaderboardPageParams>;
447
+ interface ReferrerLeaderboardPageContext extends Required<ReferrerLeaderboardPageParams> {
448
+ /**
449
+ * Total number of referrers across all leaderboard pages
450
+ * @invariant Guaranteed to be a non-negative integer (>= 0)
451
+ */
452
+ totalRecords: number;
453
+ /**
454
+ * Total number of pages in the leaderboard
455
+ * @invariant Guaranteed to be a positive integer (>= 1)
456
+ */
457
+ totalPages: number;
458
+ /**
459
+ * Indicates if there is a next page available
460
+ * @invariant true if and only if (`page` * `itemsPerPage` < `total`)
461
+ */
462
+ hasNext: boolean;
463
+ /**
464
+ * Indicates if there is a previous page available
465
+ * @invariant true if and only if (`page` > 1)
466
+ */
467
+ hasPrev: boolean;
468
+ /**
469
+ * The start index of the referrers on the page (0-indexed)
470
+ *
471
+ * `undefined` if and only if `totalRecords` is 0.
472
+ *
473
+ * @invariant Guaranteed to be a non-negative integer (>= 0)
474
+ */
475
+ startIndex?: number;
476
+ /**
477
+ * The end index of the referrers on the page (0-indexed)
478
+ *
479
+ * `undefined` if and only if `totalRecords` is 0.
480
+ *
481
+ * @invariant Guaranteed to be a non-negative integer (>= 0)
482
+ * @invariant If `totalRecords` is > 0:
483
+ * - Guaranteed to be greater than or equal to `startIndex`.
484
+ * - Guaranteed to be less than `totalRecords`.
485
+ */
486
+ endIndex?: number;
487
+ }
488
+ declare const validateReferrerLeaderboardPageContext: (context: ReferrerLeaderboardPageContext) => void;
489
+ declare const buildReferrerLeaderboardPageContext: (optionalParams: ReferrerLeaderboardPageParams, leaderboard: ReferrerLeaderboard) => ReferrerLeaderboardPageContext;
490
+ /**
491
+ * A page of referrers from the referrer leaderboard.
492
+ */
493
+ interface ReferrerLeaderboardPage {
494
+ /**
495
+ * The {@link ReferralProgramRules} used to generate the {@link ReferrerLeaderboard}
496
+ * that this {@link ReferrerLeaderboardPage} comes from.
497
+ */
498
+ rules: ReferralProgramRules;
499
+ /**
500
+ * Ordered list of {@link AwardedReferrerMetrics} for the {@link ReferrerLeaderboardPage}
501
+ * described by `paginationContext` within the related {@link ReferrerLeaderboard}.
502
+ *
503
+ * @invariant Array will be empty if `paginationContext.totalRecords` is 0.
504
+ * @invariant Array entries are ordered by `rank` (descending).
505
+ */
506
+ referrers: AwardedReferrerMetrics[];
507
+ /**
508
+ * Aggregated metrics for all referrers on the leaderboard.
509
+ */
510
+ aggregatedMetrics: AggregatedReferrerMetrics;
511
+ /**
512
+ * The {@link ReferrerLeaderboardPageContext} of this {@link ReferrerLeaderboardPage} relative to the overall
513
+ * {@link ReferrerLeaderboard}.
514
+ */
515
+ paginationContext: ReferrerLeaderboardPageContext;
516
+ /**
517
+ * The {@link UnixTimestamp} of when the data used to build the {@link ReferrerLeaderboardPage} was accurate as of.
518
+ */
519
+ accurateAsOf: UnixTimestamp;
520
+ }
521
+ declare const getReferrerLeaderboardPage: (paginationParams: ReferrerLeaderboardPageParams, leaderboard: ReferrerLeaderboard) => ReferrerLeaderboardPage;
522
+
74
523
  /**
75
524
  * Build a URL to the official ENS manager app
76
525
  * where the given {@link Address} is set as the referrer.
77
526
  */
78
527
  declare function buildEnsReferralUrl(address: Address): URL;
79
528
 
80
- export { ENCODED_REFERRER_BYTE_LENGTH, ENCODED_REFERRER_BYTE_OFFSET, ENS_HOLIDAY_AWARDS_END_DATE, ENS_HOLIDAY_AWARDS_START_DATE, type EncodedReferrer, type UnixTimestamp, buildEncodedReferrer, buildEnsReferralUrl, decodeEncodedReferrer, encodedReferrerPadding, zeroEncodedReferrer };
529
+ declare const isInteger: (value: number) => boolean;
530
+ declare const isNonNegativeInteger: (value: number) => boolean;
531
+ declare const isPositiveInteger: (value: number) => boolean;
532
+ declare const validateNonNegativeInteger: (value: number) => void;
533
+ declare const isFiniteNonNegativeNumber: (value: number) => boolean;
534
+
535
+ /**
536
+ * The type of referrer detail data.
537
+ */
538
+ declare const ReferrerDetailTypeIds: {
539
+ /**
540
+ * Represents a referrer who is ranked on the leaderboard.
541
+ */
542
+ readonly Ranked: "ranked";
543
+ /**
544
+ * Represents a referrer who is not ranked on the leaderboard.
545
+ */
546
+ readonly Unranked: "unranked";
547
+ };
548
+ /**
549
+ * The derived string union of possible {@link ReferrerDetailTypeIds}.
550
+ */
551
+ type ReferrerDetailTypeId = (typeof ReferrerDetailTypeIds)[keyof typeof ReferrerDetailTypeIds];
552
+ /**
553
+ * Referrer detail data for a specific referrer address on the leaderboard.
554
+ *
555
+ * Includes the referrer's awarded metrics from the leaderboard plus timestamp.
556
+ *
557
+ * Invariants:
558
+ * - `type` is always {@link ReferrerDetailTypeIds.Ranked}.
559
+ *
560
+ * @see {@link AwardedReferrerMetrics}
561
+ */
562
+ interface ReferrerDetailRanked {
563
+ /**
564
+ * The type of referrer detail data.
565
+ */
566
+ type: typeof ReferrerDetailTypeIds.Ranked;
567
+ /**
568
+ * The {@link ReferralProgramRules} used to calculate the {@link AwardedReferrerMetrics}.
569
+ */
570
+ rules: ReferralProgramRules;
571
+ /**
572
+ * The awarded referrer metrics from the leaderboard.
573
+ *
574
+ * Contains all calculated metrics including score, rank, qualification status,
575
+ * and award pool share information.
576
+ */
577
+ referrer: AwardedReferrerMetrics;
578
+ /**
579
+ * Aggregated metrics for all referrers on the leaderboard.
580
+ */
581
+ aggregatedMetrics: AggregatedReferrerMetrics;
582
+ /**
583
+ * The {@link UnixTimestamp} of when the data used to build the {@link ReferrerDetailData} was accurate as of.
584
+ */
585
+ accurateAsOf: UnixTimestamp;
586
+ }
587
+ /**
588
+ * Referrer detail data for a specific referrer address NOT on the leaderboard.
589
+ *
590
+ * Includes the referrer's unranked metrics (with null rank and isQualified: false) plus timestamp.
591
+ *
592
+ * Invariants:
593
+ * - `type` is always {@link ReferrerDetailTypeIds.Unranked}.
594
+ *
595
+ * @see {@link UnrankedReferrerMetrics}
596
+ */
597
+ interface ReferrerDetailUnranked {
598
+ /**
599
+ * The type of referrer detail data.
600
+ */
601
+ type: typeof ReferrerDetailTypeIds.Unranked;
602
+ /**
603
+ * The {@link ReferralProgramRules} used to calculate the {@link UnrankedReferrerMetrics}.
604
+ */
605
+ rules: ReferralProgramRules;
606
+ /**
607
+ * The unranked referrer metrics (not on the leaderboard).
608
+ *
609
+ * Contains all calculated metrics with rank set to null and isQualified set to false.
610
+ */
611
+ referrer: UnrankedReferrerMetrics;
612
+ /**
613
+ * Aggregated metrics for all referrers on the leaderboard.
614
+ */
615
+ aggregatedMetrics: AggregatedReferrerMetrics;
616
+ /**
617
+ * The {@link UnixTimestamp} of when the data used to build the {@link UnrankedReferrerDetailData} was accurate as of.
618
+ */
619
+ accurateAsOf: UnixTimestamp;
620
+ }
621
+ /**
622
+ * Referrer detail data for a specific referrer address.
623
+ *
624
+ * Use the `type` field to determine the specific type interpretation
625
+ * at runtime.
626
+ */
627
+ type ReferrerDetail = ReferrerDetailRanked | ReferrerDetailUnranked;
628
+ /**
629
+ * Get the detail for a specific referrer from the leaderboard.
630
+ *
631
+ * Returns a {@link ReferrerDetailRanked} if the referrer is on the leaderboard,
632
+ * or a {@link ReferrerDetailUnranked} if the referrer has no referrals.
633
+ *
634
+ * @param referrer - The referrer address to look up
635
+ * @param leaderboard - The referrer leaderboard to query
636
+ * @returns The appropriate {@link ReferrerDetail} (ranked or unranked)
637
+ */
638
+ declare const getReferrerDetail: (referrer: Address, leaderboard: ReferrerLeaderboard) => ReferrerDetail;
639
+
640
+ 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 ReferrerDetail, type ReferrerDetailRanked, type ReferrerDetailTypeId, ReferrerDetailTypeIds, type ReferrerDetailUnranked, type ReferrerLeaderboard, type ReferrerLeaderboardPage, type ReferrerLeaderboardPageContext, type ReferrerLeaderboardPageParams, type ReferrerMetrics, type ReferrerMetricsForComparison, type ReferrerRank, type ReferrerScore, SECONDS_PER_YEAR, type ScoredReferrerMetrics, type USDQuantity, type UnixTimestamp, type UnrankedReferrerMetrics, ZERO_ENCODED_REFERRER, buildAggregatedReferrerMetrics, buildAwardedReferrerMetrics, buildEncodedReferrer, buildEnsReferralUrl, buildRankedReferrerMetrics, buildReferralProgramRules, buildReferrerLeaderboard, buildReferrerLeaderboardPageContext, buildReferrerLeaderboardPageParams, buildReferrerMetrics, buildScoredReferrerMetrics, buildUnrankedReferrerMetrics, calcReferrerAwardPoolShare, calcReferrerFinalScore, calcReferrerFinalScoreBoost, calcReferrerFinalScoreMultiplier, calcReferrerScore, compareReferrerMetrics, decodeEncodedReferrer, getReferrerDetail, getReferrerLeaderboardPage, isFiniteNonNegativeNumber, isInteger, isNonNegativeInteger, isPositiveInteger, isReferrerQualified, isValidDuration, isValidReferrerScore, isValidUSDQuantity, normalizeAddress, sortReferrerMetrics, validateAggregatedReferrerMetrics, validateAwardedReferrerMetrics, validateDuration, validateLowercaseAddress, validateNonNegativeInteger, validateRankedReferrerMetrics, validateReferralProgramRules, validateReferrerLeaderboardPageContext, validateReferrerMetrics, validateReferrerRank, validateReferrerScore, validateScoredReferrerMetrics, validateUSDQuantity, validateUnixTimestamp, validateUnrankedReferrerMetrics };