Backend & API architecture
Architecture​
Key components of the backend include:
- Quoting engine
- Transaction builder
- On-chain Indexer
- API Gateway
Quoting engine​
Bungee's quoting engine identifies best possible routes between chains for given tokens. It taps into liquidity data of DEXes and bridges to identify best possible trades. Bridges only support a limited number of tokens to bridge, requiring swaps from user-token to a bridge-supported token. The quoting engine automatically identifies which token to swap to for maximum capital efficiency.
Every DEX and bridge integrated has its own layer in the quoting engine which returns the best trade possible and Bungee's main quoting engine compiles these into routes with different combinations of DEX and Bridge quotes.
Access the quoting engine through the /quote
API. You can customize quotes with various flags, including:
- Unique Routes for bridge : Multiple combinations of DEXes and Bridges can exist in a route. Setting this flag to
true
returns the best possible combination for a given pair. - Whitelisting : Includes or excludes specific DEXes and Bridges from the quote
- Recipient Address : Setting a recipient address on the destination chain
- Smart contract integration : Fetches quotes only for bridges that support a smart contract as sender of transaction
- Sort : Sorts routes based on highest output, least bridging time & lowest fees.
Transaction builder​
Generates transaction data to interact with Socket contracts.
In the response of /quote
API, for a given route returned, an array of user transactions exists that contains metadata of all steps involved in the route. The /route/start
API for Multi & Single Transaction Bridging and /build-tx
API for Single Transaction Bridging endpoint takes this as input and generates the transaction data for each tx involved.
On-chain indexer​
Bungee's Indexer indexes cross-chain transaction data and exposes that data via our /bridge-status
API. When a cross-chain transaction is initiated, the indexer catches the deposit
event for a given bridge on the source chain, decodes necessary data and checks for the transaction’s completion on the destination chain.
API Gateway​
The Bungee API acts an interface to fetch quotes from the engine as described above. It also generates the transaction data to interact with Bungee contracts. In addition to this, the API also supports
- Checking token approvals for Bungee contracts
- Balances
- Token Lists
- Bridging Transaction Statuses