Building Curve Limit-Order Automation with Web3.py
Summary
The document compares pending orders on decentralized exchanges with custom trading through smart contracts. Aggregators monitor prices and liquidity, then execute qualifying orders, sometimes sharing or retaining any improvement beyond the user's limit price. The article argues that batching can add delay, while a trader's own program can set custom conditions and keep execution surplus. It outlines a Curve sDAI/sUSDe example using Web3.py to query pool quotes, monitor balances, and submit a swap when an estimated profit threshold is met.
The implementation discussion covers RPC access, contract addresses and ABIs, encrypted private-key handling, slippage limits, and transaction monitoring. The stated example estimates profit for a particular investment over a week before gas costs, but provides no broader performance record. The approach requires programming and incurs gas costs; quotes can change before execution, and on-chain transactions carry security, slippage, and MEV risks. The author advises using minimum-output protections, starting with small amounts, and monitoring transactions.
Key ideas
- DEX aggregators can trigger limit orders across venues, but batching and surplus allocation affect execution outcomes.
- A custom smart-contract program can define more complex order conditions and control execution surplus.
- The example monitors a Curve pool quote and submits a swap when its estimated profit clears a threshold.
- Private-key encryption, slippage limits, and minimum-output settings are central operational safeguards.
- Estimated returns exclude gas and do not establish that the strategy will remain profitable.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.