index/classes/WeeklyChallengeService.md
Weekly Challenge Service Class
Provides methods for accessing the weekly challenge leaderboard:
- Get current week's leaderboard (tokens ranked by market cap increase)
- Get historical weekly snapshots for a specific token
Challenge Rules:
- Week runs Saturday to Friday
- Baseline is Saturday's snapshot
- Ranking is by market cap increase (current - baseline)
- Tokens with no baseline data (new this week) use previous week's latest snapshot
Public endpoint - no authentication required.
Example
const wcService = new WeeklyChallengeService(httpClient, true);
// Get top 10 tokens in weekly challenge
const { leaderboard } = await wcService.getLeaderboard({ limit: 10 });
console.log(`Week: ${leaderboard.weekStart} to ${leaderboard.weekEnd}`);
for (const token of leaderboard.tokens) {
console.log(`#${token.rank} ${token.tokenName}: +${token.marketCapIncreaseGala} GALA`);
}
// Get historical data for a specific token
const { snapshots } = await wcService.getTokenHistory({
vaultAddress: 'eth|123...'
});
for (const snap of snapshots) {
console.log(`${snap.snapshotDate}: ${snap.marketCapGala} GALA`);
}
Extends
BaseService
base service
Constructors
Constructor
new WeeklyChallengeService(
http,debugMode?):WeeklyChallengeService
Parameters
| Parameter | Type |
|---|---|
http | HttpClient |
debugMode? | boolean |
Returns
WeeklyChallengeService
Overrides
BaseService.constructor
debug mode weekly challenge service http client base
Methods
getLeaderboard()
getLeaderboard(
options?):Promise<GetWeeklyChallengeResult>
Get weekly challenge leaderboard
Returns tokens ranked by market cap increase for the current week. Week runs Saturday to Friday.
Parameters
| Parameter | Type | Description |
|---|---|---|
options? | GetWeeklyChallengeOptions | Optional parameters |
Returns
Promise<GetWeeklyChallengeResult>
Leaderboard with ranked tokens
Example
// Get top 20 tokens
const { leaderboard } = await wcService.getLeaderboard({ limit: 20 });
// Display results
console.log(`Challenge week: ${leaderboard.weekStart} - ${leaderboard.weekEnd}`);
console.log(`Snapshot: ${leaderboard.snapshotDate}`);
console.log(`Total tokens: ${leaderboard.count}`);
for (const token of leaderboard.tokens) {
const increase = token.marketCapIncreaseGala.toLocaleString();
console.log(`${token.rank}. ${token.symbol} (+${increase} GALA)`);
}
get leaderboard weekly challenge result options
getTokenHistory()
getTokenHistory(
options):Promise<GetTokenWeeklyHistoryResult>
Get token weekly history
Returns the last 4 weeks of snapshot data for a specific token. Useful for tracking a token's performance over time.
Parameters
| Parameter | Type | Description |
|---|---|---|
options | GetTokenWeeklyHistoryOptions | Options with vault address |
Returns
Promise<GetTokenWeeklyHistoryResult>
Array of weekly snapshots
Example
const { snapshots } = await wcService.getTokenHistory({
vaultAddress: 'eth|abc123...'
});
// Show weekly performance
for (const snap of snapshots) {
const date = new Date(snap.snapshotDate).toLocaleDateString();
console.log(`${date}: $${snap.marketCapUsd} (${snap.marketCapGala} GALA)`);
}
// Calculate week-over-week change
if (snapshots.length >= 2) {
const current = parseFloat(snapshots[0].marketCapGala);
const previous = parseFloat(snapshots[1].marketCapGala);
const change = ((current - previous) / previous * 100).toFixed(2);
console.log(`Week-over-week change: ${change}%`);
}
get token history weekly result options
setJwtAuth()
setJwtAuth(
jwtAuth):void
Set the JWT authentication manager. Allows dynamic configuration of JWT auth after service creation.
Parameters
| Parameter | Type | Description |
|---|---|---|
jwtAuth | JwtAuth | JWT auth manager instance |
Returns
void
Inherited from
BaseService.setJwtAuth
set jwt auth base service