Class: Leaderboard
gSwap SDK 2.0.0-rc.4 / Leaderboard
Class: Leaderboard
Defined in: packages/gswap-sdk/dist/index.d.ts:2037
The swap backend's trading-competition reads: seasons (GET /leaderboard/seasons) and a
season's rankings (GET /leaderboard?seasonId=). Public reads: no signer, no wallet. A row that
is not usable is skipped and reported to onInvalidEntry; an answer that is not the expected
list is INVALID_CHAIN_RESPONSE.
Constructors
Constructor
new Leaderboard(
dexBackendBaseUrl,httpClient,options?):Leaderboard
Defined in: packages/gswap-sdk/dist/index.d.ts:2050
Creates a leaderboard service. options.onInvalidEntry is told about every season or entry
row that was skipped as unusable.
Parameters
dexBackendBaseUrl
string
httpClient
HttpClient
options?
onInvalidEntry?
Returns
Leaderboard
Example
const leaderboard = new Leaderboard('https://dex-backend-prod1.defi.gala.com', httpClient);
Methods
getCurrentLeaderboard()
getCurrentLeaderboard(
options?):Promise<SeasonLeaderboard|null>
Defined in: packages/gswap-sdk/dist/index.d.ts:2096
The rankings of the season running at options.now (see
Leaderboard.getCurrentSeason), or null between seasons.
Parameters
options?
Returns
Promise<SeasonLeaderboard | null>
Example
const current = await gSwap.leaderboard.getCurrentLeaderboard();
if (current !== null) console.log(current.seasonId, current.entries.length);
getCurrentSeason()
getCurrentSeason(
options?):Promise<LeaderboardSeason|null>
Defined in: packages/gswap-sdk/dist/index.d.ts:2073
The season running at options.now (default: now; start and end both count as inside),
or null between seasons. When seasons overlap, the first in the backend's order.
Parameters
options?
Returns
Promise<LeaderboardSeason | null>
Example
const season = await gSwap.leaderboard.getCurrentSeason();
console.log(season === null ? 'no season running' : season.name);
getLeaderboard()
getLeaderboard(
seasonId,options?):Promise<SeasonLeaderboard>
Defined in: packages/gswap-sdk/dist/index.d.ts:2085
A season's rankings (the backend's top 100 wallets). seasonId must be an integer of at
least 1 (INVALID_SEASON_ID before anything is sent); a season with no rankings, or none at
all, is an empty list.
Parameters
seasonId
number
options?
Returns
Promise<SeasonLeaderboard>
Example
const { entries } = await gSwap.leaderboard.getLeaderboard(1);
console.log(entries[0]?.wallet, entries[0]?.totalXp);
getSeasons()
getSeasons(
options?):Promise<LeaderboardSeason[]>
Defined in: packages/gswap-sdk/dist/index.d.ts:2062
Every active season, in the backend's order (newest first).
Parameters
options?
Returns
Promise<LeaderboardSeason[]>
Example
const seasons = await gSwap.leaderboard.getSeasons();
console.log(seasons.map((season) => season.name));