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

docs: websocket documentation for active quoting #3396

Merged
merged 1 commit into from
Nov 16, 2024

Conversation

dwasse
Copy link
Collaborator

@dwasse dwasse commented Nov 15, 2024

Summary by CodeRabbit

  • New Features

    • Expanded documentation for the Quoter API, including a new section on the WebSocket API.
    • Detailed operations for quoters such as ping, subscribe, unsubscribe, and send_quote.
    • Clear structures for quote request and response content.
  • Documentation

    • Emphasized the importance of maintaining connections and subscribing to quote requests.

@dwasse dwasse requested a review from trajan0x as a code owner November 15, 2024 22:21
Copy link
Contributor

coderabbitai bot commented Nov 15, 2024

Walkthrough

The pull request introduces significant enhancements to the documentation of the Quoter API, specifically adding a new section on the WebSocket API for quoters. This section details operations available via the GET /rfq_stream endpoint, including methods like ping, subscribe, unsubscribe, and send_quote. It specifies the structure of request and response content, emphasizing the need for periodic ping messages to maintain connections. Existing documentation on Passive and Active Quotes remains unchanged, while the new section provides comprehensive guidance for users and integrators.

Changes

File Path Change Summary
docs/bridge/docs/04-Routers/RFQ/API/index.md Added a new section on WebSocket API for quoters, detailing operations, request/response formats, and connection maintenance.

Possibly related PRs

  • feat(rfq): active quoting API #3128: The changes in this PR introduce WebSocket support for the RFQ API, which directly relates to the new section on the WebSocket API for quoters added in the main PR. Both PRs enhance the functionality of the Quoter API through WebSocket connections and operations.

Suggested reviewers

  • aureliusbtc

🐇 In the meadow, where quotes do play,
A WebSocket dance brightens the day.
With pings and responses, they frolic and cheer,
For quoters now have a voice, loud and clear!
So hop along, friends, to the API's delight,
New paths for connection, oh what a sight! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: 932514b
Status:🚫  Build failed.

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Outside diff range and nitpick comments (4)
docs/bridge/docs/04-Routers/RFQ/API/index.md (4)

63-66: Add authentication and connection details to the WebSocket API introduction.

Consider adding essential information about:

  • Authentication requirements for the WebSocket connection
  • Any rate limits or connection limits per quoter
  • Connection timeout details
  • Reconnection strategies
🧰 Tools
🪛 Markdownlint

63-63: null
Headings must start at the beginning of the line

(MD023, heading-start-left)


67-71: Fix markdown list indentation.

The unordered list items should start at the beginning of the line without indentation.

-  - `ping` - sends a heartbeat to the API server to keep the connection alive (must be sent at least once per minute)
-  - `subscribe` - subscribes to quote requests for given chain(s)
-  - `unsubscribe` - unsubscribes to quote requests for given chain(s)
-  - `send_quote` - responds to a quote request
+ - `ping` - sends a heartbeat to the API server to keep the connection alive (must be sent at least once per minute)
+ - `subscribe` - subscribes to quote requests for given chain(s)
+ - `unsubscribe` - unsubscribes to quote requests for given chain(s)
+ - `send_quote` - responds to a quote request
🧰 Tools
🪛 Markdownlint

68-68: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


69-69: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


70-70: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


71-71: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


67-71: Add examples for each WebSocket operation.

Consider adding code examples showing the exact message format for each operation to make it clearer for integrators.

🧰 Tools
🪛 Markdownlint

68-68: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


69-69: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


70-70: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


71-71: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


63-110: Add error handling and recovery procedures.

The WebSocket API documentation would benefit from a dedicated section on:

  • Common error scenarios and their handling
  • Connection recovery procedures
  • Retry strategies with backoff recommendations
  • Debugging tips
🧰 Tools
🪛 Markdownlint

68-68: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


69-69: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


70-70: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


71-71: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


74-74: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


75-75: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


63-63: null
Headings must start at the beginning of the line

