Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triggered Order Contract #195

kaiynne opened this issue Aug 15, 2019 · 0 comments

Triggered Order Contract #195

kaiynne opened this issue Aug 15, 2019 · 0 comments


Copy link

@kaiynne kaiynne commented Aug 15, 2019

Triggered Orders Contract has many advantages over order book DEX's, a wider range of assets and with much deeper liquidity, but it is missing a critical feature in triggered orders. sX does not currently support any order type other than real-time market orders. We want to allow users to be able to set stop loss, take profit and limit orders. Once these basic order types are implemented we would like to expand the order types to more exotic orders, like trailing take profit, stop limit, partial stop loss and others.

User Stories

Create Triggered Order

  1. User comes to sX and sees option to setup triggered orders
  2. Dapp allows user to sign transaction delegating exchange functionality to the Triggered Order Contract
  3. Using sX user specifies triggered order. Params: currencyKeyFrom, amount, currencyKeyTo
    3.1 Limit BUY - BUY 50K sBTC @ sUSD $10,000
    3.2 Stop Loss - SELL 100 sETH @ sUSD $200
    3.3 Take Profit - SELL 500 sBNB @ sUSD $40
  4. User prepays ETH gas fees (Payable function on TriggeredOrder) with setting the limit order
  5. Dapp calls Service API with Triggered Order params saved in mongoDB
  6. Service listens to payable function storing the users gas(ETH) paid against the address

Execute Triggered Orders

  1. Service listens to ExchangeRates Smart contract for the UpdateRates event. If any rate changes tigger any open orders in the database then the Service will call a function on the TriggeredOrder Smart Contract to execute the exchanges on behalf of the user.
    1.1 The TriggeredOrder Smart Contract will refund the admin caller the amount of ETH it cost to run the call + a 10% fee

Edit/Cancel Triggered Orders

  1. sX has Triggered Order screen to see all orders open/executed/cancelled
  2. User can cancel, amend any open order


In order to implement triggered orders on sX we need several new systems to be implemented. The team will implement the ability to delegate the exchange call to a contract. This bounty covers the following:

  1. Write a Triggered Order Smart Contract that allows an off-chain service to send a transaction to the execute the delegated orders on the Synthetix smart contract
  2. Write the off-chain service to monitor the exchange rates contract and trigger orders based on exchange parameters specified by users
  3. Integrate the delegation functionality into sX Dapp
  4. Allow users to pre-pay gas for their triggered orders
  5. Update sX to accept triggered order parameters from users and store in off-chain DB
  6. Include writing unit tests
  7. We expect the contract deployed to Ropsten or Kovan for testing with your support, and then deployed to mainnet, again with your support. We expect the changes to sX to be written as a PR to be merged and deployed to staging for testing by the Synthetix team with your support.
@hav-noms hav-noms added this to To do in Synthetix Oct 2, 2019
@hav-noms hav-noms added the Bounty label Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
To do
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.