We'd like to give everyone a chance to write their own integration already (if they can work with ABIs directly) as the docs for dHedge develop. Here is a quick start for interacting with dHEDGE pools.

As long as the bot's address has manager access to a pool, the bot can also perform trades and rebalances by calling exchange.

The call to make a trade requires three arguments: exchange(bytes32 sourceKey, bytes32 sourceAmount, bytes32 destinationKey)

You provide the source currency, the amount and the destination currency. This call will perform the trade at the rate provided by the Synthetix protocol as given by the next Oracle update.

All synthetic assets are also ERC20 compatible. The documentation for all the tokens can be found here:

Please note that sourceKey and destinationKey are byte32 representations of token names: "sUSD", "sETH", "iETH". So a call exchange(sETH, 100400000000000000000, iETH) will look like this in hex:

exchange(7345544800000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000057154740ed9380000, 6945544800000000000000000000000000000000000000000000000000000000)

Here's the ABI for this function:

{ "constant": false, "inputs": [ { "internalType": "bytes32", "name": "sourceKey", "type": "bytes32" }, { "internalType": "uint256", "name": "sourceAmount", "type": "uint256" }, { "internalType": "bytes32", "name": "destinationKey", "type": "bytes32" } ], "name": "exchange", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }

Another call that the bot will most likely need is to read the current balance of the pool. Any bot could perform a direct read call to the pool smart contract. Specifically, calling getFundComposition() will return three matching lists.

The first list represents assets in the pool - sETH, sUSD, etc. The second list shows the corresponding balances of each asset. The final list is current sUSD rates of the assets (only for the ones with non-zero balance). Here's the ABI:

{ "constant": true, "inputs": [], "name": "getFundComposition", "outputs": [ { "internalType": "bytes32[]", "name": "", "type": "bytes32[]" }, { "internalType": "uint256[]", "name": "", "type": "uint256[]" }, { "internalType": "uint256[]", "name": "", "type": "uint256[]" } ], "payable": false, "stateMutability": "view", "type": "function" }

Check out the dHedge Github repository.

Stay tuned for example bots!