We are always hard-at-work, bringing you more and more neat features for Ethfinex Trustless. This time, as you might’ve noticed from some of our announcements, we’re happy to introduce a new service to your ‘off-the-orderbook’ exchange more secure and seamless than ever before. We bring you the Ethfinex Trustless OTC.

Our intuitive interface, which you can view now at https://trustless.ethfinex.com/otc/ is built atop a custom Ethereum smart contract, using solidity v0.5.4. You can examine the smart contract on etherscan. I’ve also included a snippet of the code below!

First things first, whilst possible, you will notice that we are not currently using the standard 0x contract for Trustless OTC. This is something we are considering switching to once we are confident with operation and flow of the service.

As I mentioned previously, we wrote it using solidity v0.5.4. The portion of the code that you can find below describes a function which serves to create an offer, which you can then share with your counter-party.

function initiateTrade(
address _tokenFrom,
address _tokenTo,
uint256 _amountFrom,
uint256 _amountTo,
address _optionalTaker
) public payable returns (uint newTradeID) {
if (_tokenFrom == address(0)) {
require(msg.value == _amountFrom);
} else {
require(msg.value == 0);
IERC20(_tokenFrom).safeTransferFrom(msg.sender, address(this), _amountFrom);
}
newTradeID = offers.length;
offers.length++;
TradeOffer storage o = offers[newTradeID];
balanceTracker[_tokenFrom] = balanceTracker[_tokenFrom].add(_amountFrom);
o.tokenFrom = _tokenFrom;
o.tokenTo = _tokenTo;
o.amountFrom = _amountFrom;
o.amountTo = _amountTo;
o.creator = msg.sender;
o.optionalTaker = _optionalTaker;
o.active = true;
o.tradeID = newTradeID;
tradeTracker[msg.sender].push(newTradeID);
emit OfferCreated(newTradeID);
}

You simply define the type of token you want to pay with, the type of token you want to receive (using their contract addresses) and the exchange rate. You can also optionally restrict the trade to a certain taker address, which is highly recommended, if possible, to further improve the security of your trade.

Your tokens are then deposited into the OTC smart contract through the specified transaction and a trade, with a unique ID, is generated. This trade can then be taken by anyone, as long as they meet the outlined criteria (amount and exchange rate data set by the user). That means they know the ID, have the required tokens and, optionally, are in possession of the wallet address that you’ve specified as a desired taker of the trade. This ensures that you always have full control over your trade. You can either cancel the trade and claim your tokens back, or your trade partner can take the offer resulting in you safely and seamlessly exchanging tokens according to pre-defined terms.

All of this can be done on the contract level, or you can use our custom built interface at https://trustless.ethfinex.com/otc/. Our OTC interface makes it even easier and quicker to create an offer and share it with your desired counter-party. Go check it out now!

As always, we would be very happy to hear your feedback on our design and discuss possible future features! Make sure to join us on Telegram to share feedback, ask questions or have a chat.

Until next time!


Trading is now live on Ethfinex — get started here.

Sign up to our weekly newsletter and stop by our Telegram to learn more about the vision for Ethfinex.

Visit our Twitter to stay up to date with announcements, token additions and more.