
Dca Limit Exit
DCA with automatic take-profit exit when target price is reached.
CategoryTradingAutomation
ChainsBASE_ETHETH
C
Cobo· Author
191 views·33 uses
Overview
DCA with automatic take-profit exit when target price is reached.
Facts
•swap: use
uniswap-v3-swap recipe for each buy and the final sell•price oracle: query pool price via
slot0() or use off-chain price feed (e.g., Chainlink, CoinGecko)•target_price: user-configured take-profit threshold (e.g., bought ETH at avg $2500, sell at $3000)
•exit mode: full position sell via
exactInputSingle when target_price reachedTypical Flows
DCA phase — same as `dca-order-executor`:
1.Configure:
{token_in, token_out, total_amount, num_orders, interval, target_price}2.Execute split buy orders at each interval
3.Track:
{total_spent, total_acquired, avg_price}Limit exit phase — 1 price check per interval + 2 tx on trigger:
4.At each interval, fetch current market price
5.If
current_price >= target_price: - approve(router, total_acquired) on acquired token
- exactInputSingle({tokenIn: acquired, tokenOut: quote, ...}) — sell entire position
6.Log:
{exit_price, total_pnl, num_orders_executed}Policy Controls
•Price feed reliability: Use multiple sources; stale or manipulated price data can trigger premature exit.
•Slippage on exit: Full position sell may cause significant price impact; consider splitting exit for large positions.
•Target may never be reached: DCA continues until
num_orders exhausted; unreached target leaves position open.•Gas cost on exit: Exit trade incurs additional gas; factor into P&L calculation.
•Policy denial: Exit sell must also fit within per-tx and rolling_24h limits; large positions may require split exits.
•Partial DCA completion: If target is reached before all orders execute, remaining orders should be cancelled.
•Not applicable for: single one-time swaps — use
uniswap-v3-swap directly; testnet chains — underlying swap recipe targets mainnet deployments•Partial reference: use web search for unlisted tokens, contracts, parameters, or up-to-date addresses
References
•Docs:
https://developers.uniswap.org/llms.mdx — SwapRouter02 ABI, exactInputSingle params, fee tiers, path encoding.•ABI:
https://cdn.jsdelivr.net/npm/@uniswap/swap-router-contracts/artifacts/contracts/SwapRouter02.sol/SwapRouter02.json — SwapRouter02 full ABI (exactInputSingle/exactInput/multicall), function signatures and struct params.•Docs (Oracle):
https://docs.chain.link/llms.txt — Chainlink Data Feeds, latestRoundData ABI, price feed contract addresses per chain.