GetOpenPositions CP_latest

Returns 20 DEX pools and DEX trades by token on Solana, where base currency mint address is 2zucbz…pump, transaction signer is 4GZQma…NLBN and account owner is 4GZQma…NLBN, sorted by transfer amount in USD, highest first: market address, base currency symbol, base currency name, base currency mint address, quote currency symbol, quote currency name, quote currency mint address and 25 more fields.

By Chandra Pratap SIngh · saved 11 May 2025 · Bitquery API v2

What it returns

Filters

The query

query GetOpenPositions($tokenMint: String!, $sinceTime: DateTime!) {
  Solana(network: solana) {
    # Get active liquidity positions in pools
    liquidityPositions: DEXPools(
      limit: {count: 50}
      orderBy: {descending: Pool_Base_PostAmountInUSD}
      where: {
        Pool: {
          Market: {
            BaseCurrency: {MintAddress: {is: $tokenMint}}
          }
        },
        Transaction: {Signer: {is: "4GZQmaNuR5mYcYKUxYwQ4fTYx4v8rWfEjfWGpNGkNLBN"},Result: {Success: true}}
      }
    ) {
      Pool {
        Market {
          MarketAddress
          BaseCurrency {
            Symbol
            Name
            MintAddress
          }
          QuoteCurrency {
            Symbol
            Name
            MintAddress
          }
        }
        Dex {
          ProtocolName
          ProgramAddress
        }
        
        
        # Liquidity position size
        Base {
          PostAmount
          PostAmountInUSD
         
        }
        Quote {
          PostAmount
          PostAmountInUSD
        }
        # LP Provider address
       
        # Time opened
        
        
      }
      Transaction{
        Signer
      }
      Block{
        Time
      }
    }
    
    # Get open margin/leveraged positions (if supported)
    marginPositions: DEXTradeByTokens(
      limit: {count: 30}
      orderBy: {descending: Block_Time}
      where: {
        Block: {Time: {since: $sinceTime}},
        Trade: {
          Account: {Owner: {is: "4GZQmaNuR5mYcYKUxYwQ4fTYx4v8rWfEjfWGpNGkNLBN"}},
          Currency: {MintAddress: {is: $tokenMint}},
          # Add specific program addresses for margin trading if known
          Dex: {}
        }
      }
    ) {
      Transaction {
        Signature
      }
      Trade {
        Side {
          Type  # buy or sell
          Account {
            Address
            Owner
          }
          Amount
          AmountInUSD
        }
        # Position details
        Price
        PriceInUSD
        Dex {
          ProtocolName
          ProgramAddress
        }
      }
      # Timestamp
      Block {
        Time
      }
      # This may help identify position types
      Instruction {
        Program {
          Name
          Method
        }
      }
    }
    
    # Get perpetual positions (only works with specific protocols)
    perpetualPositions: DEXTradeByTokens(
      limit: {count: 20}
      orderBy: {descending: Block_Time}
      where: {
        Trade: {
          Account: {Owner: {is: "4GZQmaNuR5mYcYKUxYwQ4fTYx4v8rWfEjfWGpNGkNLBN"}},
          Currency: {MintAddress: {is: $tokenMint}},
          # Filter for known perpetual DEXs or contracts
          Dex: {}
        },
        # Filter for position-related methods if known
        Instruction: {
          Program: {
            Method: {in: ["openPosition", "trade", "margin", "leverage"]}
          }
        }
      }
    ) {
      Transaction {
        Signature
      }
      Trade {
        # Position details
        Currency {
          Symbol
          Name
        }
        Side {
          Type
          Account {
            Address
          }
          Amount
          AmountInUSD
        }
        Price
        PriceInUSD
      }
      # Position metadata via instruction data
      Instruction {
        Program {
          Name
          Method
        }
        
      }
      
    }
    
    # Get significant token holders (may represent positions)
    majorHolders: Transfers(
      limit: {count: 20}
      orderBy: {descending: Transfer_AmountInUSD}
      where: {
        Transfer: {
          Currency: {MintAddress: {is: $tokenMint}}
        },
        Transaction: {Signer: {is: "4GZQmaNuR5mYcYKUxYwQ4fTYx4v8rWfEjfWGpNGkNLBN"},Result: {Success: true}}
      }
    ) {
      Transfer {
        Sender {
          Address
        }
        Receiver {
          Address
        }
        Currency {
          Symbol
          MintAddress
        }
        Amount
        AmountInUSD
      }
      Block {
        Time
      }
    }
  }
}

Variables

{
  "tokenMint": "2zucbzn42wA6GQiH1myPbgJ8bbkXb5ti4ikKSAhHpump",
  "sinceTime": "2025-04-19T00:00:00Z"
}

Similar queries