Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ This file provides guidance to AI coding assistants when working with code in th
- `raydium/`: Contains both `amm-routes/` and `clmm-routes/`
- `uniswap/`: Contains `router-routes/`, `amm-routes/`, and `clmm-routes/`
- `0x/router-routes/`: 0x aggregator routes
- `fibrous/router-routes/`: Fibrous aggregator routes
- `services/`: Core services and utilities
- `config-manager-v2.ts`: Configuration management
- `logger.ts`: Logging service
Expand Down Expand Up @@ -200,6 +201,8 @@ Gateway supports optimized RPC providers for enhanced performance:
- Base
- BSC (Binance Smart Chain)
- Celo
- HyperEVM
- Monad
- Optimism
- Polygon
- Sepolia (testnet)
Expand All @@ -214,6 +217,7 @@ Gateway supports optimized RPC providers for enhanced performance:
- **Raydium** (Solana): Standard AMM and CLMM operations
- **Uniswap** (Ethereum/EVM): V2 AMM, V3 CLMM, and V3 Smart Order Router swaps
- **0x** (Ethereum/EVM): Router-based swaps via DEX aggregator
- **Fibrous** (Ethereum/EVM): Router-based swaps via DEX aggregator (Base, HyperEVM, Monad)

### Supported DEX Protocols

Expand All @@ -224,6 +228,7 @@ Gateway supports optimized RPC providers for enhanced performance:
| Raydium | Solana | ❌ | βœ… | βœ… |
| Uniswap | Ethereum/EVM | βœ… | βœ… | βœ… |
| 0x | Ethereum/EVM | βœ… | ❌ | ❌ |
| Fibrous | Ethereum/EVM | βœ… | ❌ | ❌ |

