Skip to content

feat: add market maker tutorial#24

Open
gagdiez wants to merge 3 commits intomainfrom
market-maker-tutorial
Open

feat: add market maker tutorial#24
gagdiez wants to merge 3 commits intomainfrom
market-maker-tutorial

Conversation

@gagdiez
Copy link
Collaborator

@gagdiez gagdiez commented Mar 6, 2026

This PR adds a Guide on how to become a market maker

@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

Walkthrough

This pull request adds documentation for running a market-maker solver on the NEAR Intents Message Bus. It introduces a new MDX guide file and updates the documentation navigation structure with a new Guides group under Market Makers.

Changes

Cohort / File(s) Summary
Documentation Navigation
docs.json
Adds a new Guides group under Market Makers tab with a link to the become-market-maker-guide page.
Market Maker Guide
integration/market-makers/become-market-maker-guide.mdx
New comprehensive MDX guide explaining prerequisites, architecture overview, setup instructions (clone, configure, deposit liquidity, start solver), code path documentation (WebSocket connection, AMM quote evaluation, balance cron), customization options, and production considerations.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

Poem

🐰 A guide for makers bold and wise,
Who'll arbitrage beneath the skies,
With WebSockets and constant AMM,
Balance flows like morning dew from stem,
The Message Bus awaits your vim! 📚✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add market maker tutorial' accurately summarizes the main change: adding a new market maker guide/tutorial to the documentation.
Description check ✅ Passed The description 'This PR adds a Guide on how to become a market maker' is directly related to the changeset, which includes new documentation files for becoming a market maker.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch market-maker-tutorial

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@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: 1

🧹 Nitpick comments (1)
docs.json (1)

105-110: Consider adding an icon for visual consistency.

The "Message Bus" and "Token Bridges" sibling groups have icons, while "Guides" and "Services" do not. Adding an icon (e.g., "icon": "book" or "icon": "graduation-cap") would improve visual consistency across the navigation.

📝 Suggested change
          {
            "group": "Guides",
+           "icon": "graduation-cap",
            "pages": [
              "integration/market-makers/become-market-maker-guide"
            ]
          },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs.json` around lines 105 - 110, Update the "Guides" navigation entry to
include an icon property for visual consistency with sibling groups;
specifically add an "icon" field (e.g., "icon": "book" or "icon":
"graduation-cap") to the object that contains "group": "Guides" and "pages":
["integration/market-makers/become-market-maker-guide"] so the entry mirrors how
"Message Bus" and "Token Bridges" define icons.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@integration/market-makers/become-market-maker-guide.mdx`:
- Around line 87-93: The docs currently instruct hardcoding the API key into
src/services/websocket-connection.service.ts (and reference a fragile line
number); instead instruct users to add RELAY_API_KEY=your_api_key_here to their
.env.local and update the guide text to remove the line-numbered edit. Change
the guide to say the WebSocket connection service
(websocket-connection.service.ts) will read process.env.RELAY_API_KEY and
include it as the Bearer token in the Authorization header, and update the
snippet to show adding the RELAY_API_KEY to .env.local (do not show hardcoded
keys in source).

---

Nitpick comments:
In `@docs.json`:
- Around line 105-110: Update the "Guides" navigation entry to include an icon
property for visual consistency with sibling groups; specifically add an "icon"
field (e.g., "icon": "book" or "icon": "graduation-cap") to the object that
contains "group": "Guides" and "pages":
["integration/market-makers/become-market-maker-guide"] so the entry mirrors how
"Message Bus" and "Token Bridges" define icons.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fe92f811-eaf2-48cb-a662-cdc798710dd6

📥 Commits

Reviewing files that changed from the base of the PR and between 5ae7e66 and feeed5c.

📒 Files selected for processing (2)
  • docs.json
  • integration/market-makers/become-market-maker-guide.mdx

Comment on lines +87 to +93
Once issued, open `src/services/websocket-connection.service.ts` and add your API key as a Bearer token in the WebSocket connection headers at line 35:

```typescript
headers: {
Authorization: `Bearer ${YOUR_API_KEY}`,
}
```
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, check if the MDX file exists and read the relevant section
fd "become-market-maker-guide.mdx" --type f

