Skip to content

Commit 0c99c5c

Browse files
authored
Merge pull request #528 from hummingbot/feat/pools
feat: enhance pool storage with token addresses and fees
2 parents 2d85a56 + 36dff19 commit 0c99c5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3356
-463
lines changed

CLAUDE.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,63 @@ This file provides guidance to AI coding assistants when working with code in th
128128
- RPC provider configs: `src/templates/rpc/{provider}.yml`
129129
- All configs validated against JSON schemas in `src/templates/namespace/`
130130

131+
### Pool Storage Format
132+
Gateway stores pool configurations for each connector in `src/templates/pools/{connector}.json`. The pool storage format includes complete pool information fetched from on-chain data to ensure token ordering and fees match the actual pool state.
133+
134+
#### Pool Object Structure
135+
Each pool entry contains:
136+
```typescript
137+
{
138+
type: 'amm' | 'clmm', // Pool type: AMM (V2) or CLMM (V3)
139+
network: string, // Network name (e.g., 'mainnet-beta', 'mainnet')
140+
baseSymbol: string, // Base token symbol (e.g., 'SOL')
141+
quoteSymbol: string, // Quote token symbol (e.g., 'USDC')
142+
baseTokenAddress: string, // Base token contract address (authoritative)
143+
quoteTokenAddress: string, // Quote token contract address (authoritative)
144+
feePct: number, // Pool fee percentage (e.g., 0.25 for 0.25%)
145+
address: string // Pool contract address
146+
}
147+
```
148+
149+
#### Adding Pools via API
150+
Use `POST /pools` to add a new pool. The route automatically:
151+
1. Fetches pool-info from the connector (authoritative source)
152+
2. Extracts baseTokenAddress, quoteTokenAddress, and feePct
153+
3. Resolves token symbols from addresses (if not provided)
154+
4. Validates all required fields
155+
5. Stores the enhanced pool object
156+
157+
Example request:
158+
```bash
159+
curl -X POST http://localhost:15888/pools \
160+
-H "Content-Type: application/json" \
161+
-d '{
162+
"connector": "raydium",
163+
"type": "amm",
164+
"network": "mainnet-beta",
165+
"address": "58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2"
166+
}'
167+
```
168+
169+
The API will fetch pool-info and store complete pool data including token addresses and fees.
170+
171+
#### Pool Template Migration
172+
To migrate existing pool templates from the old format (symbol-only) to the new format (with token addresses and fees):
173+
174+
```bash
175+
# Ensure RPC endpoints are configured in conf/rpc/*.yml
176+
npx ts-node scripts/migrate-pool-templates.ts
177+
```
178+
179+
The migration script:
180+
- Processes raydium.json, meteora.json, and uniswap.json
181+
- Fetches pool-info for each pool address
182+
- Extracts baseTokenAddress, quoteTokenAddress, and feePct from on-chain data
183+
- Writes updated template files with the new format
184+
- Reports success/failure counts for each connector
185+
186+
After migration, review the updated template files before committing to ensure all pools were migrated successfully.
187+
131188
### RPC Provider Configuration
132189
Gateway supports optimized RPC providers for enhanced performance:
133190
- **Infura** (Ethereum): `conf/rpc/infura.yml` - Set `rpcProvider: infura` in network configs

0 commit comments

Comments
 (0)