Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adds liquidity watcher #182

Closed
wants to merge 7 commits into from
Closed
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
dist/
.vscode
.vscode
.DS_Store
9 changes: 8 additions & 1 deletion lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import {
ProposalAccounts,
ProgramVersionLabel,
ProposalWithFullData,
Dao
Dao,
TokenCache
} from "@/types";
import { SwapType } from "@metadaoproject/futarchy";
import { Observable } from "rxjs";
Expand Down Expand Up @@ -148,6 +149,8 @@ export interface FutarchyMarketsClient {
): Observable<{ orders: Order[]; totalOrders: number }>;
watchTwapPrices(marketKey: PublicKey): Observable<TwapObservation[]>;
watchSpotPrices(marketKey: PublicKey): Observable<SpotObservation[]>;
// watchCurrentSpotPrice(marketKey: PublicKey): Observable<SpotObservation[]>;
// watchConditionalSpotPrice(marketKey: PublicKey): Observable<SpotObservation[]>;
}

export interface FutarchyOrderbookMarketsClient<
Expand Down Expand Up @@ -220,3 +223,7 @@ export interface CreateProposal {
proposalDetails: ProposalDetails
): void;
}

export interface FutarchyTokenClient {
fetchFutarchyTokens(): Promise<TokenCache[] | undefined>;
}
6 changes: 6 additions & 0 deletions lib/client/indexer/indexerClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import { ClientOptions, createClient as createWsClient } from "graphql-ws";
import { FutarchyProtocol } from "@/types";
import { Observable } from "rxjs";
import { FutarchyIndexerUserClient } from "./user";
import { FutarchyIndexerTokenClient } from "./tokens";

export class FutarchyIndexerClient implements FutarchyClient {
public daos: FutarchyIndexerDaoClient;
public proposals: FutarchyIndexerProposalsClient;
public balances: FutarchyIndexerBalancesClient;
public markets: FutarchyIndexerMarketsClient;
public user: FutarchyIndexerUserClient;
public tokens: FutarchyIndexerTokenClient;
private protocolMap: Map<string, FutarchyProtocol>;
private wsClient;

Expand Down Expand Up @@ -75,6 +77,10 @@ export class FutarchyIndexerClient implements FutarchyClient {
graphqlClient,
this.protocolMap,
)
this.tokens = new FutarchyIndexerTokenClient(
rpcClient.daos,
graphqlClient
)
}

watchSlot() {
Expand Down
2 changes: 1 addition & 1 deletion lib/client/indexer/market-clients/ammMarkets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class FutarchyIndexerAmmMarketsClient
async fetchMarket(
request: AmmMarketFetchRequest
): Promise<AmmMarket | undefined> {
return this.rpcMarketsClient.fetchMarket(request);
return this.rpcMarketsClient.fetchMarket(request, false);
}

validateAddLiquidity(
Expand Down
Loading