Repository: defuse-protocol/docs

Length of output: 119


🏁 Script executed:

# Get the content around lines 87-93 of the MDX file
if [ -f "integration/market-makers/become-market-maker-guide.mdx" ]; then
  sed -n '80,100p' "integration/market-makers/become-market-maker-guide.mdx"
fi

Repository: defuse-protocol/docs

Length of output: 762


🏁 Script executed:

# Check for TypeScript files that handle API keys or environment variables
rg -n "RELAY_API_KEY|Authorization.*Bearer|headers.*Authorization" --type ts -A 2 -B 2 | head -50

Repository: defuse-protocol/docs

Length of output: 212


🏁 Script executed:

# Look for .env files and configuration examples
fd -e "\.env*" -o -name "*.example" | head -20

Repository: defuse-protocol/docs

Length of output: 294


🏁 Script executed:

# Check websocket-connection.service.ts specifically
fd "websocket-connection.service.ts" --type f

Repository: defuse-protocol/docs

Length of output: 46


🏁 Script executed:

# Check what type of repository this is
ls -la | head -20

Repository: defuse-protocol/docs

Length of output: 1165


🏁 Script executed:

# Look for any SDK files or example projects
find . -name "package.json" -o -name "tsconfig.json" -o -name ".env*" | head -20

Repository: defuse-protocol/docs

Length of output: 46


🏁 Script executed:

# Search for references to websocket or API key configuration in the docs
rg "websocket|api.key|env.local" -i --type mdx | head -30

Repository: defuse-protocol/docs

Length of output: 91


🏁 Script executed:

# Check for any example code or implementation guides
fd -e "mdx" -type f -exec rg -l "websocket-connection\|Bearer.*token\|Authorization" {} \;

Repository: defuse-protocol/docs

Length of output: 234


🏁 Script executed:

# Search for websocket references in all files
rg "websocket|Bearer.*API" -i | head -40

Repository: defuse-protocol/docs

Length of output: 3491


🏁 Script executed:

# Check the integration directory structure
find integration -type f -name "*.mdx" | head -20

Repository: defuse-protocol/docs

Length of output: 1136


🏁 Script executed:

# Search for any links to SDK or implementation code
rg "github\.com|src/services|\.env" | head -30

Repository: defuse-protocol/docs

Length of output: 6837


🏁 Script executed:

# Check if there are references to other documentation files about setup
rg "setup|install|initialize|configure" -i integration/market-makers/ | head -20

Repository: defuse-protocol/docs

Length of output: 2169


Avoid hardcoding the API key in source files; use environment variables instead.

The documentation contradicts itself. It earlier instructs users to configure env/.env.local and warns against committing API keys to version control, but then instructs them to hardcode the API key directly in src/services/websocket-connection.service.ts at line 35. Additionally, referencing a specific line number is fragile and breaks when code changes.

Instead, add the API key to the .env.local file that users are already instructed to create:

-Once issued, open `src/services/websocket-connection.service.ts` and add your API key as a Bearer token in the WebSocket connection headers at line 35:
+Once issued, add your API key to `env/.env.local`:
 
-```typescript
-headers: {
-  Authorization: `Bearer ${YOUR_API_KEY}`,
-}
+```bash
+RELAY_API_KEY=your_api_key_here

+The WebSocket connection service will automatically read this value and include it in the Bearer token.


<details>
<summary>🤖 Prompt for AI Agents</summary>

Verify each finding against the current code and only fix it if needed.

In @integration/market-makers/become-market-maker-guide.mdx around lines 87 -
93, The docs currently instruct hardcoding the API key into
src/services/websocket-connection.service.ts (and reference a fragile line
number); instead instruct users to add RELAY_API_KEY=your_api_key_here to their
.env.local and update the guide text to remove the line-numbered edit. Change
the guide to say the WebSocket connection service
(websocket-connection.service.ts) will read process.env.RELAY_API_KEY and
include it as the Bearer token in the Authorization header, and update the
snippet to show adding the RELAY_API_KEY to .env.local (do not show hardcoded
keys in source).


</details>

<!-- fingerprinting:phantom:poseidon:ocelot -->

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants