Skip to main content

Sun Pump API

In this section, we will explore several examples related to Sun Pump data. These APIs can be provided through different streams including Kafka for zero latency requirements. Please contact us on telegram.

Latest Created Sunpump token​

This query will subscribe you to the latest created sun pump tokens. You will find the newly created token address in Log { SmartContract }.

Here’s the query to retrieve the latest tokens created on Sun Pump.

If you remove subscription from the below GraphQL query it will become API, for example check this api.

subscription MyQuery {
Tron {
Events(
where: {
Transaction: { Result: { Success: true } }
Topics: {
includes: {
Hash: {
in: [
"8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0"
]
}
}
}
}
) {
Log {
SmartContract
}
Contract {
Address
}
Transaction {
Hash
FeePayer
}
}
}
}

Latest Trades on Sunpump Tron​

To subscribe to latest Sunpump trades you can use the following stream.

subscription {
Tron {
DEXTrades(where: {Trade: {Dex: {ProtocolName: {is: "sun_pump_v1"}}}}) {
Transaction {
Hash
}
Trade {
Buy {
Amount
AmountInUSD
Buyer
Seller
Amount
AmountInUSD
Currency {
SmartContract
Symbol
Name
}
}
Sell {
Amount
AmountInUSD
Buyer
Seller
Amount
AmountInUSD
Currency {
SmartContract
Symbol
Name
}
}
}
}
}
}

Get all Pairs in Virtual Liquidity Pool​

Sun Pump does not use a dedicated pool for each pair; instead, all liquidity is managed within a single contract. You can query the virtual liquidity pools directly by running the following query

