DeFi & DEX
Superhero embeds a full automated market maker at /defi. Swap any pair that has a pool,
provide liquidity and earn fees, wrap AE into its AEX-9 form, and browse every token, pool and
transaction on the exchange.
The DEX is a different market from the bonding curve that community tokens trade on. The two prices for the same token are independent, and nothing arbitrages them automatically.
The DEX and the bonding curve
| Bonding curve (community tokens) | DEX (AMM) | |
|---|---|---|
| Where | /trends/tokens/... | /defi/swap |
| What sets the price | A fixed exponential formula on supply | The ratio of two pool reserves |
| Buying | Tokens are minted against the curve | Tokens are bought from a pool; nothing is minted |
| Selling | Tokens are burned back to the curve | Tokens go into the pool |
| Counterparty | The curve contract's reserve | Other liquidity providers |
| Contracts | AffiliationBondingCurveTokenSale, BondingCurveExponential | AedexV2Router, AedexV2Factory, AedexV2Pair |
| Fee | 1% spread, split 0.5% DAO and 0.5% affiliation | 0.3% per swap, to liquidity providers |
| Can it run out of liquidity | No: the reserve always covers the full supply | Yes: a thin pool gives poor prices or no route |
| Main risk | Price falls back down the curve | Price impact, no route, and impermanent loss if you provide liquidity |
The curve can always buy back its entire supply. A liquidity pool makes no such promise: if the liquidity providers leave, there is no price to sell at.
Routes
| Route | What it does |
|---|---|
/defi | Redirects to /defi/swap |
/defi/swap | The swap form, a candlestick chart for the selected pair, and recent activity |
/defi/pool | Your liquidity positions, plus the add and remove forms |
/defi/pool/add-tokens | Add-liquidity flow for a pair you pick |
/defi/wrap | Wrap AE into WAE and unwrap it back |
/defi/explore/tokens | Every token the DEX indexes |
/defi/explore/tokens/<address> | One token's detail page |
/defi/explore/pools | Every pair |
/defi/explore/pools/<address> | One pool's detail page |
/defi/explore/transactions | Filterable feed of every DEX transaction |
/defi/bridge | Disabled: redirects to /defi/swap |
/defi/buy-ae-with-eth | Disabled: redirects to /defi/swap |
/swap, /pool, /explore and /pool/add-tokens still resolve as legacy paths.
Contract addresses
| Contract | Mainnet | Testnet |
|---|---|---|
| Router | ct_azbNZ1XrPjXfqBqbAh1ffLNTQ1sbnuUDFvJrXjYz7JQA1saQ3 | ct_MLXQEP12MBn99HL6WDaiTqDbG4bJQ3Q9Bzr57oLfvEkghvpFb |
| Factory | ct_2mfj3FoZxnhkSw5RZMcP8BfPoB1QR4QiYGNCdkAvLZ1zfF6paW | ct_NhbxN8wg8NLkGuzwRNDQhMDKSKBwDAQgxQawK7tkigi2aC7i9 |
| WAE | ct_J3zBY8xxjsRr3QojETNw48Eb38fjvEuJKkQ6KzECvubvEcvCa | ct_JDp175ruWd7mQggeHewSLS1PFXt9AzThCDaFedxon8mF8xTRF |
| aeETH | ct_ryTY1mxqjCjq1yBn9i6HDaCSdA6thXUFZTA84EMzbWd1SLKdh | ct_WVqAvLQpvZCgBg4faZLXA1YBj43Fxj91D33Z8K7pFsY8YCofv |
At startup the app asks the router for its own factory() address and uses the configured
factory only as a fallback.
The app also reads a DEX indexer alongside the chain:
| Network | DEX backend |
|---|---|
| Mainnet | https://dex-backend-mainnet.prd.service.aepps.com |
| Testnet | https://dex-backend-testnet.prd.service.aepps.com |
In this section
- Swapping: the swap form, how a route is chosen, the router entrypoints behind each swap shape, and what slippage and deadline do.
- Liquidity Pools: adding and removing liquidity, LP tokens, the protocol-fee switch, and impermanent loss with a worked example.
- Wrapped AE: why native AE cannot be a pool reserve, and the wrap and unwrap calls.
- Bridging from Ethereum: the in-app bridge is currently disabled.
- Exploring the DEX: the three explore views and the
/api/dex/*endpoints behind them. - Buying AE: where to earn or buy AE.
Related
- Bonding curves: the other market, and the one most Superhero tokens trade on.
- Buying and selling tokens: the curve-side trade flow.
- AEX-9 tokens: the token standard every DEX asset conforms to.
- DEX API: the REST surface for tokens, pairs and transactions.
- Superhero DEX on the æternity docs hub (opens in a new tab): æternity's description of the exchange.
- dex-contracts-v2 (opens in a new tab): the AMM contracts and their ACIs.