@cowprotocol/cow-sdk
Version:
<p align="center"> <img width="400" src="https://github.com/cowprotocol/cow-sdk/raw/main/docs/images/CoW.png" /> </p>
78 lines (77 loc) • 3.77 kB
TypeScript
import { Variables } from 'graphql-request';
import { DocumentNode } from 'graphql/index';
import { SupportedChainId } from '../common/chains';
import { ApiContext } from '../common/configs';
import { LastDaysVolumeQuery, LastHoursVolumeQuery, TotalsQuery } from './graphql';
type SubgraphApiBaseUrls = Record<SupportedChainId, string | null>;
interface SubgraphApiContext extends Omit<ApiContext, 'baseUrls'> {
baseUrls?: SubgraphApiBaseUrls;
}
type PartialSubgraphApiContext = Partial<SubgraphApiContext>;
/**
* CoW Protocol Production Subgraph API configuration.
* @see {@link https://api.thegraph.com/subgraphs/name/cowprotocol/cow}
* @see {@link https://api.thegraph.com/subgraphs/name/cowprotocol/cow-gc}
*/
export declare const SUBGRAPH_PROD_CONFIG: SubgraphApiBaseUrls;
/**
* CoW Protocol Staging Subgraph API configuration.
* @deprecated
* @see {@link https://api.thegraph.com/subgraphs/name/cowprotocol/cow-staging}
* @see {@link https://api.thegraph.com/subgraphs/name/cowprotocol/cow-gc-staging}
*/
export declare const SUBGRAPH_STAGING_CONFIG: SubgraphApiBaseUrls;
/**
* TheGraph API client for CoW Protocol.
*/
export declare class SubgraphApi {
API_NAME: string;
context: SubgraphApiContext;
/**
* Create a new CoW Protocol API instance.
* @param context Any properties of the {@link SubgraphApiContext} may be overridden by passing a {@link PartialSubgraphApiContext}.
*/
constructor(context?: PartialSubgraphApiContext);
/**
* Query the totals from TheGraph for the CoW Protocol.
* @param contextOverride Override the context for this call only.
* @returns The totals for the CoW Protocol.
*/
getTotals(contextOverride?: PartialSubgraphApiContext): Promise<TotalsQuery['totals'][0]>;
/**
* Query the volume over the last N days from TheGraph for the CoW Protocol.
* @param {number} days The number of days to query.
* @param {PartialSubgraphApiContext} contextOverride Override the context for this call only.
* @returns The volume for the last N days.
*/
getLastDaysVolume(days: number, contextOverride?: PartialSubgraphApiContext): Promise<LastDaysVolumeQuery>;
/**
* Query the volume over the last N hours from TheGraph for the CoW Protocol.
* @param {number} hours The number of hours to query.
* @param {PartialSubgraphApiContext} contextOverride Override the context for this call only.
* @returns The volume for the last N hours.
*/
getLastHoursVolume(hours: number, contextOverride?: PartialSubgraphApiContext): Promise<LastHoursVolumeQuery>;
/**
* Run a query against the CoW Protocol Subgraph.
* @param {string | DocumentNode} query GQL query string or DocumentNode.
* @param {Variables | undefined} variables To be passed to the query.
* @param {PartialSubgraphApiContext} contextOverride Override the context for this call only.
* @returns Results of the query.
* @throws {@link CowError} if the query fails.
*/
runQuery<T>(query: string | DocumentNode, variables?: Variables | undefined, contextOverride?: PartialSubgraphApiContext): Promise<T>;
/**
* Override parts of the context for a specific call.
* @param {PartialSubgraphApiContext} contextOverride Override the context for this call only.
* @returns {SubgraphApiContext} The context with the override applied.
*/
private getContextWithOverride;
/**
* Get the base URLs for the given environment.
* @param {CowEnv} env The environment to get the base URLs for.
* @returns {ApiBaseUrls} The base URLs for the given environment.
*/
private getEnvConfigs;
}
export {};