Skip to content

Commit

Permalink
fix: some improvements for locked balances query (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasDeco authored Jun 17, 2024
1 parent e3855d8 commit fe6939e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
20 changes: 15 additions & 5 deletions lib/client/indexer/balances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,17 @@ export class FutarchyIndexerBalancesClient implements FutarchyBalancesClient {
): Promise<BalanceLockedInProposal[]> {
if (!ownerWallet) return [];
const vaultSubQuery = {
cond_vault_acct: true,
status: true,
token: {
image_url: true,
symbol: true
},
proposals: {
ended_at: true,
proposal_acct: true,
quote_vault: true,
base_vault: true,
proposal_details: {
title: true,
categories: true
Expand Down Expand Up @@ -162,10 +169,8 @@ export class FutarchyIndexerBalancesClient implements FutarchyBalancesClient {
amount: true,
token_acct: true,
token: {
symbol: true,
decimals: true,
name: true,
image_url: true,
mint_acct: true,
vault_by_finalize: vaultSubQuery,
vault_by_revert: vaultSubQuery
Expand All @@ -180,6 +185,10 @@ export class FutarchyIndexerBalancesClient implements FutarchyBalancesClient {
: t.token.vault_by_revert;
const proposal = relatedVault?.proposals[0];
const proposalDetail = proposal?.proposal_details[0];
const tokenType =
proposal?.base_vault === relatedVault?.cond_vault_acct
? "base"
: "quote";
const daoDetail = proposal?.dao.dao_detail;
if (!proposal) return;
const balanceInProposal: BalanceLockedInProposal = {
Expand All @@ -189,9 +198,10 @@ export class FutarchyIndexerBalancesClient implements FutarchyBalancesClient {
decimals: t.token.decimals,
name: t.token.name,
publicKey: t.token.mint_acct,
symbol: t.token.symbol,
url: t.token.image_url
}
symbol: relatedVault.token.symbol,
url: relatedVault.token.image_url
},
tokenType: tokenType
},
pda: new PublicKey(t.token_acct),
dao: {
Expand Down
2 changes: 1 addition & 1 deletion lib/types/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export type BalanceLockedInProposal = Pick<
"state" | "title" | "tags" | "publicKey" | "dao" | "endDate"
> & {
proposalNumber: number;
userBalance: TokenWithBalance;
userBalance: TokenWithBalance & { tokenType: "base" | "quote" };
market: ConditionalMarketType;
pda: PublicKey;
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metadaoproject/futarchy-sdk",
"version": "3.0.0-alpha.13",
"version": "3.0.0-alpha.14",
"main": "dist",
"scripts": {
"preinstall": "npx only-allow pnpm",
Expand Down

0 comments on commit fe6939e

Please sign in to comment.