How It Works
Having limit orders and stop losses execute on a DEX works the same as any other Request 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:
The user makes a tx (the only tx that the user makes in the whole flow) which creates a
Requeston Autonomy that asks Autonomy to call the limits/stops contract. Initially thisRequestis impossible to execute, because the condition is codified in arequirestatement - any tx that tries to execute theRequestwill 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.The price on the DEX drops to $900 as 3rd parties trade on it.
The Autonomy bots are constantly simulating whether executing a
Requestwill succeed or revert. If they see it would succeed, that means that the condition for the trade is now true, and therequirestatement 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 theRequest, 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.
Last updated
Was this helpful?