View Pools
This endpoint provides real-time and historical data for all liquidity pools in the protocol.
Data Update Frequency
Our system maintains two update cycles for different types of pool data:
Real-time Updates (5-second intervals)
- Total Value Locked (TVL)
- Price Ticks
- Liquidity Positions
- Square Root Prices
Hourly Updates
- Annual Percentage Rates (APRs)
- Trading Fees
- Trading Volume
Using the sdk
import api, { IConnection } from "codemelt-retro-api-sdk"
const connection: IConnection = {
host: '<enter you host url here>',
headers: {
'x-api-key': '<enter your api key here>'
}
}
const networkName = "Zeta Mainnet"
const pools = await api.functional.api.algebra.pool.all.getAllPools(
connection,
networkName
)
Implementing Real-time Updates
To maintain real-time data updates, you can implement a polling mechanism. Here is a simple PoC:
import api, { IConnection } from "codemelt-retro-api-sdk"
import { AlgebraPoolDTO } from 'codemelt-retro-api-sdk/structures/AlgebraPoolDTO'
class PoolDataManager {
private connection: IConnection
//always use the sdk types
//if possible do not override them with custom types
private poolData: Array<AlgebraPoolDTO>
private abortController: AbortController | null = null
constructor(apiKey: string, host: string) {
this.connection = {
host,
headers: {
'x-api-key': apiKey
}
}
}
startPolling() {
this.abortController = new AbortController()
const poll = async () => {
try {
const networkName = "Zeta Mainnet"
const response = await api.functional.api.liquidity.pools.getAll(this.connection, networkName)
if(response.success && response.data.status){
this.poolData = response.data.data
}
if (!this.abortController?.signal.aborted) {
setTimeout(poll, 5000)
}
} catch (err) {
if (!this.abortController?.signal.aborted) {
setTimeout(poll, 5000)
}
}
}
poll()
}
stopPolling() {
this.abortController?.abort()
this.abortController = null
}
getPoolData(poolId: string): PoolData | undefined {
return this.poolData.get(poolId)
}
}
Best Practices
- Rate Limiting: Respect the API rate limits by not exceeding the recommended polling intervals
- Error Handling: Implement proper error handling and retries
- Data Caching: Cache data locally to reduce API calls but keep in mind update frequency
- State Management: Use appropriate state management solutions for your frontend framework. This can negatively impact the ticks and liquidity seeding
The response is of type object
.
The response is of type object
.
The response is of type object
.