Responsible for the interaction between Totle and EtherDelta when trying to fill an order.
Responsible for all implementation specific logic required by each DEX.
Due to the differing requirements of executing trades at each DEX, we employ the use of separate ExchangeHandler contracts. An ExchangeHandler is responsible for all implementation specific logic required by each DEX. This could range from depositing funds prior to initiating a trade to wrapping or unwrapping ether as required. It is a key requirement that we keep DEX logic separate from the primary contract in order to allow for expansion of the platform.
Responsible for transferring ownership of ERC20 tokens from the investor to the TotlePrimary contract on execution of a sell order.
TokenTransferProxy is responsible for transferring ownership of ERC20 tokens from the buyer/seller to the TotlePrimary contract on execution of a sell order. The buyer/seller is therefore required to set an allowance for the TokenTransferProxy prior to selling any tokens via Totle. The TokenTransferProxy maintains a record of addresses which have been authorized to transfer tokens on its behalf, the only address with this authorization is the TotlePrimary contract. In case of an upgrade to the primary contract, Totle is the only authorized party to approve this change. As the platform matures we may implement a safeguarding mechanism such as a multi-sig or time-locked contract to control address authorization and welcome feedback on this from the community.
The TotlePrimary loops through each token trade, sequentially executing all orders at their respective exchange handlers. This contract is entry point for external transactions and performs sanity checks on the payload.
This contract is the sole entry point for external transactions and is responsible for performing sanity checks on the payload, executing trades via the respective exchange handler, and keeping count of amounts given and received in order to enforce minimum exchange rate requirements.
You submit a transaction to the Totle Primary Contract which will then invoke the executeOrders function.
After checking the payload data (the data that needs to be passed with the transaction), any tokens that are chosen to be sold are transferred to the primary contract through the TokenTransferProxy. This is then followed by a check to ensure enough ETH (gas fees/transaction costs) will be available to conduct all the requested trades. Note, in order to execute a sell, a token allowance needs to be set for each token to the TokenTransferProxy contract.
The payload is split into separate trades (e.g. buy OMG, sell CVC), where they can subsequently be split into several DEX orders. This is what allows you to get the best possible prices on their orders. If there are buy and sell orders mixed together, the sell orders are executed first and any Ether gained are used to pay for buy orders to reduce the total amount of Ether required to be sent with the transaction.
A count is kept of the amounts spent and acquired, and after each trade the primary contract performs a check to ensure that all orders were executed equal to or above the minimum exchange rate. Subsequent to the execution of all trades, any Ether or tokens gained is returned to the buyer/seller and then execution is completed.
Totle Inc. is not responsible for lost funds and is in no way giving any investment advice.
Real-time price discovery
Different types of DEXs