mirror of
https://github.com/luxfi/dex.git
synced 2026-09-24 00:26:31 +00:00
The best_venue_buy() and best_venue_sell() methods used Decimal::from_double(1e18) as a sentinel value, which caused integer overflow (1e18 * 1e8 scale = 1e26 exceeds int64_t max ~9.2e18). This resulted in undefined behavior during price comparisons. Changed to use std::optional<Decimal> for safe sentinel-free comparisons.
LX Hummingbot Gateway Plugin
Official Hummingbot Gateway plugin for LX.
Installation
Via npm
npm install hummingbot-gateway-lxdex-plugin
Manual Installation
- Clone the repository:
git clone https://github.com/luxfi/dex.git
cd dex/hummingbot-gateway/plugins/lxdex
- Install dependencies and build:
npm install
npm run build
- Link to your Gateway installation:
npm link
cd /path/to/hummingbot-gateway
npm link hummingbot-gateway-lxdex-plugin
Configuration
Copy the configuration file to your Gateway config directory:
cp config/lxdex.yml /path/to/hummingbot-gateway/conf/
Configuration Options
Edit conf/lxdex.yml to customize:
- Network endpoints: API, WebSocket, gRPC URLs
- Trading parameters: Slippage, max hops, quote expiration
- Gas settings: Gas limit, price source
- Rate limits: Requests per second
- WebSocket: Auto-reconnect, ping intervals
Usage
Register with Gateway
In your Gateway startup file:
import { FastifyInstance } from 'fastify';
import { lxdexPlugin } from 'hummingbot-gateway-lxdex-plugin';
async function start(fastify: FastifyInstance) {
// Register LX plugin
await fastify.register(lxdexPlugin);
await fastify.listen({ port: 15888 });
}
Test Endpoints
# Health check
curl http://localhost:15888/lxdex/health
# Get swap quote
curl "http://localhost:15888/lxdex/router/quote-swap?baseToken=LUX"eToken=USDC&amount=1000000000000000000&side=SELL"
# Get trading pairs
curl http://localhost:15888/lxdex/pairs
Supported Trading Operations
| Schema | Endpoint Prefix | Operations |
|---|---|---|
| Router | /lxdex/router |
Quote swap, Execute swap |
| AMM | /lxdex/amm |
Pool info, Add/Remove liquidity |
| CLMM | /lxdex/clmm |
Open/Close positions, Collect fees |
| CLOB | /lxdex |
Place/Cancel orders, Order book |
Links
License
Apache-2.0