Orca DEX API
In this section, we'll show you how to access information about Orca DEX data using Bitquery APIs.
This Solana API is part of our Early Access Program (EAP).
You can use this program to try out the data and see how it works with your applications before you fully integrate it. You can learn more about this here.
Latest Pools created on Orca
To retrieve the newest pools created on Orca DEX, we will utilize the Solana instructions API/Websocket.
We will specifically look for the latest instructions from Orca's Whirlpool program, identified by the program ID whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc
.
Whenever a new pool is created on Orca, it triggers the initializePool
instructions. The pool address can be obtained from the program addresses listed in the transaction's instructions.
For instance, Index 1 and 2 represent the tokens involved in the pool, while Index 4 is for the pool's address. Note that the indexing starts from 0.
You can run this query using this link.
subscription {
Solana {
Instructions(
where: {
Instruction: {
Program: {
Method: { is: "initializePool" }
Address: { is: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc" }
}
}
}
) {
Instruction {
Program {
Method
Arguments {
Name
Value {
__typename
... on Solana_ABI_Integer_Value_Arg {
integer
}
... on Solana_ABI_String_Value_Arg {
string
}
... on Solana_ABI_Address_Value_Arg {
address
}
... on Solana_ABI_BigInt_Value_Arg {
bigInteger
}
... on Solana_ABI_Bytes_Value_Arg {
hex
}
... on Solana_ABI_Boolean_Value_Arg {
bool
}
... on Solana_ABI_Float_Value_Arg {
float
}
... on Solana_ABI_Json_Value_Arg {
json
}
}
}
}
Accounts {
Address
}
}
Transaction {
Signature
}
}
}
}
Pair Creation time for a specific pair
You can use the following query to get the pair creation time for a specific pair on Orca DEX on Solana. But you need to use keyword query
obviously.
You can run this query using this link.
{
Solana {
Instructions(
where: {Instruction: {Program: {Method: {is: "initializePool"}, Address: {is: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"}}, Accounts: {includes: {Address: {is: "Bg8rob51iTgMBi1hmRhZV8hzaHU5zP77Pd61UpbzyzGd"}}}}, Transaction: {Result: {Success: true}}}
) {
Transaction {
Signature
}
Block {
Time
}
}
}
}
Latest Trades on Orca DEX API Websocket
To access a real-time stream of trades for Solana Orca DEX, check out this GraphQL subscription (WebSocket).
subscription {
Solana {
DEXTrades(
where: {
Trade: {
Dex: {
ProgramAddress: {
is: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"
}
}
}
}
) {
Transaction {
Signature
}
Block {
Time
}
Trade {
Dex {
ProgramAddress
ProtocolName
ProtocolFamily
}
Buy {
Account {
Address
}
Amount
AmountInUSD
Currency {
MintAddress
Symbol
Name
}
Price
PriceInUSD
}
Sell {
Account {
Address
}
Amount
AmountInUSD
Currency {
MintAddress
Symbol
Name
}
Price
PriceInUSD
}
}
}
}
}
Latest Trades for a specific currency on Solana Orca DEX
If you want to monitor trades for a specific currency on Orca DEX, you can use the stream provided. Input the currency's mint address; for example, in the query below, we use the WSOL token's Mint address to fetch buys of the WSOL token.
By setting the limit to 1, you will receive the most recent trade, which reflects the latest price of the token.
Execute this query by following this link.
subscription {
Solana {
DEXTrades(
where: {
Trade: {
Dex: {
ProgramAddress: {
is: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"
}
}
Buy: {
Currency: {
MintAddress: { is: "So11111111111111111111111111111111111111112" }
}
}
}
}
) {
Transaction {
Signature
}
Block {
Time
}
Trade {
Dex {
ProgramAddress
ProtocolName
ProtocolFamily
}
Buy {
Account {
Address
}
Amount
AmountInUSD
Currency {
MintAddress
Symbol
Name
}
Price
PriceInUSD
}
Sell {
Account {
Address
}
Amount
AmountInUSD
Currency {
MintAddress
Symbol
Name
}
Price
PriceInUSD
}
}
}
}
}
Latest price of a token
You can use the following query to get the latest price of a token, we have used WSOL address here in the below example. We are getting realtime price of WSOL on Orca DEX on Solana in different pools.
You can run this query using this link.
Solana {
DEXTradeByTokens(
where: {Trade: {Currency: {MintAddress: {is: "So11111111111111111111111111111111111111112"}}, Dex: {ProgramAddress: {is: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"}}}}
) {
Block {
Time
}
Trade {
Amount
PriceAgainstSideCurrency: Price
Currency {
Symbol
Name
MintAddress
}
Side {
Amount
Currency {
Symbol
Name
MintAddress
}
}
Dex {
ProgramAddress
ProtocolFamily
ProtocolName
}
Market {
MarketAddress
}
Order {
LimitAmount
LimitPrice
OrderId
}
}
}
}
}
Orca OHLC APIs
If you want to get OHLC data for any specific currency pair on Orca DEX, you can use this api.
Only use this API as query
and not subscription
websocket as Aggregates and Time Intervals don't work well with subscriptions.
query {
Solana {
DEXTradeByTokens(
orderBy: { descendingByField: "Block_Timefield" }
where: {
Trade: {
Currency: {
MintAddress: { is: "6D7NaB2xsLd7cauWu1wKk6KBsJohJmP2qZH9GEfVi5Ui" }
}
Side: {
Currency: {
MintAddress: { is: "So11111111111111111111111111111111111111112" }
}
}
Dex: {
ProgramAddress: {
is: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc"
}
}
}
}
limit: { count: 10 }
) {
Block {
Timefield: Time(interval: { in: minutes, count: 1 })
}
volume: sum(of: Trade_Amount)
Trade {
high: Price(maximum: Trade_Price)
low: Price(minimum: Trade_Price)
open: Price(minimum: Block_Slot)
close: Price(maximum: Block_Slot)
}
count
}
}
}
Track Latest Add Liquidity Transactions on Orca DEX
You can also track Add Liquidity transactions in real time on Orca DEX from Orca API using instructions. Firstly, you can use this query to get all the methods of Orca program to deduce which program method is responsible for add liquidity transactions. The method we want to filter for turns out to be increaseLiquidity
.
If you want to track latest liquidity additions in Orca pools, you can use this Websocket api.
In the response, mint under 6th and 7th addresses in the Accounts array gives you the Token A and Token B respectively of the pool in which liquidity is added.
subscription {
Solana {
Instructions(
orderBy: { descending: Block_Time }
where: {
Instruction: {
Program: {
Address: { is: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc" }
Method: { is: "increaseLiquidity" }
}
}
}
) {
Block {
Time
}
Instruction {
Accounts {
Address
IsWritable
Token {
Mint
Owner
ProgramId
}
}
AncestorIndexes
InternalSeqNumber
Index
ExternalSeqNumber
Depth
CallerIndex
Data
CallPath
BalanceUpdatesCount
Logs
Program {
AccountNames
Address
Arguments {
Name
Type
Value {
... on Solana_ABI_Integer_Value_Arg {
integer
}
... on Solana_ABI_String_Value_Arg {
string
}
... on Solana_ABI_Address_Value_Arg {
address
}
... on Solana_ABI_BigInt_Value_Arg {
bigInteger
}
... on Solana_ABI_Bytes_Value_Arg {
hex
}
... on Solana_ABI_Boolean_Value_Arg {
bool
}
... on Solana_ABI_Float_Value_Arg {
float
}
... on Solana_ABI_Json_Value_Arg {
json
}
}
}
Name
Method
Parsed
}
}
Transaction {
Signature
}
}
}
}
Track Latest Remove Liquidity Transactions on Orca DEX
You can also track Remove Liquidity transactions in real time on Orca DEX from Orca API using instructions. Firstly, you can use this query to get all the methods of Orca program to deduce which program method is responsible for remove liquidity transactions. The method we want to filter for turns out to be decreaseLiquidity
.
If you want to track latest liquidity removals in Orca pools, you can use this Websocket api.
In the response, mint under 6th and 7th addresses in the Accounts array gives you the Token A and Token B respectively of the pool in which liquidity is removed.
subscription {
Solana {
Instructions(
orderBy: { descending: Block_Time }
where: {
Instruction: {
Program: {
Address: { is: "whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc" }
Method: { is: "decreaseLiquidity" }
}
}
}
) {
Block {
Time
}
Instruction {
Accounts {
Address
IsWritable
Token {
Mint
Owner
ProgramId
}
}
AncestorIndexes
InternalSeqNumber
Index
ExternalSeqNumber
Depth
CallerIndex
Data
CallPath
BalanceUpdatesCount
Logs
Program {
AccountNames
Address
Arguments {
Name
Type
Value {
... on Solana_ABI_Integer_Value_Arg {
integer
}
... on Solana_ABI_String_Value_Arg {
string
}
... on Solana_ABI_Address_Value_Arg {
address
}
... on Solana_ABI_BigInt_Value_Arg {
bigInteger
}
... on Solana_ABI_Bytes_Value_Arg {
hex
}
... on Solana_ABI_Boolean_Value_Arg {
bool
}
... on Solana_ABI_Float_Value_Arg {
float
}
... on Solana_ABI_Json_Value_Arg {
json
}
}
}
Name
Method
Parsed
}
}
Transaction {
Signature
}
}
}
}