Case study / Decentralized finance
Building a cross-chain swap engine
Before sending tokens on one blockchain, a trader wants to know how much will arrive on the other. We built a routing engine from scratch to answer that question before the trader commits.
One trade, several possible routes
Two liquidity providers can quote different amounts for the same swap. To give the trader a useful estimate, the engine had to compare routes for the same input amount and work out what each route would deliver in the destination token.
Our team owned the project from business analysis and product design through engineering, testing and production launch. At the core was a routing algorithm we developed specifically for the engine.
How the engine quotes a swap
- Compare provider quotes. The router collects quotes for the requested swap and identifies candidate routes between the source and destination chains.
- Simulate each candidate. The engine estimates how many destination tokens each route would deliver before committing funds.
- Quote the selected route. The trader sees the expected amount in the token they will receive and can decide whether to proceed.
Checking the quote against the trade
For an executed swap, we could compare two numbers directly – the number of tokens the engine quoted and the number that arrived on the destination chain. This gave the team a way to check how well its simulations reflected execution.
In production, quoted amounts closely tracked what traders received. We also compared our quotes with those from leading swap aggregators and found them competitive.