@shogun-sdk/swap 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +274 -0
- package/dist/esm/client/SwapClient.js +351 -0
- package/dist/esm/client/SwapClient.js.map +1 -0
- package/dist/esm/examples/usage.js +239 -0
- package/dist/esm/examples/usage.js.map +1 -0
- package/dist/esm/index.js +11 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/index.js +5 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/utils/index.js +60 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/client/SwapClient.d.ts +159 -0
- package/dist/types/client/SwapClient.d.ts.map +1 -0
- package/dist/types/examples/usage.d.ts +17 -0
- package/dist/types/examples/usage.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +34 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +27 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +58 -0
- package/src/client/SwapClient.ts +490 -0
- package/src/examples/usage.ts +261 -0
- package/src/index.ts +12 -0
- package/src/types/index.ts +36 -0
- package/src/utils/index.ts +77 -0
package/README.md
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
# @shogun-sdk/swap
|
|
2
|
+
|
|
3
|
+
A comprehensive swap SDK for the Shogun Network that provides unified quote fetching across multiple chains and protocols with intelligent fallback mechanisms.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔄 **Unified Quote Interface** - Single API for quotes across all supported chains
|
|
8
|
+
- 🎯 **Intelligent Fallback** - Automatically falls back from intents-sdk to one-shot API
|
|
9
|
+
- ⛓️ **Multi-Chain Support** - Ethereum, Arbitrum, Polygon, Solana, Sui, Hyperliquid, and more
|
|
10
|
+
- 🛡️ **Type Safety** - Full TypeScript support with comprehensive type definitions
|
|
11
|
+
- ⚡ **Performance Optimized** - Built for both frontend and backend applications
|
|
12
|
+
- 🔧 **Flexible Configuration** - Customizable timeouts, slippage, and routing options
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @shogun-sdk/swap
|
|
18
|
+
pnpm install @shogun-sdk/swap
|
|
19
|
+
yarn add @shogun-sdk/swap
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### Basic Usage
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { SwapClient, ChainID } from "@shogun-sdk/swap";
|
|
28
|
+
|
|
29
|
+
// Initialize the client
|
|
30
|
+
const swapClient = new SwapClient({
|
|
31
|
+
apiKey: 'your-api-key',
|
|
32
|
+
apiUrl: 'https://api.shogun.network',
|
|
33
|
+
timeout: 30000
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Get a cross-chain quote
|
|
37
|
+
const quote = await swapClient.getQuote({
|
|
38
|
+
sourceChainId: ChainID.Ethereum,
|
|
39
|
+
destChainId: ChainID.Arbitrum,
|
|
40
|
+
tokenIn: '0xA0b86a33E6441b8c4C8C0C4C0C4C0C4C0C4C0C4C', // USDC
|
|
41
|
+
tokenOut: '0x1234567890123456789012345678901234567890', // Target token
|
|
42
|
+
amount: BigInt('1000000'), // 1 USDC (6 decimals)
|
|
43
|
+
senderAddress: '0x...',
|
|
44
|
+
destinationAddress: '0x...',
|
|
45
|
+
slippageBps: 50 // 0.5% slippage
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
console.log('Expected output:', quote.amountOut.toString());
|
|
49
|
+
console.log('Quote source:', quote.source); // 'intents-sdk' or 'one-shot'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Single-Chain Swaps
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
// Get a quote for same-chain swap
|
|
56
|
+
const singleChainQuote = await swapClient.getSingleChainQuote(
|
|
57
|
+
ChainID.Ethereum,
|
|
58
|
+
'0xA0b86a33E6441b8c4C8C0C4C0C4C0C4C0C4C0C4C', // USDC
|
|
59
|
+
'0x1234567890123456789012345678901234567890', // Target token
|
|
60
|
+
BigInt('1000000'), // 1 USDC
|
|
61
|
+
50 // 0.5% slippage
|
|
62
|
+
);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Solana Swaps with Jito Tips
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
const solanaQuote = await swapClient.getQuote({
|
|
69
|
+
sourceChainId: ChainID.Solana,
|
|
70
|
+
destChainId: ChainID.Solana,
|
|
71
|
+
tokenIn: 'So11111111111111111111111111111111111111112', // SOL
|
|
72
|
+
tokenOut: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
|
|
73
|
+
amount: BigInt('1000000000'), // 1 SOL
|
|
74
|
+
jitoTip: 1000000, // 0.001 SOL tip
|
|
75
|
+
slippageBps: 100 // 1% slippage
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Advanced Usage
|
|
80
|
+
|
|
81
|
+
### Error Handling and Fallback
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
try {
|
|
85
|
+
const quote = await swapClient.getQuote(params);
|
|
86
|
+
|
|
87
|
+
if (quote.error) {
|
|
88
|
+
console.warn('Quote error:', quote.error);
|
|
89
|
+
// Handle error case
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (quote.amountOut > 0n) {
|
|
93
|
+
console.log('Valid quote from:', quote.source);
|
|
94
|
+
// Proceed with swap
|
|
95
|
+
}
|
|
96
|
+
} catch (error) {
|
|
97
|
+
console.error('Failed to get quote:', error);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Request Timeout Control
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const controller = new AbortController();
|
|
105
|
+
const timeoutId = setTimeout(() => controller.abort(), 10000); // 10s timeout
|
|
106
|
+
|
|
107
|
+
try {
|
|
108
|
+
const quote = await swapClient.getQuote(params, controller.signal);
|
|
109
|
+
clearTimeout(timeoutId);
|
|
110
|
+
} catch (error) {
|
|
111
|
+
clearTimeout(timeoutId);
|
|
112
|
+
if (error.name === 'AbortError') {
|
|
113
|
+
console.error('Request timed out');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Utility Functions
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import {
|
|
122
|
+
validateSwapParams,
|
|
123
|
+
calculatePriceImpact,
|
|
124
|
+
formatTokenAmount,
|
|
125
|
+
type SwapParams
|
|
126
|
+
} from "@shogun-sdk/swap";
|
|
127
|
+
|
|
128
|
+
// Validate swap parameters
|
|
129
|
+
const swapParams: SwapParams = {
|
|
130
|
+
tokenIn: '0x...',
|
|
131
|
+
tokenOut: '0x...',
|
|
132
|
+
amountIn: BigInt(1000000),
|
|
133
|
+
amountOutMin: BigInt(900000),
|
|
134
|
+
to: '0x...',
|
|
135
|
+
deadline: Math.floor(Date.now() / 1000) + 3600
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
validateSwapParams(swapParams);
|
|
139
|
+
|
|
140
|
+
// Calculate price impact
|
|
141
|
+
const priceImpact = calculatePriceImpact(
|
|
142
|
+
BigInt(1000000), // amountIn
|
|
143
|
+
BigInt(990000), // amountOut
|
|
144
|
+
1.0, // tokenInPrice
|
|
145
|
+
1.0 // tokenOutPrice
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
// Format token amounts
|
|
149
|
+
const formattedAmount = formatTokenAmount(BigInt(1000000), 6); // "1.0"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## API Reference
|
|
153
|
+
|
|
154
|
+
### SwapClient
|
|
155
|
+
|
|
156
|
+
The main client class for fetching quotes.
|
|
157
|
+
|
|
158
|
+
#### Constructor
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
new SwapClient(config: SwapClientConfig)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
**Config Options:**
|
|
165
|
+
- `apiKey: string` - API key for one-shot service
|
|
166
|
+
- `apiUrl: string` - API URL for one-shot service
|
|
167
|
+
- `timeout?: number` - Request timeout in milliseconds (optional)
|
|
168
|
+
|
|
169
|
+
#### Methods
|
|
170
|
+
|
|
171
|
+
##### `getQuote(params, signal?)`
|
|
172
|
+
|
|
173
|
+
Fetches a quote with intelligent fallback logic.
|
|
174
|
+
|
|
175
|
+
**Parameters:**
|
|
176
|
+
- `params: UnifiedQuoteParams` - Quote parameters
|
|
177
|
+
- `signal?: AbortSignal` - Optional abort signal for cancellation
|
|
178
|
+
|
|
179
|
+
**Returns:** `Promise<UnifiedQuoteResponse>`
|
|
180
|
+
|
|
181
|
+
##### `getSingleChainQuote(chainId, tokenIn, tokenOut, amount, slippageBps?, signal?)`
|
|
182
|
+
|
|
183
|
+
Gets a quote for same-chain swaps.
|
|
184
|
+
|
|
185
|
+
**Parameters:**
|
|
186
|
+
- `chainId: ChainID` - Chain identifier
|
|
187
|
+
- `tokenIn: string` - Input token address
|
|
188
|
+
- `tokenOut: string` - Output token address
|
|
189
|
+
- `amount: bigint` - Amount to swap
|
|
190
|
+
- `slippageBps?: number` - Slippage in basis points (optional)
|
|
191
|
+
- `signal?: AbortSignal` - Optional abort signal (optional)
|
|
192
|
+
|
|
193
|
+
**Returns:** `Promise<UnifiedQuoteResponse>`
|
|
194
|
+
|
|
195
|
+
### Types
|
|
196
|
+
|
|
197
|
+
#### `UnifiedQuoteParams`
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
interface UnifiedQuoteParams {
|
|
201
|
+
sourceChainId: ChainID;
|
|
202
|
+
destChainId: ChainID;
|
|
203
|
+
tokenIn: string;
|
|
204
|
+
tokenOut: string;
|
|
205
|
+
amount: bigint;
|
|
206
|
+
senderAddress?: string;
|
|
207
|
+
destinationAddress?: string;
|
|
208
|
+
slippageBps?: number;
|
|
209
|
+
affiliateWallet?: string;
|
|
210
|
+
affiliateFee?: string;
|
|
211
|
+
jitoTip?: number;
|
|
212
|
+
gasRefuel?: number;
|
|
213
|
+
dynamicSlippage?: boolean;
|
|
214
|
+
externalCall?: string;
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### `UnifiedQuoteResponse`
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
interface UnifiedQuoteResponse {
|
|
222
|
+
amountOut: bigint;
|
|
223
|
+
amountInUsd: number;
|
|
224
|
+
amountOutUsd: number;
|
|
225
|
+
amountOutReduced?: bigint;
|
|
226
|
+
amountOutUsdReduced?: number;
|
|
227
|
+
estimatedAmountInAsMinStablecoinAmount?: bigint;
|
|
228
|
+
priceImpact: number;
|
|
229
|
+
slippage: number;
|
|
230
|
+
provider: string;
|
|
231
|
+
rawQuote: any;
|
|
232
|
+
source: 'intents-sdk' | 'one-shot';
|
|
233
|
+
error?: string;
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Utility Functions
|
|
238
|
+
|
|
239
|
+
- `validateSwapParams(params: SwapParams): void` - Validate swap parameters
|
|
240
|
+
- `calculatePriceImpact(amountIn, amountOut, tokenInPrice, tokenOutPrice): number` - Calculate price impact percentage
|
|
241
|
+
- `formatTokenAmount(amount: bigint, decimals: number): string` - Format token amounts for display
|
|
242
|
+
|
|
243
|
+
## Supported Chains
|
|
244
|
+
|
|
245
|
+
- **Ethereum**
|
|
246
|
+
- **Arbitrum**
|
|
247
|
+
- **Polygon**
|
|
248
|
+
- **Solana**
|
|
249
|
+
- **Sui**
|
|
250
|
+
- **Hyperliquid**
|
|
251
|
+
- **Base**
|
|
252
|
+
- **BSC**
|
|
253
|
+
|
|
254
|
+
## Quote Sources
|
|
255
|
+
|
|
256
|
+
The SDK uses a two-tier approach for quote fetching:
|
|
257
|
+
|
|
258
|
+
1. **Primary: Intents SDK** - Fast, local quote calculation using integrated DEX aggregators
|
|
259
|
+
2. **Fallback: One-Shot API** - Comprehensive quote service with additional routing options
|
|
260
|
+
|
|
261
|
+
This ensures maximum reliability and the best possible quotes for your swaps.
|
|
262
|
+
|
|
263
|
+
## Error Handling
|
|
264
|
+
|
|
265
|
+
The SDK provides comprehensive error handling:
|
|
266
|
+
|
|
267
|
+
- **Network Errors** - Automatic retry with fallback
|
|
268
|
+
- **Invalid Parameters** - Clear validation error messages
|
|
269
|
+
- **Timeout Handling** - Configurable request timeouts
|
|
270
|
+
- **Quote Errors** - Detailed error information in response
|
|
271
|
+
|
|
272
|
+
## License
|
|
273
|
+
|
|
274
|
+
ISC
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SwapClient - Unified client for fetching quotes from multiple sources
|
|
3
|
+
*
|
|
4
|
+
* This client combines the QuoteProvider from intents-sdk and the OneShotClient
|
|
5
|
+
* from money-legos to provide a unified interface for quote fetching with fallback logic.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Intelligent fallback from intents-sdk to one-shot API
|
|
9
|
+
* - Comprehensive error handling and retry logic
|
|
10
|
+
* - Support for all major chains and protocols
|
|
11
|
+
* - Built-in validation and type safety
|
|
12
|
+
* - Configurable timeouts and retry policies
|
|
13
|
+
*/
|
|
14
|
+
import { QuoteProvider } from '@shogun-sdk/intents-sdk';
|
|
15
|
+
import { compareAddresses, fetchQuote } from '@shogun-sdk/money-legos';
|
|
16
|
+
export class SwapClient {
|
|
17
|
+
constructor(config) {
|
|
18
|
+
Object.defineProperty(this, "config", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: void 0
|
|
23
|
+
});
|
|
24
|
+
this.config = {
|
|
25
|
+
timeout: 30000,
|
|
26
|
+
maxRetries: 3,
|
|
27
|
+
retryDelay: 1000,
|
|
28
|
+
debug: false,
|
|
29
|
+
headers: {},
|
|
30
|
+
preferIntentsSdk: true,
|
|
31
|
+
...config,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validates the client configuration
|
|
36
|
+
*/
|
|
37
|
+
validateConfig() {
|
|
38
|
+
if (!this.config.apiKey) {
|
|
39
|
+
throw new Error('API key is required');
|
|
40
|
+
}
|
|
41
|
+
if (!this.config.apiUrl) {
|
|
42
|
+
throw new Error('API URL is required');
|
|
43
|
+
}
|
|
44
|
+
if (this.config.timeout <= 0) {
|
|
45
|
+
throw new Error('Timeout must be greater than 0');
|
|
46
|
+
}
|
|
47
|
+
if (this.config.maxRetries < 0) {
|
|
48
|
+
throw new Error('Max retries cannot be negative');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Logs debug messages if debug mode is enabled
|
|
53
|
+
*/
|
|
54
|
+
debug(message, data) {
|
|
55
|
+
if (this.config.debug) {
|
|
56
|
+
console.log(`[SwapClient] ${message}`, data || '');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sleeps for the specified number of milliseconds
|
|
61
|
+
*/
|
|
62
|
+
sleep(ms) {
|
|
63
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Validates quote parameters
|
|
67
|
+
*/
|
|
68
|
+
validateQuoteParams(params) {
|
|
69
|
+
if (!params.sourceChainId || !params.destChainId) {
|
|
70
|
+
throw new Error('Source and destination chain IDs are required');
|
|
71
|
+
}
|
|
72
|
+
if (!params.tokenIn || !params.tokenOut) {
|
|
73
|
+
throw new Error('Token addresses are required');
|
|
74
|
+
}
|
|
75
|
+
if (params.amount <= 0n) {
|
|
76
|
+
throw new Error('Amount must be greater than 0');
|
|
77
|
+
}
|
|
78
|
+
if (compareAddresses(params.tokenIn, params.tokenOut) && params.sourceChainId === params.destChainId) {
|
|
79
|
+
throw new Error('Input and output tokens cannot be the same');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Fetches a quote using the unified interface
|
|
84
|
+
* First tries intents-sdk QuoteProvider, then falls back to one-shot API
|
|
85
|
+
*
|
|
86
|
+
* @param params Quote parameters
|
|
87
|
+
* @param signal Optional AbortSignal for cancelling the request
|
|
88
|
+
* @returns Promise<UnifiedQuoteResponse>
|
|
89
|
+
*/
|
|
90
|
+
async getQuote(params, signal) {
|
|
91
|
+
this.validateConfig();
|
|
92
|
+
this.validateQuoteParams(params);
|
|
93
|
+
this.debug('Fetching quote', { params });
|
|
94
|
+
// Determine quote source order based on configuration
|
|
95
|
+
const sources = this.config.preferIntentsSdk
|
|
96
|
+
? ['intents-sdk', 'one-shot']
|
|
97
|
+
: ['one-shot', 'intents-sdk'];
|
|
98
|
+
for (const source of sources) {
|
|
99
|
+
for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
|
|
100
|
+
try {
|
|
101
|
+
this.debug(`Attempting quote from ${source} (attempt ${attempt + 1})`);
|
|
102
|
+
let quote;
|
|
103
|
+
if (source === 'intents-sdk') {
|
|
104
|
+
quote = await this.getIntentsQuote(params, signal);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
quote = await this.getOneShotQuote(params, signal);
|
|
108
|
+
}
|
|
109
|
+
if (quote && !quote.error && quote.amountOut > 0n) {
|
|
110
|
+
this.debug(`Successfully got quote from ${source}`, { amountOut: quote.amountOut.toString() });
|
|
111
|
+
return quote;
|
|
112
|
+
}
|
|
113
|
+
if (attempt < this.config.maxRetries) {
|
|
114
|
+
this.debug(`Quote attempt ${attempt + 1} failed, retrying in ${this.config.retryDelay}ms`);
|
|
115
|
+
await this.sleep(this.config.retryDelay);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
this.debug(`Quote attempt ${attempt + 1} from ${source} failed`, error);
|
|
120
|
+
if (attempt < this.config.maxRetries) {
|
|
121
|
+
await this.sleep(this.config.retryDelay);
|
|
122
|
+
}
|
|
123
|
+
else if (source === sources[sources.length - 1]) {
|
|
124
|
+
// Last source and last attempt
|
|
125
|
+
return {
|
|
126
|
+
amountOut: 0n,
|
|
127
|
+
amountInUsd: 0,
|
|
128
|
+
amountOutUsd: 0,
|
|
129
|
+
priceImpact: 0,
|
|
130
|
+
slippage: 0,
|
|
131
|
+
provider: 'none',
|
|
132
|
+
rawQuote: null,
|
|
133
|
+
source: source,
|
|
134
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// This should never be reached, but just in case
|
|
141
|
+
return {
|
|
142
|
+
amountOut: 0n,
|
|
143
|
+
amountInUsd: 0,
|
|
144
|
+
amountOutUsd: 0,
|
|
145
|
+
priceImpact: 0,
|
|
146
|
+
slippage: 0,
|
|
147
|
+
provider: 'none',
|
|
148
|
+
rawQuote: null,
|
|
149
|
+
source: 'one-shot',
|
|
150
|
+
error: 'All quote sources failed'
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Gets quote from intents-sdk QuoteProvider
|
|
155
|
+
*/
|
|
156
|
+
async getIntentsQuote(params, _signal) {
|
|
157
|
+
const intentsParams = {
|
|
158
|
+
sourceChainId: params.sourceChainId,
|
|
159
|
+
destChainId: params.destChainId,
|
|
160
|
+
amount: params.amount,
|
|
161
|
+
tokenIn: params.tokenIn,
|
|
162
|
+
tokenOut: params.tokenOut,
|
|
163
|
+
};
|
|
164
|
+
const quote = await QuoteProvider.getQuote(intentsParams);
|
|
165
|
+
return {
|
|
166
|
+
amountOut: quote.estimatedAmountOut,
|
|
167
|
+
amountInUsd: quote.amountInUsd,
|
|
168
|
+
amountOutUsd: quote.estimatedAmountOutUsd,
|
|
169
|
+
amountOutReduced: quote.estimatedAmountOutReduced,
|
|
170
|
+
amountOutUsdReduced: quote.estimatedAmountOutUsdReduced,
|
|
171
|
+
estimatedAmountInAsMinStablecoinAmount: quote.estimatedAmountInAsMinStablecoinAmount,
|
|
172
|
+
priceImpact: 0, // QuoteProvider doesn't provide price impact directly
|
|
173
|
+
slippage: 0, // QuoteProvider doesn't provide slippage directly
|
|
174
|
+
provider: 'intents-sdk',
|
|
175
|
+
rawQuote: quote,
|
|
176
|
+
source: 'intents-sdk'
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Gets quote from one-shot API
|
|
181
|
+
*/
|
|
182
|
+
async getOneShotQuote(params, signal) {
|
|
183
|
+
const oneShotParams = {
|
|
184
|
+
srcChain: params.sourceChainId,
|
|
185
|
+
destChain: params.destChainId,
|
|
186
|
+
srcToken: params.tokenIn,
|
|
187
|
+
destToken: params.tokenOut,
|
|
188
|
+
amount: params.amount.toString(),
|
|
189
|
+
senderAddress: params.senderAddress || '',
|
|
190
|
+
affiliateWallet: params.affiliateWallet || '',
|
|
191
|
+
affiliateFee: params.affiliateFee || '0',
|
|
192
|
+
slippage: params.slippageBps ? params.slippageBps / 100 : 0.5, // Convert bps to percentage
|
|
193
|
+
destinationAddress: params.destinationAddress || '',
|
|
194
|
+
dstChainOrderAuthorityAddress: '',
|
|
195
|
+
jitoTip: params.jitoTip,
|
|
196
|
+
gasRefuel: params.gasRefuel,
|
|
197
|
+
dynamicSlippage: params.dynamicSlippage,
|
|
198
|
+
externalCall: params.externalCall,
|
|
199
|
+
};
|
|
200
|
+
const quote = await fetchQuote({
|
|
201
|
+
key: this.config.apiKey,
|
|
202
|
+
url: this.config.apiUrl,
|
|
203
|
+
}, oneShotParams, signal || new AbortController().signal);
|
|
204
|
+
if (quote.error) {
|
|
205
|
+
throw new Error(quote.error);
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
amountOut: BigInt(quote.outputAmount.value),
|
|
209
|
+
amountInUsd: 0, // One-shot doesn't provide USD values directly
|
|
210
|
+
amountOutUsd: 0,
|
|
211
|
+
priceImpact: 0, // One-shot doesn't provide price impact directly
|
|
212
|
+
slippage: oneShotParams.slippage,
|
|
213
|
+
provider: 'one-shot',
|
|
214
|
+
rawQuote: quote,
|
|
215
|
+
source: 'one-shot'
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Gets a single-chain quote from intents-sdk
|
|
220
|
+
* Useful for same-chain swaps
|
|
221
|
+
*/
|
|
222
|
+
async getSingleChainQuote(chainId, tokenIn, tokenOut, amount, slippageBps, _signal) {
|
|
223
|
+
this.validateConfig();
|
|
224
|
+
if (!chainId || !tokenIn || !tokenOut || amount <= 0n) {
|
|
225
|
+
throw new Error('Invalid parameters for single-chain quote');
|
|
226
|
+
}
|
|
227
|
+
this.debug('Fetching single-chain quote', { chainId, tokenIn, tokenOut, amount: amount.toString() });
|
|
228
|
+
try {
|
|
229
|
+
const quote = await QuoteProvider.getSingleChainQuote({
|
|
230
|
+
chainId,
|
|
231
|
+
amount,
|
|
232
|
+
tokenIn,
|
|
233
|
+
tokenOut,
|
|
234
|
+
slippageBps,
|
|
235
|
+
});
|
|
236
|
+
this.debug('Single-chain quote successful', { amountOut: quote.amountOut.toString() });
|
|
237
|
+
return {
|
|
238
|
+
amountOut: quote.amountOut,
|
|
239
|
+
amountInUsd: quote.amountInUsd,
|
|
240
|
+
amountOutUsd: quote.amountOutUsd,
|
|
241
|
+
priceImpact: quote.priceImpact,
|
|
242
|
+
slippage: quote.slippage,
|
|
243
|
+
provider: quote.provider,
|
|
244
|
+
rawQuote: quote.rawQuote,
|
|
245
|
+
source: 'intents-sdk'
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
catch (error) {
|
|
249
|
+
this.debug('Single-chain quote failed', error);
|
|
250
|
+
return {
|
|
251
|
+
amountOut: 0n,
|
|
252
|
+
amountInUsd: 0,
|
|
253
|
+
amountOutUsd: 0,
|
|
254
|
+
priceImpact: 0,
|
|
255
|
+
slippage: 0,
|
|
256
|
+
provider: 'none',
|
|
257
|
+
rawQuote: null,
|
|
258
|
+
source: 'intents-sdk',
|
|
259
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred'
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Gets multiple quotes for comparison
|
|
265
|
+
* Useful for finding the best route
|
|
266
|
+
*/
|
|
267
|
+
async getMultipleQuotes(params, signal) {
|
|
268
|
+
this.debug('Fetching multiple quotes', { count: params.length });
|
|
269
|
+
const promises = params.map(param => this.getQuote(param, signal));
|
|
270
|
+
const results = await Promise.allSettled(promises);
|
|
271
|
+
return results.map((result) => {
|
|
272
|
+
if (result.status === 'fulfilled') {
|
|
273
|
+
return result.value;
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
return {
|
|
277
|
+
amountOut: 0n,
|
|
278
|
+
amountInUsd: 0,
|
|
279
|
+
amountOutUsd: 0,
|
|
280
|
+
priceImpact: 0,
|
|
281
|
+
slippage: 0,
|
|
282
|
+
provider: 'none',
|
|
283
|
+
rawQuote: null,
|
|
284
|
+
source: 'one-shot',
|
|
285
|
+
error: result.reason instanceof Error ? result.reason.message : 'Unknown error occurred'
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Gets the best quote from multiple options
|
|
292
|
+
*/
|
|
293
|
+
async getBestQuote(params, signal) {
|
|
294
|
+
const quotes = await this.getMultipleQuotes(params, signal);
|
|
295
|
+
const validQuotes = quotes.filter(quote => !quote.error && quote.amountOut > 0n);
|
|
296
|
+
if (validQuotes.length === 0) {
|
|
297
|
+
return null;
|
|
298
|
+
}
|
|
299
|
+
// Return the quote with the highest output amount
|
|
300
|
+
return validQuotes.reduce((best, current) => current.amountOut > best.amountOut ? current : best);
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Estimates gas costs for a swap (EVM chains only)
|
|
304
|
+
*/
|
|
305
|
+
async estimateGas(chainId, tokenIn, tokenOut, amount, _userAddress) {
|
|
306
|
+
this.debug('Estimating gas', { chainId, tokenIn, tokenOut, amount: amount.toString() });
|
|
307
|
+
try {
|
|
308
|
+
// This would need to be implemented based on your specific needs
|
|
309
|
+
// For now, return a placeholder
|
|
310
|
+
return {
|
|
311
|
+
gasEstimate: 200000n, // Typical swap gas limit
|
|
312
|
+
gasPrice: 20000000000n // 20 gwei
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
this.debug('Gas estimation failed', error);
|
|
317
|
+
return null;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Validates if a token pair is supported for swapping
|
|
322
|
+
*/
|
|
323
|
+
async isTokenPairSupported(chainId, tokenIn, tokenOut) {
|
|
324
|
+
try {
|
|
325
|
+
// Try to get a minimal quote to check if the pair is supported
|
|
326
|
+
const quote = await this.getSingleChainQuote(chainId, tokenIn, tokenOut, BigInt('1'), // Minimal amount
|
|
327
|
+
1000 // 10% slippage for validation
|
|
328
|
+
);
|
|
329
|
+
return !quote.error && quote.amountOut > 0n;
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
this.debug('Token pair validation failed', error);
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Updates the client configuration
|
|
338
|
+
*/
|
|
339
|
+
updateConfig(newConfig) {
|
|
340
|
+
Object.assign(this.config, newConfig);
|
|
341
|
+
this.validateConfig();
|
|
342
|
+
this.debug('Configuration updated', newConfig);
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* Gets the current configuration
|
|
346
|
+
*/
|
|
347
|
+
getConfig() {
|
|
348
|
+
return { ...this.config };
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
//# sourceMappingURL=SwapClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwapClient.js","sourceRoot":"","sources":["../../../src/client/SwapClient.ts"],"names":[],"mappings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