📄
Autonomy Docs
  • Autonomy Network
    • Overview
    • Use Cases
    • System Components
      • Registry
      • Requests
      • Executors
      • StakeManager
    • Products
      • AutoSwap
        • How It Works
        • Integrating Limits/Stops Into Your DEX
        • Limits & Stops SDK
      • AutoHedge
        • How to Use AutoHedge
        • Return/Profit Analysis
        • How It Works
        • How It Works (detailed)
          • Derivations
        • Links
      • AutoStation
        • Tutorial 1: Create A Condition And Upload It
          • Part 1: non-recurring
          • Part 2: recurring
          • Part 3: uploading to AutoStation
          • Part 4: bonus - how to call manually
        • Tutorial 2: Example automation using AutoStation
  • Developers
    • How to create a Request
    • Deployed Contracts
Powered by GitBook
On this page

Was this helpful?

  1. Autonomy Network
  2. Products
  3. AutoSwap

How It Works

PreviousAutoSwapNextIntegrating Limits/Stops Into Your DEX

Last updated 2 years ago

Was this helpful?

Having limit orders and stop losses execute on a DEX works the same as any other on Autonomy. Say the price of ETH is $1000 and the user wants to set a stop loss order to sell ETH when the price gets to $900:

  1. The user makes a tx (the only tx that the user makes in the whole flow) which on Autonomy that asks Autonomy to contract. Initially this Request is impossible to execute, because the condition is - any tx that tries to execute the Request will revert. This check is done on the actual input/output amounts of the trade, and is therefore a guarantee that the user will always get the trade they want, and doesn't need to rely on an oracle. The user still has their tokens in their wallet.

  2. The price on the DEX drops to $900 as 3rd parties trade on it.

  3. The Autonomy bots are constantly simulating whether executing a Request will succeed or revert. If they see it would succeed, that means that the condition for the trade is now true, and the require statement won't make the tx revert. This means the bot can know when a trade can be executed without knowing anything about tokens or prices or oracles. The bot now executes the Request, which atomically swaps the user's input token to the output token and it shows up in their wallet. At no point does the bot ever have control over the user's tokens.

creates a Request
call the limits/stops
codified in a require statement
Request