-
-
Notifications
You must be signed in to change notification settings - Fork 290
Expand file tree
/
Copy pathconnector.routes.ts
More file actions
109 lines (99 loc) · 2.88 KB
/
Copy pathconnector.routes.ts
File metadata and controls
109 lines (99 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { Type, Static } from '@sinclair/typebox';
import { FastifyPluginAsync } from 'fastify';
import { logger } from '../services/logger';
import { GammaConfig } from './gamma/gamma.config';
import { JupiterConfig } from './jupiter/jupiter.config';
import { MeteoraConfig } from './meteora/meteora.config';
import { RaydiumConfig } from './raydium/raydium.config';
import {
UniswapConfig,
uniswapNetworks,
uniswapAmmNetworks,
uniswapClmmNetworks,
} from './uniswap/uniswap.config';
// Define the schema using Typebox
const ConnectorSchema = Type.Object({
name: Type.String(),
trading_types: Type.Array(Type.String()),
chain: Type.String(),
networks: Type.Array(Type.String()),
});
const ConnectorsResponseSchema = Type.Object({
connectors: Type.Array(ConnectorSchema),
});
// Type for TypeScript
type ConnectorsResponse = Static<typeof ConnectorsResponseSchema>;
export const connectorsRoutes: FastifyPluginAsync = async (fastify) => {
// List available connectors
fastify.get<{ Reply: ConnectorsResponse }>(
'/',
{
schema: {
description:
'Returns a list of available DEX connectors and their supported blockchain networks.',
tags: ['system'],
response: {
200: ConnectorsResponseSchema,
},
},
},
async () => {
logger.info('Getting available DEX connectors and networks');
const connectors = [
{
name: 'gamma/amm',
trading_types: ['amm'],
chain: GammaConfig.chain,
networks: GammaConfig.networks
},
{
name: 'jupiter',
trading_types: ['swap'],
chain: JupiterConfig.chain,
networks: JupiterConfig.networks,
},
{
name: 'meteora/clmm',
trading_types: ['clmm', 'swap'],
chain: MeteoraConfig.chain,
networks: MeteoraConfig.networks,
},
{
name: 'raydium/amm',
trading_types: ['amm', 'swap'],
chain: RaydiumConfig.chain,
networks: RaydiumConfig.networks,
},
{
name: 'raydium/clmm',
trading_types: ['clmm', 'swap'],
chain: RaydiumConfig.chain,
networks: RaydiumConfig.networks,
},
{
name: 'uniswap',
trading_types: ['swap'],
chain: 'ethereum',
networks: uniswapNetworks,
},
{
name: 'uniswap/amm',
trading_types: ['amm', 'swap'],
chain: 'ethereum',
networks: uniswapAmmNetworks,
},
{
name: 'uniswap/clmm',
trading_types: ['clmm', 'swap'],
chain: 'ethereum',
networks: uniswapClmmNetworks,
},
];
logger.info(
'Available connectors: ' + connectors.map((c) => c.name).join(', '),
);
return { connectors };
},
);
};
export default connectorsRoutes;