## Environment Variables
- `GATEWAY_PASSPHRASE`: Set passphrase for wallet encryption
Expand Down
5 changes: 4 additions & 1 deletion 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, PancakeSwap, 0x)
- **Standardized REST API**: Consistent endpoints for interacting with blockchains (Ethereum, Solana) and DEXs (Uniswap, Jupiter, Raydium, Meteora, PancakeSwap, 0x, Fibrous)
- **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 @@ -46,6 +46,8 @@ Gateway may be used alongside the main [Hummingbot client](https://github.com/hu
- Base
- BSC (Binance Smart Chain)
- Celo
- HyperEVM
- Monad
- Optimism
- Polygon
- Sepolia (testnet)
Expand Down Expand Up @@ -83,6 +85,7 @@ Both RPC providers maintain full backward compatibility - networks default to st
| 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 |
| Fibrous | Ethereum/EVM | βœ… | ❌ | ❌ | DEX aggregator for Base, HyperEVM and Monad |

#### Trading Types Explained:
- **Router**: DEX aggregators that find optimal swap routes across multiple liquidity sources
Expand Down
8 changes: 8 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { solanaRoutes } from './chains/solana/solana.routes';
import { configRoutes } from './config/config.routes';
import { register0xRoutes } from './connectors/0x/0x.routes';
import { dflowRoutes } from './connectors/dflow/dflow.routes';
import { registerFibrousRoutes } from './connectors/fibrous/fibrous.routes';
import { jupiterRoutes } from './connectors/jupiter/jupiter.routes';
import { meteoraRoutes } from './connectors/meteora/meteora.routes';
import { okxRoutes } from './connectors/okx/okx.routes';
Expand Down Expand Up @@ -114,6 +115,10 @@ const swaggerOptions = {
description: 'Uniswap connector endpoints',
},
{ name: '/connector/0x', description: '0x connector endpoints' },
{
name: '/connector/fibrous',
description: 'Fibrous connector endpoints',
},
{
name: '/connector/pancakeswap-sol',
description: 'PancakeSwap Solana connector endpoints',
Expand Down Expand Up @@ -342,6 +347,9 @@ const configureGatewayServer = () => {
// 0x routes
app.register(register0xRoutes);

// Fibrous routes
app.register(registerFibrousRoutes);

// Pancakeswap routes
app.register(pancakeswapRoutes.router, {
prefix: '/connectors/pancakeswap/router',
Expand Down
12 changes: 12 additions & 0 deletions src/chains/ethereum/ethereum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export const EIP1559_NETWORKS = [
'robinhoodchain',
'robinhoodchain-testnet',
'unichain',
'hyperevm',
'monad',
];

export class Ethereum {
Expand Down Expand Up @@ -917,6 +919,16 @@ export class Ethereum {
symbol: 'WETH',
nativeSymbol: 'ETH',
},
hyperevm: {
address: '0x5555555555555555555555555555555555555555',
symbol: 'WHYPE',
nativeSymbol: 'HYPE',
},
monad: {
address: '0x3bD359C1119dA7dA1D913D1c4d2b7C461115433a',
symbol: 'WMON',
nativeSymbol: 'MON',
},
};

/**
Expand Down
7 changes: 7 additions & 0 deletions src/config/routes/getConnectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { PancakeswapConfig } from '#src/connectors/pancakeswap/pancakeswap.confi

import { ZeroXConfig } from '../../connectors/0x/0x.config';
import { DFlowConfig } from '../../connectors/dflow/dflow.config';
import { FibrousConfig } from '../../connectors/fibrous/fibrous.config';
import { JupiterConfig } from '../../connectors/jupiter/jupiter.config';
import { MeteoraConfig } from '../../connectors/meteora/meteora.config';
import { OkxConfig } from '../../connectors/okx/okx.config';
Expand Down Expand Up @@ -62,6 +63,12 @@ export const connectorsConfig = [
chain: ZeroXConfig.chain,
networks: [...ZeroXConfig.networks],
},
{
name: 'fibrous',
trading_types: [...FibrousConfig.tradingTypes],
chain: FibrousConfig.chain,
networks: [...FibrousConfig.networks],
},
{
name: 'pancakeswap',
trading_types: [...PancakeswapConfig.tradingTypes],
Expand Down
48 changes: 48 additions & 0 deletions src/connectors/fibrous/fibrous.abi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/**
* Minimal ABI for the Fibrous EVM router contract.
*
* Only the `swap` entrypoint is included, since that is the sole function
* Gateway encodes. The full ABI is published at:
* https://github.com/Fibrous-Finance/router-contract-abi
*
* The tuple layouts below mirror the `route` and `swap_parameters` objects
* returned verbatim by the Fibrous `POST /{network}/v2/calldata` endpoint.
*/
export const FibrousRouterABI = [
{
type: 'function',
name: 'swap',
inputs: [
{
name: 'route',
type: 'tuple',
internalType: 'struct RouteParam',
components: [
{ name: 'token_in', type: 'address', internalType: 'address' },
{ name: 'token_out', type: 'address', internalType: 'address' },
{ name: 'amount_in', type: 'uint256', internalType: 'uint256' },
{ name: 'amount_out', type: 'uint256', internalType: 'uint256' },
{ name: 'min_received', type: 'uint256', internalType: 'uint256' },
{ name: 'destination', type: 'address', internalType: 'address' },
{ name: 'swap_type', type: 'uint8', internalType: 'enum SwapType' },
],
},
{
name: 'swap_parameters',
type: 'tuple[]',
internalType: 'struct SwapParams[]',
components: [
{ name: 'token_in', type: 'address', internalType: 'address' },
{ name: 'token_out', type: 'address', internalType: 'address' },
{ name: 'rate', type: 'uint32', internalType: 'uint32' },
{ name: 'protocol_id', type: 'int24', internalType: 'int24' },
{ name: 'pool_address', type: 'address', internalType: 'address' },
{ name: 'swap_type', type: 'uint8', internalType: 'enum SwapType' },
{ name: 'extra_data', type: 'bytes', internalType: 'bytes' },
],
},
],
outputs: [{ name: '', type: 'uint256', internalType: 'uint256' }],
stateMutability: 'payable',
},
] as const;
49 changes: 49 additions & 0 deletions src/connectors/fibrous/fibrous.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { getAvailableEthereumNetworks } from '../../chains/ethereum/ethereum.utils';
import { ConfigManagerV2 } from '../../services/config-manager-v2';

export namespace FibrousConfig {
// Supported networks for Fibrous
// See https://docs.fibrous.finance
export const chain = 'ethereum';
// Only include networks that are supported by Fibrous and available in Gateway.
// Fibrous also supports Starknet, which is not an EVM chain and therefore not
// reachable through Gateway's Ethereum chain implementation.
export const networks = getAvailableEthereumNetworks().filter((network) =>
['base', 'hyperevm', 'monad'].includes(network),
);
export type Network = string;

// Supported trading types
export const tradingTypes = ['router'] as const;

export interface RootConfig {
// Global configuration
apiKey: string;
slippagePct: number;
}

export const config: RootConfig = {
apiKey: ConfigManagerV2.getInstance().get('fibrous.apiKey'),
slippagePct: ConfigManagerV2.getInstance().get('fibrous.slippagePct'),
};

// Maps a Gateway network name to the Fibrous API network path segment
const networkMap: Record<string, string> = {
base: 'base',
hyperevm: 'hyperevm',
monad: 'monad',
};

export const getApiNetwork = (network: string): string => {
const apiNetwork = networkMap[network];
if (!apiNetwork) {
throw new Error(
`Fibrous API network not found for network: ${network}. Supported networks: ${Object.keys(networkMap).join(', ')}`,
);
}
return apiNetwork;
};

// Fibrous exposes a V2 API for EVM networks. V1 remains available for Starknet only.
export const getApiEndpoint = (network: string): string => `https://api.fibrous.finance/${getApiNetwork(network)}/v2`;
}
10 changes: 10 additions & 0 deletions src/connectors/fibrous/fibrous.routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { FastifyInstance } from 'fastify';

import fibrousRouterRoutes from './router-routes';

export const registerFibrousRoutes = async (fastify: FastifyInstance): Promise<void> => {
// Register router routes (3 endpoints)
await fastify.register(fibrousRouterRoutes, {
prefix: '/connectors/fibrous/router',
});
};
Loading