-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./pricing.interface"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} |