query SunPumpTokenPools {
Tron {
DexPools: BalanceUpdates(
where: {BalanceUpdate: {Address: {is: "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw}}}
) {
totalLiquidity: sum(of: BalanceUpdate_Amount)
Currency {
SmartContract
Name
Symbol
Decimals
}
}
}
}

Find the query here

Sunpump Trades in Mempool​

We simulate transactions in mempool, therefore you can also get trades directly from mempool using following stream.

subscription {
Tron (mempool:true) {
DEXTrades(where: {Trade: {Dex: {ProtocolName: {is: "sun_pump_v1"}}}}) {
Transaction {
Hash
}
Trade {
Buy {
Amount
AmountInUSD
Buyer
Seller
Amount
AmountInUSD
Currency {
SmartContract
Symbol
Name
}
}
Sell {
Amount
AmountInUSD
Buyer
Seller
Amount
AmountInUSD
Currency {
SmartContract
Symbol
Name
}
}
}
}
}
}

OHLC data for specific token on SunPump​

You can also get ohlc data for specific token using DEXTradeByTokens API. Here is an example.

query TokenOHLC($token: String) {
Tron {
DEXTradeByTokens(
orderBy: {ascendingByField: "Block_Time"}
where: {Trade: {Amount: {gt: "0"}, Currency: {SmartContract: {is: $token}}}, Transaction: {Result: {Success: true}}}
) {
Block {
Time(interval: {count: 5, in: minutes})
allTime: Time
}
Trade {
Buyer
Seller
Dex {
SmartContract
ProtocolName
ProtocolFamily
}
Currency {
Symbol
Name
SmartContract
}
Price
Amount
Side {
AmountInUSD
Amount
}
open: Price(minimum: Block_Number)
close: Price(maximum: Block_Number)
min: Price(maximum: Trade_Price)
max: Price(minimum: Trade_Price)
closeUsd: PriceInUSD(maximum: Trade_PriceInUSD)
}
volume: sum(of: Trade_Side_Amount)
volumeUsd: sum(of: Trade_Side_AmountInUSD)
}
}
}
{
"token": "TMaQT6QWTaTxuorH7Aa898Gmt7ibJKc6Ti"
}

image

You can check the data here on DEXrabbit.

Latest Trades for specific token on SunPump​

You can also get trades for specific token using DEXTradeByTokens API. Here is an example.

To learn the difference between DEXTrades and DEXTradeByTokens API, read this and this doc.

query SunPumpTokenLatestTrades($token: String) {
Tron {
DEXTradeByTokens(
orderBy: {descending: Block_Time}
limit: {count: 50}
where: {Trade: {Currency: {SmartContract: {is: $token}}, Price: {gt: 0}}, Transaction: {Result: {Success: true}}}
) {
Block {
allTime: Time
}
Trade {
Seller
Buyer
Price
Amount
AmountInUSD
Currency {
Name
Symbol
SmartContract
}
Side {
Type
Currency {
Name
Symbol
SmartContract
}
AmountInUSD
Amount
}
}
}
}
}
{
"token": "TQFZb7S1gb5D2u7HqmKJRNZXoTjVe428sh"
}

image

You can check the data here on DEXrabbit.

note

Getting SunPump data using transactions API instead of Trades as shown in following examples.

Latest Buy events on SunPump Tron​

You can use following stream to get latest buys on Sunpump. You can try this stream on IDE.

subscription {
Tron(mempool: false) {
BuyEvents: Events(
where: {
Transaction: {
Data: { includes: "1cc2c911" }
Result: { Success: true }
}
Contract: { Address: { is: "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw" } }
}
) {
Log {
SmartContract
Signature {
Name
SignatureHash
}
}
Contract {
Address
}
Transaction {
Hash
Timestamp
Index
FeePayer
}
LogHeader {
Data
}
Block {
Number
}
Topics {
Hash
}
}
}
}

Sunpump Bonding Curve using TRX Balance​

TRX balance in bonding curve based on dex trades. Calculated as balance = in_sum - out_sum

Try this query.

{
Tron {
in: DEXTrades(
where: {Trade: {Dex: {SmartContract: {is: "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw"}}, Buy: {Currency: {SmartContract: {is: "TWnCdRpXc7RUPiM24T744rkux1t5VZt7TH"}}}}}
) {
sum(of: Trade_Sell_Amount)
}
out: DEXTrades(
where: {Trade: {Dex: {SmartContract: {is: "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw"}}, Sell: {Currency: {SmartContract: {is: "TWnCdRpXc7RUPiM24T744rkux1t5VZt7TH"}}}}}
) {
sum(of: Trade_Buy_Amount)
}
}
}

Historical TRX balance in bonding curve based on DEX trades.

Calculated as balance = in_sum - out_sum

Use following query.

{
Tron {
in: DEXTrades(
where: {Trade: {Dex: {SmartContract: {is: "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw"}}, Buy: {Currency: {SmartContract: {is: "TWnCdRpXc7RUPiM24T744rkux1t5VZt7TH"}}}}}
) {
Block {
Time(interval: {count: 5, in: minutes})
allTime: Time
}
sum(of: Trade_Sell_Amount)
}
out: DEXTrades(
where: {Trade: {Dex: {SmartContract: {is: "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw"}}, Sell: {Currency: {SmartContract: {is: "TWnCdRpXc7RUPiM24T744rkux1t5VZt7TH"}}}}}
) {
Block {
Time(interval: {count: 5, in: minutes})
allTime: Time
}
sum(of: Trade_Buy_Amount)
}
}
}

Latest Sell events on SunPump Tron​

You can use following stream to get latest sells on Sunpump. You can try this stream on IDE.

subscription {
Tron(mempool: false) {
SellEvents: Events(
where: {
Transaction: {
Data: { includes: "d19aa2b9" }
Result: { Success: true }
}
Contract: { Address: { is: "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw" } }
}
) {
Log {
SmartContract
Signature {
Name
SignatureHash
}
}
Contract {
Address
}
Transaction {
Hash
Timestamp
Index
FeePayer
}
LogHeader {
Data
}
Block {
Number
}
Topics {
Hash
}
}
}
}

First Time Buy Event on Sunpump​

You can use follow stream to get stream of first time buy event for any new token.

You can try this stream on IDE.

subscription {
Tron(mempool: false) {
BuyEventsFirstTime: Events(
where: {
Transaction: {
Data: { includes: "2f70d762" }
Result: { Success: true }
}
Contract: { Address: { is: "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw" } }
}
) {
Log {
SmartContract
Signature {
Name
SignatureHash
}
}
Contract {
Address
}
Transaction {
Hash
Timestamp
Index
FeePayer
}
LogHeader {
Data
}
Block {
Number
}
Topics {
Hash
}
}
}
}

Tron DEX Trade API​

Currently Tron DEX trade API doesn't have Sunpump for now, but it has other DEXs including Sunswap and we are in process of adding Sunpump in DEX trades api.

You can try this API on our IDE.

subscription {
Tron(mempool: false) {
DEXTrades(where: {Transaction: {Result: {Success: true}}}) {
Trade {
Dex {
ProtocolName
SmartContract
OwnerAddress
Pair {
Name
SmartContract
}
}
Buy {
Currency {
AssetId
SmartContract
Symbol
Fungible
}
Amount
Buyer
Seller
Price
Ids
OrderId
}
Sell {
Currency {
AssetId
SmartContract
Symbol
Fungible
}
Price
Amount
}
Success
}
Transaction {
Hash
Index
Result {
Success
}
Timestamp
}
Block {
Number
}
}
}
}

Track Token Launch to Sunswap​

This query allows you to track when tokens are launched on SunSwap using the launchToDEX function. It returns the most recent 10 token launches, displaying details such as the token address, transaction hash, block timestamp, and the method call signature.

Arguments: Includes the token address and any other relevant parameters passed during the launchToDEX method call. You can use the token argument to get the address of the token that was launched. You can run the query here

query MyQuery {
Tron(network: tron, dataset: realtime) {
Calls(
where: {Call: {To: {is: "TTfvyrAz86hbZk5iDpKD78pqLGgi8C7AAw"}, Signature: {Name: {is: "launchToDEX"}}}}
limit: {count: 10}
orderBy: {descending: Block_Time}
) {
Call {
Signature {
Name
}
}
Arguments {
Value {
... on EVM_ABI_Boolean_Value_Arg {
bool
}
... on EVM_ABI_Bytes_Value_Arg {
hex
}
... on EVM_ABI_BigInt_Value_Arg {
bigInteger
}
... on EVM_ABI_Address_Value_Arg {
address
}
... on EVM_ABI_String_Value_Arg {
string
}
... on EVM_ABI_Integer_Value_Arg {
integer
}
}
Name
}
Transaction {
Hash
}
Block {
Time
}
}
}
}

Track Token Purchase Events on Sunpump​

This query allows you to track TokenPurchased events on SunPump. It retrieves the 10 most recent token purchase events, showing important details such as the token address, buyer information, transaction hash, and token amount involved. The arguments has key event parameters like the token address, buyer, transaction amount, fees, and token reserve values.

You can run the query here

{
Tron {
Events(
where: {Log: {Signature: {Name: {is: "TokenPurchased"}}}}
limit: {count: 10}
) {
Log {
Signature {
Name
SignatureHash
}
}
Transaction {
Hash
Timestamp
}
Topics {
Hash
}
Arguments {
Name
Value {
... on EVM_ABI_Integer_Value_Arg {
integer
}
... on EVM_ABI_String_Value_Arg {
string
}
... on EVM_ABI_Boolean_Value_Arg {
bool
}
... on EVM_ABI_Bytes_Value_Arg {
hex
}
... on EVM_ABI_BigInt_Value_Arg {
bigInteger
}
... on EVM_ABI_Address_Value_Arg {
address
}
}
}
Call {
From
To
}
}
}
}

Track Token Creation on Sunpump in Realtime​

This subscription allows you to track new tokens being created on SunPump in real time. It captures the latest TokenCreate events, providing important details such as the token address, creator, and transaction information.

The Arguments include the token address, creator, and token index. You can run it here

subscription{
Tron {
Events(
where: {Log: {Signature: {Name: {is: "TokenCreate"}}}}

) {
Log {
Signature {
Name
SignatureHash
}
}
Transaction {
Hash
Timestamp
}
Topics {
Hash
}
Arguments {
Name
Value {
... on EVM_ABI_Integer_Value_Arg {
integer
}
... on EVM_ABI_String_Value_Arg {
string
}
... on EVM_ABI_Boolean_Value_Arg {
bool
}
... on EVM_ABI_Bytes_Value_Arg {
hex
}
... on EVM_ABI_BigInt_Value_Arg {
bigInteger
}
... on EVM_ABI_Address_Value_Arg {
address
}
}
}
Call {
From
To
}
}
}
}

Video Tutorial on How to get Newly Created Tokens on Sun Pump​