Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
9437e87
feat: current cycle leaderboard updates
dnechay Apr 1, 2026
c94d1fa
chore: progress checking number overflow safety-belt
dnechay Apr 1, 2026
9868f1b
chore: total number in leaderboard
dnechay Apr 1, 2026
b0d0f7d
feat: cache prefinal results for leaderboard
dnechay Apr 1, 2026
872c5f4
chore: comment on competitive mm leaderboard
dnechay Apr 1, 2026
d971134
refactor: reward pool calc utils
dnechay Apr 1, 2026
17af2f5
refactor: move out reward related logic
dnechay Apr 2, 2026
34c0f94
feat: leaderboard estimated reward
dnechay Apr 2, 2026
ea6c237
chore: add deprecation comment
dnechay Apr 2, 2026
90f757e
feat: use same cycle duration for competitive mm
dnechay Apr 2, 2026
b5ed52f
feat: daily competitive rewards calculation
dnechay Apr 2, 2026
f2410f6
feat: estimate leaderboard rewards for competitive
dnechay Apr 2, 2026
9dd49be
test: estimate rewards
dnechay Apr 3, 2026
1f26c78
fix: min volume required condition
dnechay Apr 3, 2026
d405772
fix: typos
dnechay Apr 3, 2026
8f5b6c4
fix: reward pool edge case for to_cancel
dnechay Apr 3, 2026
aa0445a
fix: flaky test
dnechay Apr 3, 2026
3e8d110
refactor: comment placement
dnechay Apr 3, 2026
1c0b223
feat: rewardPool safety-belt
dnechay Apr 3, 2026
7dce88a
fix: typo in fixture
dnechay Apr 3, 2026
c19c915
fix: flaky test
dnechay Apr 3, 2026
8bd6600
fix: typo
dnechay Apr 3, 2026
3da2bf3
fix: competitive result file name
dnechay Apr 3, 2026
af9dcdd
fix: typo
dnechay Apr 3, 2026
b4d5345
refactor: rename relevance date prop
dnechay Apr 6, 2026
f5ea2ac
refactor: long to_cancel reward pool
dnechay Apr 6, 2026
f54cde7
fix: flaky test
dnechay Apr 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions recording-oracle/src/common/utils/http.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import * as crypto from 'crypto';
import { Readable } from 'stream';

import { faker } from '@faker-js/faker';
import nock from 'nock';

import { generateRandomHashString } from '~/test/fixtures/crypto';

import * as cryptoUtils from './crypto';
import * as httpUtils from './http';

describe('HTTP utilities', () => {
Expand Down Expand Up @@ -117,10 +117,7 @@ describe('HTTP utilities', () => {
it('should throw when downloaded file hash is not valid', async () => {
const fileUrl = faker.internet.url();
const fileContent = faker.string.sample();
const fileHash = crypto
.createHash('sha256')
.update(fileContent)
.digest('hex');
const fileHash = cryptoUtils.hashString(fileContent, 'sha256');

const scope = nock(fileUrl)
.get('/')
Expand All @@ -146,10 +143,7 @@ describe('HTTP utilities', () => {
it('should return file content when hash is valid', async () => {
const fileUrl = faker.internet.url();
const fileContent = faker.string.sample();
const fileHash = crypto
.createHash('sha1')
.update(fileContent)
.digest('hex');
const fileHash = cryptoUtils.hashString(fileContent, 'sha1');

const scope = nock(fileUrl)
.get('/')
Expand Down
2 changes: 1 addition & 1 deletion recording-oracle/src/common/utils/http.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as crypto from 'crypto';
import crypto from 'crypto';

import { type AxiosError } from 'axios';
import _ from 'lodash';
Expand Down
11 changes: 6 additions & 5 deletions recording-oracle/src/modules/campaigns/campaigns.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
ListJoinedCampaignsQueryDto,
ListJoinedCampaignsSuccessDto,
CampaignLeaderboardResponseDto,
GetLeaderboardQueryDto,
} from './campaigns.dto';
import { CampaignsControllerErrorsFilter } from './campaigns.error-filter';
import { CampaignNotFoundError } from './campaigns.errors';
Expand Down Expand Up @@ -252,14 +251,16 @@ export class CampaignsController {
@Get(`${SPECIFIC_CAMPAIGN_ROUTE}/leaderboard`)
async getCampaignLeaderboard(
@Param() { chainId, campaignAddress }: CampaignParamsDto,
@Query() { rankBy }: GetLeaderboardQueryDto,
): Promise<CampaignLeaderboardResponseDto> {
const data = await this.campaignsService.getCampaignLeaderboard(
const leaderboardData = await this.campaignsService.getCampaignLeaderboard(
chainId,
campaignAddress,
rankBy,
);

return { data };
return {
data: leaderboardData.entries,
total: leaderboardData.total,
updatedAt: leaderboardData.updatedAt.toISOString(),
};
}
}
33 changes: 19 additions & 14 deletions recording-oracle/src/modules/campaigns/campaigns.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
CampaignType,
CampaignJoinStatus,
ReturnedCampaignStatus,
LeaderboardRanking,
} from './types';

export class JoinCampaignDto {
Expand Down Expand Up @@ -265,28 +264,26 @@ export class GetUserProgressResponseDto {
totalMeta: object;
}

export class GetLeaderboardQueryDto {
@ApiProperty({
name: 'rank_by',
enum: LeaderboardRanking,
})
@IsEnum(LeaderboardRanking)
rankBy: LeaderboardRanking;
}

export class LeaderboardEntry {
@ApiProperty()
address: string;

@ApiProperty()
score: number;

@ApiProperty({
description: `
This field represents different value based on chosen ranking mode and can be:
- total rewards earned by participant
- current score on market making campaign
- current amount of held tokens
This field represents different value based on the campaign type and can be:
- generated volume for "market making" campaigns
- balance / held tokens for "holding" and "threshold" campaigns
`,
})
result: number;

@ApiProperty({
name: 'estimated_reward',
})
estimatedReward: number;
}

export class CampaignLeaderboardResponseDto {
Expand All @@ -295,4 +292,12 @@ export class CampaignLeaderboardResponseDto {
isArray: true,
})
data: LeaderboardEntry[];

@ApiProperty()
total: number;

@ApiProperty({
name: 'updated_at',
})
updatedAt: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import dayjs from 'dayjs';
import { DataSource, In, LessThanOrEqual, MoreThan, Repository } from 'typeorm';

import { CampaignEntity } from './campaign.entity';
import { PROGRESS_PERIOD_DAYS } from './constants';
import { CAMPAIGNS_DAILY_CYCLE } from './constants';
import { CampaignStatus } from './types';

@Injectable()
Expand All @@ -29,7 +29,7 @@ export class CampaignsRepository extends Repository<CampaignEntity> {

async findForProgressRecording(): Promise<CampaignEntity[]> {
const now = new Date();
const timeAgo = dayjs().subtract(PROGRESS_PERIOD_DAYS, 'day').toDate();
const timeAgo = dayjs().subtract(CAMPAIGNS_DAILY_CYCLE, 'day').toDate();

const results = await this.createQueryBuilder('campaign')
.where(
Expand Down
Loading