这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
74165cf
feat: add PancakeSwap Solana CLMM connector
fengtality Oct 20, 2025
1e74dd0
feat: add positionsOwned route and documentation for PancakeSwap Solana
fengtality Oct 20, 2025
21701cd
fix: query Token2022 accounts in positionsOwned route
fengtality Oct 20, 2025
c5e275d
feat: add quote-swap route for PancakeSwap Solana CLMM
fengtality Oct 20, 2025
5d4078f
feat: add execute-swap route for PancakeSwap Solana CLMM
fengtality Oct 20, 2025
c8360e3
docs: update README with implemented swap routes
fengtality Oct 20, 2025
03a7202
test: add comprehensive tests and fixtures for all PancakeSwap Solana…
fengtality Oct 20, 2025
b25343d
feat: add removeLiquidity, closePosition, and collectFees routes for …
fengtality Oct 20, 2025
767cf6c
feat: add addLiquidity route and update README for PancakeSwap Solana
fengtality Oct 20, 2025
94d3e94
feat: add quotePosition and openPosition routes - complete CLMM imple…
fengtality Oct 20, 2025
7b5fe51
feat: standardize PancakeSwap schemas with optional network and defau…
fengtality Oct 20, 2025
69aed8e
fix: add null check and proper decimal conversion for position fees
fengtality Oct 21, 2025
2aca47c
feat: improve quote-swap with pool-based price impact and fee calcula…
fengtality Oct 21, 2025
84f8059
fix: upgrade Anchor to 0.30.1 to support IDL defined type format
fengtality Oct 21, 2025
456a6a3
fix: add token account creation and WSOL wrapping for swap transactions
fengtality Oct 21, 2025
0870ea0
fix: detect correct token program (SPL vs Token2022) for swap accounts
fengtality Oct 21, 2025
7a1217c
fix: always wrap SOL before swap, don't close WSOL account
fengtality Oct 21, 2025
3883672
fix: improve error handling in all PancakeSwap Solana routes
fengtality Oct 21, 2025
d476a90
fix: use proper sqrt price limits for swap instead of 0
fengtality Oct 21, 2025
22e06f2
debug: add detailed logging for swap instruction parameters
fengtality Oct 21, 2025
8be0168
fix: add tick array account to swap instruction
fengtality Oct 21, 2025
a53f77f
fix: use snake_case parameter names for Anchor instruction encoding
fengtality Oct 21, 2025
1472a3f
fix: use 0 for sqrt_price_limit (no limit)
fengtality Oct 21, 2025
516f621
fix: only include tick array if it exists on-chain
fengtality Oct 21, 2025
402c6c8
fix: use big-endian encoding for PancakeSwap CLMM PDA derivations
fengtality Oct 21, 2025
28cd247
fix: add slippage support to addLiquidity route
fengtality Oct 21, 2025
6b4ad5a
fix: use quotePosition for proper amount calculation in addLiquidity
fengtality Oct 21, 2025
3d0a2cd
fix: add reward vault accounts to PancakeSwap decrease_liquidity_v2
fengtality Oct 21, 2025
405ac42
fix: add active reward accounts dynamically for decrease_liquidity_v2
fengtality Oct 21, 2025
a9413d2
feat: implement proper liquidity calculation for PancakeSwap addLiqui…
fengtality Oct 21, 2025
906a65f
feat: align closePosition with manual transaction behavior
fengtality Oct 21, 2025
14b62bb
fix: properly construct u128 liquidity value in closePosition
fengtality Oct 21, 2025
13cf7c8
fix: correct liquidity parsing and token program detection in closePo…
fengtality Oct 21, 2025
e32b77f
refactor: cleanup and modularize PancakeSwap Solana connector
fengtality Oct 21, 2025
166054d
test: add CLMM position lifecycle test template (skipped by default)
fengtality Oct 21, 2025
c7d73d4
refactor: enable manual test via MANUAL_TEST env variable
fengtality Oct 21, 2025
aa8e207
refactor: move position lifecycle test to test/lifecycle folder
fengtality Oct 21, 2025
9620cf5
feat: execute real transactions in PancakeSwap Solana lifecycle test
fengtality Oct 21, 2025
cfc6711
docs: add GATEWAY_PASSPHRASE requirement to lifecycle test
fengtality Oct 21, 2025
24eb501
fix: match route flow in lifecycle test - add simulation and fix sign…
fengtality Oct 21, 2025
5d94c34
refactor: use route functions in lifecycle test and export handlers
fengtality Oct 21, 2025
2010ed2
fix: remove lowerPrice and upperPrice from addLiquidity call
fengtality Oct 21, 2025
388d9f7
feat: add WSOL wrapping support for PancakeSwap Solana CLMM positions
fengtality Oct 21, 2025
528e15d
feat: export executeSwap function for direct testing
fengtality Oct 21, 2025
7f5973c
feat: validate pool tokens match swap request before execution
fengtality Oct 21, 2025
cd9e7e8
feat: add WSOL wrap/unwrap helper methods to Solana class
fengtality Oct 21, 2025
2db59ce
feat: auto-unwrap WSOL to native SOL in swap transactions
fengtality Oct 21, 2025
e988187
fix: correct swap parameter order for exact-in vs exact-out swaps
fengtality Oct 21, 2025
5abd201
docs: update closePosition description and add tokens
fengtality Oct 21, 2025
95a81ef
feat: add PancakeSwap Solana pool templates
fengtality Oct 21, 2025
ba93249
fix: make supported connectors list dynamic instead of hardcoded
fengtality Oct 21, 2025
675f35a
feat: add specific error handling for PriceSlippageCheck
fengtality Oct 21, 2025
2804ef8
fix: use proper CLMM math in quote-position to calculate correct amounts
fengtality Oct 21, 2025
7b03c5a
chore: increase default slippage tolerance to 2% for Solana connectors
fengtality Oct 21, 2025
bd74723
test: fix error handling expectations in PancakeSwap Solana tests
fengtality Oct 21, 2025
3f86d1b
feat: export quoteSwap function for testing
fengtality Oct 21, 2025
7bdb8fd
test: add comprehensive route tests for PancakeSwap Solana CLMM
fengtality Oct 21, 2025
818020c
feat: add single-sided position support for out-of-range CLMM positions
fengtality Oct 21, 2025
d98a3b9
docs: update README to include both PancakeSwap connectors
fengtality Oct 21, 2025
af296aa
fix: apply Helius merged config to solana.config for priority fee est…
fengtality Oct 21, 2025
719cd7d
fix: improve Helius transaction sending messages to clarify what's used
fengtality Oct 21, 2025
ae9264f
test: add Infura configuration regression test and improve logging
fengtality Oct 21, 2025
dcfe677
fix: decode Universal Router errors and improve Permit2 expiration di…
fengtality Oct 21, 2025
9de190d
fix: handle empty string amount in approve route
fengtality Oct 21, 2025
71fd891
fix: only initialize HeliusService when API key is configured
fengtality Oct 21, 2025
5a22885
test: Helius regression test now sets up config instead of skipping
fengtality Oct 21, 2025
51d7001
fix: Helius regression test now properly reloads ConfigManagerV2
fengtality Oct 21, 2025
a26fd5f
Merge branch 'development' into feat/pancakeswap-sol
fengtality Oct 21, 2025
1e251a9
test: skip PancakeSwap Solana integration tests in CI
fengtality Oct 21, 2025
17d3015
test: reorganize PancakeSwap Solana integration tests into lifecycle …
fengtality Oct 21, 2025
fcb1951
fix(pancakeswap-sol): use tick-aligned prices and proper CLMM math fo…
fengtality Oct 24, 2025
33709fc
Merge branch 'development' into feat/pancakeswap-sol
fengtality Oct 24, 2025
2d50074
feat: add swapProvider to chain status endpoint response
fengtality Oct 25, 2025
99f4022
feat: add standardized quote-swap and execute-swap chain routes
fengtality Oct 25, 2025
99163d4
feat(solana): implement comprehensive rate limit detection and propag…
fengtality Oct 25, 2025
f225cde
feat: improve gas estimation with refactored parameters and better er…
fengtality Oct 25, 2025
89d604b
refactor(test): eliminate test code duplication with centralized helpers
fengtality Oct 25, 2025
6855987
fix(test): update universal router tests for gas estimation changes
fengtality Oct 25, 2025
d8575b1
Merge branch 'development' into feat/pancakeswap-sol
fengtality Oct 27, 2025
0e0c7c1
feat(routes): add unified cross-chain /swap routes
fengtality Oct 27, 2025
315915e
fix(routes): correct chain-network format for unified swap routes
fengtality Oct 27, 2025
5d20e91
refactor: consolidate swap routes and fix positions-owned endpoints
fengtality Oct 28, 2025
fcf3fbe
feat(trading): add Swagger UI defaults and improve swap route schemas
fengtality Oct 28, 2025
8717815
feat(trading): implement unified CLMM transaction endpoints
fengtality Oct 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gateway can be accessed through:
- **Hummingbot Client**: For automated trading strategies, use the [Hummingbot repository](https://github.com/hummingbot/hummingbot)

### Key Features
- **Standardized REST API**: Consistent endpoints for interacting with blockchains (Ethereum, Solana) and DEXs (Uniswap, Jupiter, Raydium, Meteora, 0x, Pancakeswap)
- **Standardized REST API**: Consistent endpoints for interacting with blockchains (Ethereum, Solana) and DEXs (Uniswap, Jupiter, Raydium, Meteora, PancakeSwap, 0x)
- **Three Trading Types**: Router (DEX aggregators), AMM (V2-style pools), and CLMM (V3-style concentrated liquidity)
- **Modular Architecture**: Clear separation of concerns with distinct modules for chains, connectors, configuration, and wallet management
- **TypeScript-based**: Leverages the TypeScript ecosystem and popular libraries like Fastify, Ethers.js, and Solana/web3.js
Expand Down Expand Up @@ -78,7 +78,9 @@ Both RPC providers maintain full backward compatibility - networks default to st
|----------|-------|--------|-----|------|-------------|
| Jupiter | Solana | ✅ | ❌ | ❌ | DEX aggregator finding optimal swap routes |
| Meteora | Solana | ❌ | ❌ | ✅ | Dynamic Liquidity Market Maker (DLMM) |
| PancakeSwap (Solana) | Solana | ❌ | ❌ | ✅ | V3 concentrated liquidity pools with single-sided positions |
| Raydium | Solana | ❌ | ✅ | ✅ | Full-featured DEX with V2 AMM and V3 CLMM |
| PancakeSwap | Ethereum/EVM | ✅ | ✅ | ✅ | Multi-chain DEX with V2 AMM, V3 CLMM, and Smart Router |
| Uniswap | Ethereum/EVM | ✅ | ✅ | ✅ | Complete V2 AMM, V3 CLMM, and Smart Order Router |
| 0x | Ethereum/EVM | ✅ | ❌ | ❌ | DEX aggregator with professional market making features |

Expand Down Expand Up @@ -383,13 +385,13 @@ docker run -p 15888:15888 \
- `POST /connectors/{dex}/router/execute-quote` - Execute pre-fetched quote
- `GET /connectors/0x/router/get-price` - Get price estimate (0x only)

#### AMM Operations (Uniswap V2, Raydium, Pancakeswap V2)
#### AMM Operations (Uniswap V2, PancakeSwap V2, Raydium)
- `GET /connectors/{dex}/amm/pool-info` - Pool information
- `GET /connectors/{dex}/amm/position-info` - LP position details
- `POST /connectors/{dex}/amm/add-liquidity` - Add liquidity
- `POST /connectors/{dex}/amm/remove-liquidity` - Remove liquidity

#### CLMM Operations (Uniswap V3, Raydium, Meteora, Pancakeswap V3)
#### CLMM Operations (Uniswap V3, PancakeSwap V3, Raydium, Meteora)
- `GET /connectors/{dex}/clmm/pool-info` - Pool information
- `GET /connectors/{dex}/clmm/positions-owned` - List positions
- `POST /connectors/{dex}/clmm/open-position` - Open position
Expand Down Expand Up @@ -425,6 +427,8 @@ Gateway stores pool configurations for AMM and CLMM connectors in `src/templates
**Pool Template Files:**
- `src/templates/pools/raydium.json` - Raydium AMM and CLMM pools
- `src/templates/pools/meteora.json` - Meteora DLMM pools
- `src/templates/pools/pancakeswap.json` - PancakeSwap (EVM) V2 AMM and V3 CLMM pools
- `src/templates/pools/pancakeswap-sol.json` - PancakeSwap Solana CLMM pools
- `src/templates/pools/uniswap.json` - Uniswap V2 and V3 pools

**Migrating Pool Templates:**
Expand All @@ -433,8 +437,8 @@ If you need to migrate pool templates from an older format (without token addres

```bash
# Ensure RPC endpoints are configured in conf/rpc/*.yml
# Raydium/Meteora require Helius or standard Solana RPC
# Uniswap requires Infura or standard Ethereum RPC
# Raydium/Meteora/PancakeSwap-Sol require Helius or standard Solana RPC
# Uniswap/PancakeSwap require Infura or standard Ethereum RPC

npx ts-node scripts/migrate-pool-templates.ts
```
Expand Down Expand Up @@ -591,7 +595,8 @@ The test directory is organized as follows:
/uniswap/ # Uniswap connector tests
/raydium/ # Raydium connector tests
/meteora/ # Meteora connector tests
/pancakeswap/ # Pancakeswap connector tests
/pancakeswap/ # PancakeSwap (EVM) connector tests
/pancakeswap-sol/ # PancakeSwap Solana connector tests
/mocks/ # Mock response data
/chains/ # Chain mock responses
chains.json # Chain routes mock response
Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
'/node_modules/',
'test-helpers',
'<rootDir>/test-scripts/',
'<rootDir>/test/lifecycle/',
],
testMatch: ['<rootDir>/test/**/*.test.ts', '<rootDir>/test/**/*.test.js'],
transform: {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"setup": "bash ./gateway-setup.sh",
"setup:with-defaults": "bash ./gateway-setup.sh --with-defaults",
"start": "START_SERVER=true node dist/index.js",
"copy-files": "copyfiles 'src/templates/namespace/*.json' 'src/templates/*.yml' 'src/templates/chains/**/*.yml' 'src/templates/connectors/*.yml' 'src/templates/tokens/**/*.json' 'src/templates/pools/*.json' 'src/templates/rpc/*.yml' dist",
"copy-files": "copyfiles 'src/templates/namespace/*.json' 'src/templates/*.yml' 'src/templates/chains/**/*.yml' 'src/templates/connectors/*.yml' 'src/templates/tokens/**/*.json' 'src/templates/pools/*.json' 'src/templates/rpc/*.yml' dist && copyfiles -u 1 'src/connectors/pancakeswap-sol/idl/*.json' dist",
"test": "GATEWAY_TEST_MODE=dev jest --verbose",
"test:clear-cache": "jest --clearCache",
"test:debug": "GATEWAY_TEST_MODE=dev jest --watch --runInBand",
Expand All @@ -37,7 +37,7 @@
"prepare": "pnpm husky"
},
"dependencies": {
"@coral-xyz/anchor": "^0.29.0",
"@coral-xyz/anchor": "^0.30.1",
"@ethersproject/abstract-provider": "5.7.0",
"@ethersproject/address": "5.7.0",
"@ethersproject/contracts": "5.7.0",
Expand Down
25 changes: 16 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { register0xRoutes } from './connectors/0x/0x.routes';
import { jupiterRoutes } from './connectors/jupiter/jupiter.routes';
import { meteoraRoutes } from './connectors/meteora/meteora.routes';
import { pancakeswapRoutes } from './connectors/pancakeswap/pancakeswap.routes';
import { pancakeswapSolRoutes } from './connectors/pancakeswap-sol/pancakeswap-sol.routes';
import { raydiumRoutes } from './connectors/raydium/raydium.routes';
import { uniswapRoutes } from './connectors/uniswap/uniswap.routes';
import { getHttpsOptions } from './https';
Expand All @@ -28,6 +29,7 @@ import { ConfigManagerV2 } from './services/config-manager-v2';
import { logger } from './services/logger';
import { quoteCache } from './services/quote-cache';
import { tokensRoutes } from './tokens/tokens.routes';
import { tradingRoutes, tradingClmmRoutes } from './trading/trading.routes';
import { GATEWAY_VERSION } from './version';
import { walletRoutes } from './wallet/wallet.routes';

Expand Down Expand Up @@ -61,6 +63,8 @@ const swaggerOptions = {
{ name: '/wallet', description: 'Wallet management endpoints' },
{ name: '/tokens', description: 'Token management endpoints' },
{ name: '/pools', description: 'Pool management endpoints' },
{ name: '/trading/swap', description: 'Unified cross-chain swap endpoints' },
{ name: '/trading/clmm', description: 'Unified cross-chain CLMM (Concentrated Liquidity) endpoints' },

// Chains
{
Expand Down Expand Up @@ -90,6 +94,14 @@ const swaggerOptions = {
description: 'Uniswap connector endpoints',
},
{ name: '/connector/0x', description: '0x connector endpoints' },
{
name: '/connector/pancakeswap-sol',
description: 'PancakeSwap Solana connector endpoints',
},
{
name: '/connector/pancakeswap',
description: 'PancakeSwap EVM connector endpoints',
},
],
components: {
parameters: {
Expand Down Expand Up @@ -213,6 +225,12 @@ const configureGatewayServer = () => {
// Register pool routes
app.register(poolRoutes, { prefix: '/pools' });

// Register trading routes (unified cross-chain swap)
app.register(tradingRoutes, { prefix: '/trading/swap' });

// Register trading CLMM routes (unified cross-chain concentrated liquidity)
app.register(tradingClmmRoutes, { prefix: '/trading/clmm' });

// Register chain routes
app.register(solanaRoutes, { prefix: '/chains/solana' });
app.register(ethereumRoutes, { prefix: '/chains/ethereum' });
Expand Down Expand Up @@ -247,6 +265,9 @@ const configureGatewayServer = () => {
});
app.register(pancakeswapRoutes.amm, { prefix: '/connectors/pancakeswap/amm' });
app.register(pancakeswapRoutes.clmm, { prefix: '/connectors/pancakeswap/clmm' });

// PancakeSwap Solana routes
app.register(pancakeswapSolRoutes, { prefix: '/connectors/pancakeswap-sol' });
};

// Register routes on main server
Expand Down Expand Up @@ -275,7 +296,7 @@ const configureGatewayServer = () => {
});
}

// Handle Fastify's native errors
// Handle Fastify's native errors (includes rate limit errors with statusCode 429)
if (error.statusCode && error.statusCode >= 400) {
return reply.status(error.statusCode).send({
statusCode: error.statusCode,
Expand Down
16 changes: 10 additions & 6 deletions src/chains/ethereum/ethereum.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ export interface EthereumNetworkConfig {
chainID: number;
nodeURL: string;
nativeCurrencySymbol: string;
minGasPrice?: number;
maxFeePerGas?: number;
maxPriorityFeePerGas?: number;
swapProvider?: string;
gasPrice?: number | null;
baseFee?: number | null;
priorityFee?: number | null;
baseFeeMultiplier?: number;
infuraAPIKey?: string;
useInfuraWebSocket?: boolean;
}
Expand All @@ -29,9 +31,11 @@ export function getEthereumNetworkConfig(network: string): EthereumNetworkConfig
chainID: ConfigManagerV2.getInstance().get(namespaceId + '.chainID'),
nodeURL: ConfigManagerV2.getInstance().get(namespaceId + '.nodeURL'),
nativeCurrencySymbol: ConfigManagerV2.getInstance().get(namespaceId + '.nativeCurrencySymbol'),
minGasPrice: ConfigManagerV2.getInstance().get(namespaceId + '.minGasPrice'),
maxFeePerGas: ConfigManagerV2.getInstance().get(namespaceId + '.maxFeePerGas'),
maxPriorityFeePerGas: ConfigManagerV2.getInstance().get(namespaceId + '.maxPriorityFeePerGas'),
swapProvider: ConfigManagerV2.getInstance().get(namespaceId + '.swapProvider'),
gasPrice: ConfigManagerV2.getInstance().get(namespaceId + '.gasPrice'),
baseFee: ConfigManagerV2.getInstance().get(namespaceId + '.baseFee'),
priorityFee: ConfigManagerV2.getInstance().get(namespaceId + '.priorityFee'),
baseFeeMultiplier: ConfigManagerV2.getInstance().get(namespaceId + '.baseFeeMultiplier'),
};
}

Expand Down
Loading