(MD023, heading-start-left)


78-78: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


88-88: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


103-103: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between a7ff26a and 932514b.

📒 Files selected for processing (1)
  • docs/bridge/docs/04-Routers/RFQ/API/index.md (1 hunks)
🧰 Additional context used
🪛 Markdownlint
docs/bridge/docs/04-Routers/RFQ/API/index.md

68-68: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


69-69: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


70-70: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


71-71: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


74-74: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


75-75: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


63-63: null
Headings must start at the beginning of the line

(MD023, heading-start-left)


78-78: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


88-88: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


103-103: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

Comment on lines +77 to +84
All websocket messages follow this format:
```
{
op: string,
content: json,
success: bool,
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance message format specification.

The message format needs:

  1. Field descriptions and types
  2. Language specification for the code block
  3. Examples of success and error cases
-  ```
+  ```json
   {
-    op: string,
-    content: json,
-    success: bool,
+    "op": "string",     // Operation type (e.g., "ping", "subscribe")
+    "content": "json",  // Operation-specific payload
+    "success": "bool"   // Indicates if the operation was successful
   }

<details>
<summary>🧰 Tools</summary>

<details>
<summary>🪛 Markdownlint</summary>

78-78: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

</details>

</details>

<!-- This is an auto-generated comment by CodeRabbit -->

Comment on lines +86 to +108
Quote request content should have the following format:

```
{
data: {
origin_chain_id: number,
dest_chain_id: number,
origin_token_addr: string,
dest_token_addr: string,
origin_amount_exact: string,
expiration_window: number // number of ms since created_at until request should expire
},
}
```

Quote response content should have the following format:

```
{
request_id: string,
dest_amount: string,
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add field validations and improve format specifications.

Please enhance the content formats with:

  1. Field validations (e.g., allowed ranges, formats)
  2. Field descriptions
  3. Language specifications for code blocks
-  ```
+  ```json
   {
     "data": {
-      origin_chain_id: number,
-      dest_chain_id: number,
-      origin_token_addr: string,
-      dest_token_addr: string,
-      origin_amount_exact: string,
-      expiration_window: number
+      "origin_chain_id": "number",      // Source chain ID (e.g., 1 for Ethereum)
+      "dest_chain_id": "number",        // Destination chain ID
+      "origin_token_addr": "string",    // Token address on source chain (0x...)
+      "dest_token_addr": "string",      // Token address on destination chain
+      "origin_amount_exact": "string",  // Amount in wei (must be > 0)
+      "expiration_window": "number"     // Must be between 1000 and 300000 ms
     },
   }
  • {
  • request_id: string,
  • dest_amount: string,
  • "request_id": "string", // Unique identifier for the quote request
  • "dest_amount": "string" // Amount in wei (must be > 0)
    }
🧰 Tools
🪛 Markdownlint

88-88: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)


103-103: null
Fenced code blocks should have a language specified

(MD040, fenced-code-language)

Comment on lines +73 to +75
The API server may respond with the following operations:
- `pong` - acknowleges a `ping` message
- `request_quote` - informs quoter of a new user quote request
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error responses and examples.

Please enhance this section by:

  1. Adding possible error response types (e.g., invalid_request, unauthorized, etc.)
  2. Including examples of each response type
  3. Fixing the markdown list indentation
-  - `pong` - acknowleges a `ping` message
-  - `request_quote` - informs quoter of a new user quote request
+ - `pong` - acknowleges a `ping` message
+ - `request_quote` - informs quoter of a new user quote request
+ - `error` - indicates an error condition with details

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 Markdownlint

74-74: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)


75-75: Expected: 0; Actual: 2
Unordered list indentation

(MD007, ul-indent)

@parodime parodime merged commit 3e8a2f3 into feat/FbV2-docs Nov 16, 2024
27 of 29 checks passed
@parodime parodime deleted the feat/FbV2-docs-ws branch November 16, 2024 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants