# How it Works

Perped leverages API3's Request-Response Protocol (RRP). Here's a general flow of how it works

1. When a user wants to open a perpetual position on *Perped* (for example, a 10x long position on AAPL stock) they go to the web UI and put in the parameters for it, or the trade can be opened from a direct RPC call to the blockchain.
2. The associated *Perped* smart contract responsible for opening and closing positions will then send a call to the **Airnode RRP** smart contract which then writes the details of the request to the blockchain in the form of an event.
3. The Airnode for the data provider that *Perped* has chosen to use will then ‘wake up’ for its next interval, and see that there was an event written to the blockchain that tells it the *Perped* protocol smart contract needs to know the price of AAPL stock.
4. The Airnode will retrieve the price of the stock from the data provider’s HTTP API and then send that value along with some other information such as a uniquely generated request ID directly to the *Perped* smart contract. The function on the *Perped* contract that receives the price information from the Airnode will have all of the other data necessary for opening the trade already there as a pending trade.
5. When it receives the price from Airnode, the trade is then settled at that time, by the transaction from the Airnode (aka “Airnode Settlement”). That’s it, the trade is now open. The same action outlined here is done when closing a trade.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://perped.gitbook.io/perped/technical-overview/how-it-works.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
