Dex integration security

From PlamenTSV/plamen · View interactive version

Dex integration security is an AI agent skill from the GitHub repository PlamenTSV/plamen. Protocol Type Trigger dex_integration (detected when recon finds swap|addLiquidity|removeLiquidity|IUniswapV2Router|ISwapRouter|amountOutMin|amountOutMinimum|slippage - AND the...

How to use this skill

Skill file

Injectable Skill: DEX Integration Security

Protocol Type Trigger: dex_integration (detected when recon finds: swap|addLiquidity|removeLiquidity|IUniswapV2Router|ISwapRouter|amountOutMin|amountOutMinimum|slippage - AND the protocol is NOT itself a DEX implementation)

Inject Into: Breadth agents, depth-external, depth-edge-case

Language: Primarily EVM; applicable to Sui PTB-based DEX interactions and Soroban DEX integrations (SoroSwap, Phoenix Protocol)

Finding prefix: [DEX-N]

Orchestrator Decomposition Guide

When decomposing this skill into depth agent investigation questions, map sections to domains:

When This Skill Activates

Recon detects DEX integration patterns: swap, addLiquidity, removeLiquidity, IUniswapV2Router, ISwapRouter, amountOutMin, amountOutMinimum, slippage, exactInputSingle, exactInput, swapExactTokensForTokens - but the protocol itself is NOT a DEX/AMM implementation. This skill analyzes the CALLER's integration with an external DEX, not the DEX internals.


1. Slippage Parameter Analysis

For each function that calls a DEX swap:

1a. Parameter Origin

1b. Parameter Forwarding

1c. Multi-Hop and Multi-Swap

Tag: [TRACE:swap_call → amountOutMin_source={user/computed/hardcoded} → value_can_be_zero={YES/NO} → forwarded_through={functions}]


2. Deadline Enforcement

For each function that calls a DEX router:

2a. Deadline Value

2b. Queued or Delayed Swaps

2c. L2 Considerations

Tag: [TRACE:router_call → deadline={value_or_source} → block.timestamp_used={YES/NO} → queue_delay_considered={YES/NO}]


3. Return Value Handling

For each DEX call that returns swap output amounts:

3a. Actual vs Expected

3b. Multi-Output Validation

3c. Failure Handling

Tag: [TRACE:swap_return → checked={YES/NO} → fee_on_transfer_aware={YES/NO} → revert_handling={propagate/catch/ignore}]


4. Fee Tier and Pool Assumptions

4a. Hardcoded Pool or Fee Tier

4b. Pool Liquidity Assumptions

Tag: [TRACE:pool_selection → hardcoded={YES/NO} → fee_tier={value} → pool_verified={YES/NO} → liquidity_assumption={documented/implicit}]


5. Router Approval Safety

5a. Approval Scope

5b. Router Mutability

5c. Permit Usage

Tag: [TRACE:approval → scope={unlimited/exact} → router_upgradeable={YES/NO} → stale_revoked={YES/NO}]


Common False Positives

Step Execution Checklist (MANDATORY)

| Section | Required | Completed? | Notes |

|---------|----------|------------|-------|

| 1. Slippage Parameter Analysis | YES | | Origin, forwarding, multi-hop |

| 2. Deadline Enforcement | YES | | Value, queue delay, L2 |

| 3. Return Value Handling | YES | | Actual vs expected, fee-on-transfer |

| 4. Fee Tier and Pool Assumptions | IF hardcoded pool/fee tier | | Pool verification, liquidity |

| 5. Router Approval Safety | IF protocol approves router | | Scope, mutability, stale approvals |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.