-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.ts
More file actions
52 lines (49 loc) · 1.39 KB
/
debug.ts
File metadata and controls
52 lines (49 loc) · 1.39 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
/**
* Debug utilities for swap execution failures
* @internal
*/
import { Logger } from './logger'
import type { SwapQuote, FetchQuoteResponse } from './types'
/**
* Context for swap execution debugging
*/
export interface SwapExecutionContext {
quote: SwapQuote | FetchQuoteResponse
address: string
slippage: number
transactionCount: number
middlewareCount: number
groupSize: number
}
/**
* Log detailed context when a swap execution fails
* Only logs when debug level is enabled
*/
export function logSwapExecutionFailure(
context: SwapExecutionContext,
error: unknown,
): void {
Logger.debug('Swap execution failed', {
error: error instanceof Error ? error.message : String(error),
quote: {
fromASAID: context.quote.fromASAID,
toASAID: context.quote.toASAID,
type: context.quote.type,
amount:
'amount' in context.quote ? context.quote.amount.toString() : undefined,
quote: context.quote.quote.toString(),
requiredAppOptIns: context.quote.requiredAppOptIns,
route: context.quote.route?.map((r) => ({
percentage: r.percentage,
path: r.path.map((p) => p.name).join(' → '),
})),
},
swap: {
address: context.address,
slippage: context.slippage,
transactionCount: context.transactionCount,
middlewareCount: context.middlewareCount,
groupSize: context.groupSize,
},
})
}