Skip to content

Commit

Permalink
feat: revise queries for aggregate vs 2 different markets
Browse files Browse the repository at this point in the history
  • Loading branch information
R-K-H committed Aug 4, 2024
1 parent dc49a92 commit 8dcae79
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
44 changes: 44 additions & 0 deletions lib/client/indexer/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,50 @@ export class FutarchyIndexerMarketsClient implements FutarchyMarketsClient {
]
});
}
watchOrdersForMarkets(
passMarketAcct: PublicKey,
failMarketAcct: PublicKey,
page?: number,
pageSize?: number
): Observable<{ orders: Order[]; totalOrders: number }> {
const pageSizeValue = pageSize ?? 25;
const offset = ((page ?? 1) - 1) * pageSizeValue;
return this.watchOrdersForArgs({
where: {
market_acct: { _in: [passMarketAcct.toBase58(), failMarketAcct.toBase58()]}
},
order_by: [
{
order_time: "desc"
}
],
offset,
limit: pageSizeValue
});
}
watchUserOrdersForMarkets(
owner: PublicKey,
passMarketAcct: PublicKey,
failMarketAcct: PublicKey,
page?: number,
pageSize?: number
): Observable<{ orders: Order[]; totalOrders: number }> {
const pageSizeValue = pageSize ?? 25;
const offset = ((page ?? 1) - 1) * pageSizeValue;
return this.watchOrdersForArgs({
where: {
actor_acct: { _eq: owner.toBase58() },
market_acct: { _in: [passMarketAcct.toBase58(), failMarketAcct.toBase58()]}
},
order_by: [
{
order_time: "desc"
}
],
offset,
limit: pageSizeValue
});
}
watchOrdersForMarket(
marketAcct: PublicKey,
page?: number,
Expand Down
6 changes: 3 additions & 3 deletions lib/client/indexer/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ export class FutarchyIndexerProposalsClient implements FutarchyProposalsClient {

async fetchProposal(
proposalAcct: PublicKey
): Promise<ProposalWithFullData | null> {
): Promise<ProposalWithFullData | undefined> {
const { proposals } = await this.graphqlClient.query?.({
proposals: {
__args: {
Expand Down Expand Up @@ -468,7 +468,7 @@ export class FutarchyIndexerProposalsClient implements FutarchyProposalsClient {
}
}
});
if (!proposals[0]) return null;
if (!proposals[0]) return undefined;

const proposal = proposals[0];

Expand Down Expand Up @@ -510,7 +510,7 @@ export class FutarchyIndexerProposalsClient implements FutarchyProposalsClient {
curr.quote_price,
0
) ?? 0;
if (!relatedProtocol || !passMarket || !failMarket) return null;
if (!relatedProtocol || !passMarket || !failMarket) return undefined;
return {
account: {
baseVault: new PublicKey(proposal.base_vault ?? 5),
Expand Down

0 comments on commit 8dcae79

Please sign in to comment.