CenturionDEX
Launch App

Flash Swaps

Last modified:

Flash swaps allow you to withdraw up to the full reserves of any ERC20 token from a CenturionDEX v2 pair and execute arbitrary logic at no upfront cost, provided that by the end of the transaction you either:

Flash swaps eliminate upfront capital requirements and ordering constraints for multi-step transactions involving CenturionDEX.

Examples

Capital-free arbitrage

Arbitrage is a core part of CenturionDEX's design — it keeps pool prices aligned with external markets. Traditionally, only those with sufficient capital can exploit mispricings. Flash swaps remove that barrier.

Suppose buying 1 CTN on CenturionDEX costs 200 DAI (via getAmountIn), while selling 1 CTN on Oasis yields 220 DAI. That's a risk-free 20 DAI profit — but you may not have 200 DAI on hand. With a flash swap, anyone who can pay gas can capture it.

Withdrawing CTN from CenturionDEX

Optimistically withdraw 1 CTN via a flash swap. This is the working capital for the arbitrage. We assume:

For on-chain profit-maximizing calculations against a fixed external price, see ExampleSwapToPrice.sol.

Trade at the external venue

Sell the 1 CTN on Oasis for 220 DAI. Send 200 DAI back to the CenturionDEX pair to cover the flash swap. Keep 20 DAI profit.

Instant leverage

Flash swaps streamline leveraged positions using lending protocols.

Consider a Maker-like system that accepts CTN as collateral and mints DAI at a 150% collateralization ratio. With a 3 CTN principal at 1 CTN / 200 DAI, you can mint 400 DAI. Normally, you'd loop — sell DAI for more CTN, deposit, mint again — burning gas at each iteration.

With a flash swap you can withdraw the full CTN amount upfront. For 2× leverage on 3 CTN: flash-borrow 3 CTN, deposit all 6 CTN into Maker, mint 800 DAI, repay the flash swap (~605 DAI), and keep the remainder as a safety margin.

Developer resources