The Totle API gives users and applications a simple, efficient, and cost effective way to exchange multiple ERC20 tokens in a single atomic transaction. API clients can use the Totle API to find the best prices across multiple decentralized exchanges, retrieve a set of orders that will satisfy trade criteria, and settle those orders atomically.
Say the client wishes to buy 10 BAT tokens, 20 OMG tokens, and 30 ZIL tokens with ETH. They can send that trade criteria to Totle’s getOrders API and the Totle backend will send back a transaction payload containing a set of orders that will sell ETH for BAT, OMG, and ZIL on various exchanges. If the client signs the payload with the private key controlling the ETH and submits the signed transaction to the Ethereum network, the Totle smart contract system will execute the trades on the various exchanges until the criteria is satisfied.
Since the trades are executed as a single Ethereum transaction there are only two possible outcomes: either the transaction succeeds and the client’s trade criteria is satisfied or the transaction fails and no tokens are transferred. Clients don’t need to worry about acquiring intermediate tokens needed to facilitate the trades (e.g. WETH, ZRX, etc.) because the backend includes orders to acquire them in the payload as well.
Totle’s backend is integrated with a number of leading DEXs, which allows it to find liquidity and the best prices for ERC20 tokens available across decentralized exchange landscape. The Totle API provides a uniform interface to trading on heterogeneous DEXs that have different matching and settlement schemes. It does this by maintaining a local aggregated set of signed limit orders from order book based systems such as 0x and Ether Delta and performing real-time price discovery for market maker DEXs such as Bancor and Uniswap. Unlike limit orders, the exact prices on market maker DEXs aren’t known a priori and will change with the size of the order. However, Totle’s backend has enough information and intelligence to compare market and limit orders and choose the ones that will result in the best prices for the client. Totle is also integrated with dynamic matching DEXs (e.g. Airswap) where prices have to be negotiated in real time with the counterparty. Totle’s backend performs these negotiations and is able to compare these prices with limit and market orders from other exchanges. Doing this enables Totle’s matching system to combine real time price information and aggregated order books to find the best available prices across a diverse set of DEXs.
The first version of the Totle API described here provides the minimal amount of functionality to enable atomic swaps involving multiple DEXs and tokens. It will be expanded in the future to support other features and use cases.
Figure 1. Provides an overview of how an API client can use the Totle API to execute a set of trades involving multiple DEXs and/or tokens in a single atomic transaction.
To to find and execute multiple trades atomically API clients follow a basic two step process execute trades.
Looking for something else? Send us your feedback.