The Totle API gives you a simple, efficient, and cost-effective way to exchange multiple ERC-20 tokens in a single atomic transaction. You can use the Totle API to:
Say the client wishes to rebalance their portfolio by acquiring 10 BAT tokens, 20 OMG tokens, and 30 ZIL tokens with ETH. They can send those trade criteria to Totle’s rebalance API endpoint, 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.
Say the client has 10 ETH tokens, and they want to swap these for as many BAT tokens as possible. The user can send a request to Totle’s swap endpoint, indicating they want to swap 10 ETH tokens in exchange for however many BAT tokens it takes to equal the value of the 10 ETH tokens.
The Totle backend will calculate the amount of BAT tokens that can be acquired given the current pricing and execute the trade if possible.
Since trades are executed as a single Ethereum transaction, there are only two possible outcomes:
Clients don’t need to worry about acquiring intermediate tokens required 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 integrates with many 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 can 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 find and execute multiple trades atomically API clients follow a basic two step process execute trades.
Looking for something else? Send us your feedback.