这是indexloc提供的服务,不要输入任何密码
Skip to content

Feat/cardano #484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: development
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
"rebuild-bigint": "cd node_modules/bigint-buffer && npm run rebuild"
},
"dependencies": {
"@aiquant/lucid-cardano": "^0.10.11",
"@aiquant/minswap-sdk": "^0.0.0",
"@aiquant/sundaeswap-core": "^1.2.10",
"@blockfrost/blockfrost-js": "^5.7.0",
"@coral-xyz/anchor": "^0.29.0",
"@ethersproject/abstract-provider": "5.7.0",
"@ethersproject/address": "5.7.0",
Expand Down Expand Up @@ -52,6 +56,7 @@
"@solana/spl-token-registry": "^0.2.4574",
"@solana/web3.js": "^1.98.0",
"@solflare-wallet/utl-sdk": "^1.4.0",
"@sundaeswap/asset": "^1.0.10",
"@uniswap/sdk": "3.0.3",
"@uniswap/sdk-core": "^5.9.0",
"@uniswap/smart-order-router": "^3.59.0",
Expand All @@ -64,6 +69,7 @@
"axios": "^1.8.4",
"bn.js": "5.2.1",
"brotli": "1.3.2",
"core-js": "^3.43.0",
"dayjs": "^1.11.13",
"decimal.js": "^10.5.0",
"decimal.js-light": "^2.5.1",
Expand Down
2,857 changes: 1,734 additions & 1,123 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ import Fastify, { FastifyInstance } from 'fastify';
import { chainRoutes } from './chains/chain.routes';
import { ethereumRoutes } from './chains/ethereum/ethereum.routes';
import { solanaRoutes } from './chains/solana/solana.routes';
import { cardanoRoutes } from './chains/cardano/cardano.routes';
import { configRoutes } from './config/config.routes';
import { connectorsRoutes } from './connectors/connector.routes';
import { jupiterRoutes } from './connectors/jupiter/jupiter.routes';
import { meteoraRoutes } from './connectors/meteora/meteora.routes';
import { raydiumRoutes } from './connectors/raydium/raydium.routes';
import { uniswapRoutes } from './connectors/uniswap/uniswap.routes';
import { minswapRoutes } from './connectors/minswap/minswap.routes';
import { sundaeswapRoutes } from './connectors/sundaeswap/sundaeswap.routes';
import { getHttpsOptions } from './https';
import { ConfigManagerV2 } from './services/config-manager-v2';
import { logger } from './services/logger';
Expand Down Expand Up @@ -63,6 +66,7 @@ const swaggerOptions = {
// Chains
{ name: 'solana', description: 'Solana chain endpoints' },
{ name: 'ethereum', description: 'Ethereum chain endpoints' },
{ name: 'cardano', description: 'Cardano chain endpoints' },

// Connectors
{ name: 'jupiter', description: 'Jupiter DEX aggregator (Solana)' },
Expand Down Expand Up @@ -90,6 +94,14 @@ const swaggerOptions = {
name: 'uniswap/clmm',
description: 'Uniswap V3 pool connector (Ethereum)',
},
{
name: 'minswap/amm',
description: 'Minswap pool connector (Cardano)',
},
{
name: 'sundaeswap/amm',
description: 'Sundaeswap pool connector (Cardano)',
},
],
components: {
parameters: {
Expand Down Expand Up @@ -209,9 +221,18 @@ const configureGatewayServer = () => {

app.register(uniswapRoutes, { prefix: '/connectors/uniswap' });

// Minswap routes
app.register(minswapRoutes.amm, { prefix: '/connectors/minswap/amm' });

// Sundaeswap routes
app.register(sundaeswapRoutes.amm, {
prefix: '/connectors/sundaeswap/amm',
});

// Register chain routes
app.register(solanaRoutes, { prefix: '/chains/solana' });
app.register(ethereumRoutes, { prefix: '/chains/ethereum' });
app.register(cardanoRoutes, { prefix: '/chains/cardano' });
};

// Register routes on main server
Expand Down
40 changes: 40 additions & 0 deletions src/chains/cardano/cardano.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { ConfigManagerV2 } from '../../services/config-manager-v2';
interface NetworkConfig {
name: string;
tokenListType: string;
tokenListSource: string;
nativeCurrencySymbol: string;
apiurl: string;
projectId: string;
}

export interface Config {
network: NetworkConfig;
}

export function getCardanoConfig(
chainName: string,
networkName: string,
): Config {
return {
network: {
name: networkName,
tokenListType: ConfigManagerV2.getInstance().get(
chainName + '.networks.' + networkName + '.tokenListType',
),
tokenListSource: ConfigManagerV2.getInstance().get(
chainName + '.networks.' + networkName + '.tokenListSource',
),
nativeCurrencySymbol: ConfigManagerV2.getInstance().get(
chainName + '.networks.' + networkName + '.nativeCurrencySymbol',
),
apiurl: ConfigManagerV2.getInstance().get(
chainName + '.networks.' + networkName + '.apiurl',
),
projectId: ConfigManagerV2.getInstance().get(
chainName + '.networks.' + networkName + '.projectId',
),
},
// Additional Cardano-specific configurations can be added here
};
}
24 changes: 24 additions & 0 deletions src/chains/cardano/cardano.routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { FastifyPluginAsync } from 'fastify';

import { statusRoute } from './routes/status';
import { tokensRoute } from './routes/tokens';
import { balancesRoute } from './routes/balances';
import { pollRoute } from './routes/poll';

// Register the type declaration needed for Fastify schema tags
declare module 'fastify' {
interface FastifySchema {
tags?: readonly string[];
description?: string;
}
}

export const cardanoRoutes: FastifyPluginAsync = async (fastify) => {
// Register all the route handlers
fastify.register(statusRoute);
fastify.register(tokensRoute);
fastify.register(balancesRoute);
fastify.register(pollRoute);
};

export default cardanoRoutes;
Loading