Skip to content

Commit

Permalink
feat: add pricing service interface
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnigir1 committed Jul 26, 2024
1 parent d5d61bc commit e503a93
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions libs/pricing/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./pricing.module";
export * from "./services/coingecko.service";
export * from "./interfaces";
1 change: 1 addition & 0 deletions libs/pricing/src/interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./pricing.interface";
19 changes: 19 additions & 0 deletions libs/pricing/src/interfaces/pricing.interface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Represents a pricing service that provides token prices.
*/
/**
* Represents a pricing service that retrieves token prices.
*/
export interface IPricingService {
/**
* Retrieves the prices of the specified tokens.
* @param tokenIds - An array of token IDs.
* @param [config] - Optional configuration object.
* @param config.currency - The currency in which the prices should be returned.
* @returns A promise that resolves to a record containing the token IDs as keys and their corresponding prices as values.
*/
getTokenPrices<TokenId extends string = string>(
tokenIds: TokenId[],
config?: { currency: string },
): Promise<Record<string, number>>;
}
10 changes: 9 additions & 1 deletion libs/pricing/src/services/coingecko.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { Injectable } from "@nestjs/common";
import { IPricingService } from "@packages/pricing/interfaces";

@Injectable()
export class CoingeckoService {
export class CoingeckoService implements IPricingService {
private readonly API_BASE_URL = "https://api.coingecko.com/api/v3/";
constructor(private readonly apiKey: string) {}

async getTokenPrices(
_tokenIds: string[],
_config: { currency: string } = { currency: "usd" },
): Promise<Record<string, number>> {
throw new Error("Method not implemented.");
}
}

0 comments on commit e503a93

Please sign in to comment.