@covalenthq/client-sdk 2.2.5 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { type Execution } from "../utils/functions/execution";
2
- import { type Chain, type GoldRushResponse, type Quote } from "../utils/types/Generic.types";
3
- import { type GetTokenPricesQueryParamOpts, type TokenPricesResponse } from "../utils/types/PricingService.types";
2
+ import type { Chain, GoldRushResponse, Quote } from "../utils/types/Generic.types";
3
+ import type { GetTokenPricesQueryParamOpts, PoolSpotPriceQueryParamsOpts, PoolSpotPricesResponse, TokenPricesResponse } from "../utils/types/PricingService.types";
4
4
  /**
5
5
  * Pricing API
6
6
  *
@@ -22,4 +22,15 @@ export declare class PricingService {
22
22
  *
23
23
  */
24
24
  getTokenPrices(chainName: Chain, quoteCurrency: Quote, contractAddress: string, queryParamOpts?: GetTokenPricesQueryParamOpts): Promise<GoldRushResponse<TokenPricesResponse[]>>;
25
+ /**
26
+ *
27
+ * Get the spot token pair prices for a specified pool contract address. Supports pools on Uniswap V2, V3 and their forks.
28
+ *
29
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
30
+ * @param {string} contractAddress - The pool contract address.
31
+ * @param {GetTokenPricesQueryParamOpts} queryParamOpts
32
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, `GBP`, `BTC` and `ETH`.
33
+ *
34
+ */
35
+ getPoolSpotPrices(chainName: Chain, contractAddress: string, queryParamOpts?: PoolSpotPriceQueryParamsOpts): Promise<GoldRushResponse<PoolSpotPricesResponse[]>>;
25
36
  }
@@ -38,3 +38,43 @@ export type GetTokenPricesQueryParamOpts = Nullable<{
38
38
  /** * Sort the prices in chronological ascending order. By default, it's set to `false` and returns prices in chronological descending order. */
39
39
  pricesAtAsc?: boolean;
40
40
  }>;
41
+ export type PoolSpotPriceQueryParamsOpts = Nullable<{
42
+ /** * The currency to convert. */
43
+ quoteCurrency: string;
44
+ }>;
45
+ export type PoolSpotPricesResponse = Nullable<{
46
+ /** * The timestamp when the response was generated. */
47
+ updated_at: Date;
48
+ /** * The pool contract address. */
49
+ pool_address: string;
50
+ /** * The contract address of token_0 in the token pair making up the pool. */
51
+ token_0_address: string;
52
+ /** * The contract name of token_0 in the token pair making up the pool. */
53
+ token_0_name: string;
54
+ /** * The contract symbol of token_0 in the token pair making up the pool. */
55
+ token_0_ticker: string;
56
+ /** * Price of token_0 in units of token_1. */
57
+ token_0_price: string;
58
+ /** * Price of token_0 in units of token_1 as of 24 hours ago. */
59
+ token_0_price_24h: string;
60
+ /** * Price of token_0 in the selected quote currency (defaults to USD). */
61
+ token_0_price_quote: string;
62
+ /** * Price of token_0 in the selected quote currency (defaults to USD) as of 24 hours ago. */
63
+ token_0_price_24h_quote: string;
64
+ /** * The contract address of token_1 in the token pair making up the pool. */
65
+ token_1_address: string;
66
+ /** * The contract name of token_1 in the token pair making up the pool. */
67
+ token_1_name: string;
68
+ /** * The contract symbol of token_1 in the token pair making up the pool. */
69
+ token_1_ticker: string;
70
+ /** * Price of token_1 in units of token_0. */
71
+ token_1_price: string;
72
+ /** * Price of token_1 in units of token_0 as of 24 hours ago. */
73
+ token_1_price_24h: string;
74
+ /** * Price of token_1 in the selected quote currency (defaults to USD). */
75
+ token_1_price_quote: string;
76
+ /** * Price of token_1 in the selected quote currency (defaults to USD) as of 24 hours ago. */
77
+ token_1_price_24h_quote: string;
78
+ /** * The currency to convert. */
79
+ quote_currency: string;
80
+ }>;
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var version = "2.2.5";
1
+ var version = "2.2.6";
2
2
 
3
3
  const bigIntParser = (val) => {
4
4
  if (val === null || val === undefined) {
@@ -2302,6 +2302,35 @@ class PricingService {
2302
2302
  };
2303
2303
  return await this.execution.execute(endpoint, parseData);
2304
2304
  }
2305
+ /**
2306
+ *
2307
+ * Get the spot token pair prices for a specified pool contract address. Supports pools on Uniswap V2, V3 and their forks.
2308
+ *
2309
+ * @param {Chain} chainName - The chain name eg: `eth-mainnet` or 1.
2310
+ * @param {string} contractAddress - The pool contract address.
2311
+ * @param {GetTokenPricesQueryParamOpts} queryParamOpts
2312
+ * - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, `GBP`, `BTC` and `ETH`.
2313
+ *
2314
+ */
2315
+ async getPoolSpotPrices(chainName, contractAddress, queryParamOpts) {
2316
+ const endpoint = endpointGenerator(`pricing/spot_prices/${chainName}/pools/${contractAddress}`, [
2317
+ {
2318
+ key: "quote-currency",
2319
+ value: queryParamOpts?.quoteCurrency,
2320
+ },
2321
+ ]);
2322
+ const parseData = (data) => {
2323
+ if (data.data) {
2324
+ data.data.forEach((dataItem) => {
2325
+ dataItem.updated_at = dataItem.updated_at
2326
+ ? new Date(dataItem.updated_at)
2327
+ : null;
2328
+ });
2329
+ }
2330
+ return data;
2331
+ };
2332
+ return await this.execution.execute(endpoint, parseData);
2333
+ }
2305
2334
  }
2306
2335
 
2307
2336
  /**