|
| 1 | +import { Injectable, Scope } from '@nestjs/common'; |
| 2 | +import { Prompt } from '../../../dist'; |
| 3 | +import { z } from 'zod'; |
| 4 | + |
| 5 | +@Injectable({ scope: Scope.REQUEST }) |
| 6 | +export class DexPrompt { |
| 7 | + constructor() {} |
| 8 | + |
| 9 | + @Prompt({ |
| 10 | + name: 'getRouteAnalysis', |
| 11 | + description: 'Analyze and explain the best trading route between two tokens, including gas costs, slippage, and alternative routes', |
| 12 | + parameters: z.object({ |
| 13 | + chain: z.string().describe('Chain name (supported aliases: solana→sol, binance→bsc, matic→polygon, arb→arbitrum, op→optimism, avax→avalanche, eth→ethereum)'), |
| 14 | + fromToken: z.string().describe('Source token address or symbol'), |
| 15 | + toToken: z.string().describe('Destination token address or symbol'), |
| 16 | + amount: z.string().describe('Amount of tokens to swap'), |
| 17 | + }), |
| 18 | + }) |
| 19 | + getRouteAnalysis({ chain, fromToken, toToken, amount }) { |
| 20 | + return { |
| 21 | + description: 'DEX route analysis guide', |
| 22 | + messages: [ |
| 23 | + { |
| 24 | + role: 'user', |
| 25 | + content: { |
| 26 | + type: 'text', |
| 27 | + text: `I want to analyze the best trading route from ${fromToken} to ${toToken} on ${chain} for ${amount} tokens.`, |
| 28 | + }, |
| 29 | + }, |
| 30 | + { |
| 31 | + role: 'assistant', |
| 32 | + content: { |
| 33 | + type: 'text', |
| 34 | + text: `I'll help you analyze the best trading route from ${fromToken} to ${toToken} on ${chain} for ${amount} tokens. |
| 35 | +
|
| 36 | +To get the optimal route, I'll use the DEX route finder tool which will: |
| 37 | +1. Calculate the best path through available DEX protocols |
| 38 | +2. Estimate gas costs and fees |
| 39 | +3. Consider slippage tolerance |
| 40 | +4. Provide alternative routes if available |
| 41 | +
|
| 42 | +Let me fetch this information for you using the getRoute tool.`, |
| 43 | + }, |
| 44 | + }, |
| 45 | + ], |
| 46 | + }; |
| 47 | + } |
| 48 | + |
| 49 | + @Prompt({ |
| 50 | + name: 'getSwapGuide', |
| 51 | + description: 'Provide a comprehensive guide for executing a token swap, including safety tips and best practices', |
| 52 | + parameters: z.object({ |
| 53 | + chain: z.string().describe('Chain name (supported aliases: solana→sol, binance→bsc, matic→polygon, arb→arbitrum, op→optimism, avax→avalanche, eth→ethereum)'), |
| 54 | + fromToken: z.string().describe('Source token address or symbol'), |
| 55 | + toToken: z.string().describe('Destination token address or symbol'), |
| 56 | + amount: z.string().describe('Amount of tokens to swap'), |
| 57 | + }), |
| 58 | + }) |
| 59 | + getSwapGuide({ chain, fromToken, toToken, amount }) { |
| 60 | + return { |
| 61 | + description: 'Token swap execution guide', |
| 62 | + messages: [ |
| 63 | + { |
| 64 | + role: 'user', |
| 65 | + content: { |
| 66 | + type: 'text', |
| 67 | + text: `I want to execute a swap from ${fromToken} to ${toToken} on ${chain} for ${amount} tokens.`, |
| 68 | + }, |
| 69 | + }, |
| 70 | + { |
| 71 | + role: 'assistant', |
| 72 | + content: { |
| 73 | + type: 'text', |
| 74 | + text: `I'll guide you through executing a swap from ${fromToken} to ${toToken} on ${chain} for ${amount} tokens. |
| 75 | +
|
| 76 | +**Swap Execution Guide:** |
| 77 | +
|
| 78 | +1. **Route Analysis**: First, let's find the best trading route using the getRoute tool |
| 79 | +2. **Slippage Protection**: Set appropriate slippage tolerance (recommended: 1-3%) |
| 80 | +3. **Gas Estimation**: Ensure you have enough gas for the transaction |
| 81 | +4. **Wallet Security**: Use a secure wallet and never share private keys |
| 82 | +5. **Transaction Confirmation**: Always review transaction details before confirming |
| 83 | +
|
| 84 | +**Safety Tips:** |
| 85 | +- Double-check token addresses |
| 86 | +- Verify the swap amount and expected output |
| 87 | +- Use reputable DEX protocols |
| 88 | +- Consider using a test transaction first |
| 89 | +
|
| 90 | +Let me help you execute this swap safely using the executeSwap tool.`, |
| 91 | + }, |
| 92 | + }, |
| 93 | + ], |
| 94 | + }; |
| 95 | + } |
| 96 | + |
| 97 | + @Prompt({ |
| 98 | + name: 'dex-trading-strategy', |
| 99 | + description: 'DEX trading strategy guide based on market conditions and user preferences', |
| 100 | + parameters: z.object({ |
| 101 | + tradingStyle: z.enum(['conservative', 'moderate', 'aggressive']).describe('Trading style preference'), |
| 102 | + marketCondition: z.enum(['bull', 'bear', 'sideways', 'volatile']).describe('Current market condition'), |
| 103 | + timeHorizon: z.enum(['short-term', 'medium-term', 'long-term']).describe('Investment time horizon'), |
| 104 | + }), |
| 105 | + }) |
| 106 | + getDexTradingStrategy({ tradingStyle, marketCondition, timeHorizon }) { |
| 107 | + const strategies = { |
| 108 | + 'conservative': { |
| 109 | + 'bull': 'Focus on established tokens with high liquidity, use low slippage settings, consider DCA approach.', |
| 110 | + 'bear': 'Reduce position sizes, focus on stablecoins, use limit orders to avoid market impact.', |
| 111 | + 'sideways': 'Range trading with tight stop-losses, focus on high-volume pairs.', |
| 112 | + 'volatile': 'Reduce exposure, use small position sizes, focus on major pairs only.', |
| 113 | + }, |
| 114 | + 'moderate': { |
| 115 | + 'bull': 'Balance between established and emerging tokens, moderate slippage tolerance.', |
| 116 | + 'bear': 'Selective buying opportunities, focus on fundamentally strong projects.', |
| 117 | + 'sideways': 'Swing trading approach, moderate position sizes.', |
| 118 | + 'volatile': 'Increased position monitoring, dynamic slippage adjustment.', |
| 119 | + }, |
| 120 | + 'aggressive': { |
| 121 | + 'bull': 'Higher risk tolerance, explore new tokens, higher slippage tolerance.', |
| 122 | + 'bear': 'Contrarian approach, aggressive accumulation of quality assets.', |
| 123 | + 'sideways': 'Active trading, leverage opportunities in both directions.', |
| 124 | + 'volatile': 'High-frequency trading, dynamic route optimization.', |
| 125 | + }, |
| 126 | + }; |
| 127 | + |
| 128 | + const strategy = strategies[tradingStyle][marketCondition]; |
| 129 | + |
| 130 | + return { |
| 131 | + description: 'DEX trading strategy guide', |
| 132 | + messages: [ |
| 133 | + { |
| 134 | + role: 'user', |
| 135 | + content: { |
| 136 | + type: 'text', |
| 137 | + text: `I want to develop a ${tradingStyle} trading strategy for ${marketCondition} market conditions with ${timeHorizon} time horizon.`, |
| 138 | + }, |
| 139 | + }, |
| 140 | + { |
| 141 | + role: 'assistant', |
| 142 | + content: { |
| 143 | + type: 'text', |
| 144 | + text: `${strategy} |
| 145 | +
|
| 146 | +**Additional Considerations for ${timeHorizon} trading:** |
| 147 | +${timeHorizon === 'short-term' ? '- Focus on technical analysis and quick execution' : ''} |
| 148 | +${timeHorizon === 'medium-term' ? '- Balance technical and fundamental analysis' : ''} |
| 149 | +${timeHorizon === 'long-term' ? '- Emphasize fundamental analysis and project research' : ''} |
| 150 | +
|
| 151 | +Let me help you implement this strategy using the appropriate DEX tools.`, |
| 152 | + }, |
| 153 | + }, |
| 154 | + ], |
| 155 | + }; |
| 156 | + } |
| 157 | +} |
0 commit comments