How routing works
How Kabudex turns an intention into a transaction: where quotes come from, how minimums are set, and every reason an order can fail.
Two routers
Kabudex uses two routing paths, each where it is strongest. Single swaps and bridges go through LI.FI, which aggregates many exchanges and bridges and is often the best price for one pair. Baskets and launched tokens go through Uniswap's Universal Router at 0x8876789976dEcBfCbBbe364623C63652db8C0904, because it can run several swaps inside one transaction, which is what a basket needs.
Finding the pool for a basket leg
Kabudex keeps a snapshot of every Uniswap v3 and v4 pool that holds each stock token against USDG or ETH: 223 pools across 72 stocks at the last probe. Baskets use the 48 stocks whose deepest USDG pool fills a $250 buy within 3% of the on-chain mid price. For each leg of a basket, the app quotes every candidate pool on the chain with Uniswap's own quoters and keeps the one that returns the most. Failures are ignored: a pool that has emptied since the snapshot simply drops out.
- 1Split the amount
Each leg gets
amount × weight. Weights that do not add to 100% are scaled in proportion. - 2Quote every pool
The V4 quoter and V3 QuoterV2 are called for each candidate pool. The best quote wins.
- 3Set the minimum
Each leg's minimum is
quote × (1 − slippage). The router enforces it on-chain. - 4Build one call
The legs become commands of one
execute(commands, inputs, deadline)call: wrap ETH if needed, swap, take the outputs to your address, sweep any leftover back to you.
WRAP_ETH ETH -> WETH, held by the router for this call
V3_SWAP_EXACT_IN WETH -> USDG
V4_SWAP SETTLE USDG
SWAP_EXACT_IN_SINGLE USDG -> NVDA minOut set
SWAP_EXACT_IN_SINGLE USDG -> AAPL minOut set
SWAP_EXACT_IN_SINGLE USDG -> META minOut set
TAKE NVDA, AAPL, META -> your address
SWEEP leftover USDG -> your address
// measured: about 539,000 gas paid in ETH, 427,000 paid in USDGWhat can make an order fail
| Reason | What you see | What to do |
|---|---|---|
| Price moved past your limit | The price moved past your slippage limit. | Refresh the quote, or allow more slippage. |
| Quote expired | The quote expired before the transaction was mined. | Sign again; quotes carry a deadline. |
| Token paused by the issuer | This token is paused right now. | Wait for the issuer to unpause it. |
| Address blocked by the issuer | This wallet cannot send or receive this stock. | Nothing an interface can change. |
| Missing approval | The router is not allowed to spend this token yet. | Approve, then retry. |
| Not enough balance or gas | Not enough balance for this trade plus gas. | Lower the amount or add ETH for gas. |
In every case the chain reverts the whole transaction. Nothing is half done, and only the gas used up to the failure is spent.