Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions apps/ftso-data-provider/src/dto/data-provider-responses.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// PDP (Protocol Data Provider) Response

import { RewardEpoch } from "../../../../libs/ftso-core/src/RewardEpoch";
import { AbiDataInput } from "../../../../libs/ftso-core/src/utils/ABICache";
import { FeedResultWithProof, TreeResult } from "../../../../libs/ftso-core/src/utils/MerkleTreeStructs";
import { MedianCalculationResult } from "../../../../libs/ftso-core/src/voting-types";
Expand Down Expand Up @@ -60,6 +61,25 @@ export type ExternalMedianResponse =
| ExternalMedianResponseNotAvailable
| ExternalMedianResponseTooEarly;

interface ExternalRewardEpochResponseOk {
status: ExternalResponseStatusEnum.OK;
rewardEpochId: number;
rewardEpochFeedConfiguration: RewardEpoch;
}

interface ExternalRewardEpochResponseNotAvailable {
status: ExternalResponseStatusEnum.NOT_AVAILABLE;
}

interface ExternalRewardEpochResponseTooEarly {
status: ExternalResponseStatusEnum.TOO_EARLY;
}

export type ExternalRewardEpochResponse =
| ExternalRewardEpochResponseOk
| ExternalRewardEpochResponseNotAvailable
| ExternalRewardEpochResponseTooEarly;

export interface JSONAbiDefinition {
abiName: string;
data: AbiDataInput;
Expand Down
15 changes: 15 additions & 0 deletions apps/ftso-data-provider/src/ftso-data-provider.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
ExternalMedianResponse,
ExternalResponse,
ExternalResponseStatusEnum,
ExternalRewardEpochResponse,
PDPResponse,
PDPResponseStatusEnum,
} from "./dto/data-provider-responses.dto";
Expand Down Expand Up @@ -177,6 +178,20 @@ export class FtsoDataProviderController implements BeforeApplicationShutdown {
};
}

@ApiTags(ApiTagsEnum.EXTERNAL)
@Get("rewardEpochFeedConfiguration/:votingRoundId")
async rewardEpochConfiguration(
@Param("votingRoundId", ParseIntPipe) votingRoundId: number
): Promise<ExternalRewardEpochResponse> {
const data = await this.ftsoDataProviderService.getRewardEpoch(votingRoundId);

return {
status: data ? ExternalResponseStatusEnum.OK : ExternalResponseStatusEnum.NOT_AVAILABLE,
rewardEpochId: data.rewardEpochId,
rewardEpochFeedConfiguration: data,
};
}

async beforeApplicationShutdown() {
this.shutdownInitiated = true;
this.logger.log(`Shutdown initiated, voting round commits disabled.`);
Expand Down
6 changes: 6 additions & 0 deletions apps/ftso-data-provider/src/ftso-data-provider.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,12 @@ export class FtsoDataProviderService {
];
}

async getRewardEpoch(votingRoundId: number): Promise<RewardEpoch> {
const rewardEpoch = await this.rewardEpochManager.getRewardEpochForVotingEpochId(votingRoundId);

return rewardEpoch;
}

// Internal methods

private async getFeedValuesForEpoch(votingRoundId: number, supportedFeeds: Feed[]): Promise<IRevealData> {
Expand Down