Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions skills/aerodrome-amm/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ tags:




## Pre-flight Dependencies (auto-injected by Plugin Store CI)

> Run once per session before first use. These checks ensure required tools are installed.
Expand Down
189 changes: 189 additions & 0 deletions skills/raydium/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
---
name: raydium
description: "Raydium AMM plugin for token swaps, price queries, and pool info on Solana. Trigger phrases: swap on raydium, raydium swap, raydium price, raydium pool, get swap quote raydium. Chinese: 在Raydium上兑换代币, 查询Raydium价格, 查询Raydium流动池"
license: MIT
metadata:
author: skylavis-sky
version: "0.1.0"
---


## Pre-flight Dependencies (auto-injected by Plugin Store CI)

> Run once per session before first use. These checks ensure required tools are installed.

### Install onchainos CLI + Skills (auto-injected)

```bash
# 1. Install onchainos CLI
onchainos --version 2>/dev/null || curl -fsSL https://raw.githubusercontent.com/okx/onchainos-skills/main/install.sh | sh

# 2. Install onchainos skills (enables AI agent to use onchainos commands)
npx skills add okx/onchainos-skills --yes --global

# 3. Install plugin-store skills (enables plugin discovery and management)
npx skills add MigOKG/plugin-store --skill plugin-store --yes --global
```

### Install raydium binary (auto-injected)

```bash
if ! command -v raydium >/dev/null 2>&1; then
OS=$(uname -s | tr A-Z a-z)
ARCH=$(uname -m)
case "${OS}_${ARCH}" in
darwin_arm64) TARGET="aarch64-apple-darwin" ;;
darwin_x86_64) TARGET="x86_64-apple-darwin" ;;
linux_x86_64) TARGET="x86_64-unknown-linux-gnu" ;;
linux_aarch64) TARGET="aarch64-unknown-linux-gnu" ;;
esac
curl -fsSL "https://github.com/MigOKG/plugin-store/releases/download/plugins/raydium@0.1.0/raydium-${TARGET}" -o ~/.local/bin/raydium
chmod +x ~/.local/bin/raydium
fi
```

### Report install (auto-injected, runs once)

```bash
REPORT_FLAG="$HOME/.plugin-store/reported/raydium"
if [ ! -f "$REPORT_FLAG" ]; then
mkdir -p "$HOME/.plugin-store/reported"
# Device fingerprint → SHA256 → 32-char device ID
DEV_RAW="$(hostname):$(uname -s):$(uname -m):$HOME"
DEV_ID=$(echo -n "$DEV_RAW" | shasum -a 256 | head -c 32)
# HMAC signature (obfuscated key, same as CLI binary)
_K=$(echo 'OE9nNWFRUFdfSVJkektrMExOV2RNeTIzV2JibXo3ZWNTbExJUDFIWnVoZw==' | base64 -d 2>/dev/null || echo 'OE9nNWFRUFdfSVJkektrMExOV2RNeTIzV2JibXo3ZWNTbExJUDFIWnVoZw==' | openssl base64 -d)
HMAC_SIG=$(echo -n "${_K}${DEV_ID}" | shasum -a 256 | head -c 8)
DIV_ID="${DEV_ID}${HMAC_SIG}"
unset _K
# Report to Vercel stats
curl -s -X POST "https://plugin-store-dun.vercel.app/install" \
-H "Content-Type: application/json" \
-d '{"name":"raydium","version":"0.1.0"}' >/dev/null 2>&1 || true
# Report to OKX API (with HMAC-signed device token)
curl -s -X POST "https://www.okx.com/priapi/v1/wallet/plugins/download/report" \
-H "Content-Type: application/json" \
-d '{"pluginName":"raydium","divId":"'"$DIV_ID"'"}' >/dev/null 2>&1 || true
touch "$REPORT_FLAG"
fi
```

---


## Architecture

- Read ops (`get-swap-quote`, `get-price`, `get-token-price`, `get-pools`, `get-pool-list`) → direct REST API calls to Raydium endpoints; no wallet or confirmation needed
- Write ops (`swap`) → after user confirmation, builds serialized tx via Raydium transaction API, then submits via `onchainos wallet contract-call --chain 501 --unsigned-tx <base64_tx>`
- Chain: Solana mainnet (chain ID 501)
- APIs: `https://api-v3.raydium.io` (data) and `https://transaction-v1.raydium.io` (tx building)

## Commands

### get-swap-quote — Get swap quote

Returns expected output amount, price impact, and route plan. No on-chain action.

```bash
raydium get-swap-quote \
--input-mint So11111111111111111111111111111111111111112 \
--output-mint EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v \
--amount 1000000000 \
--slippage-bps 50
```

### get-price — Get token price ratio

Computes the price ratio between two tokens using the swap quote endpoint.

```bash
raydium get-price \
--input-mint So11111111111111111111111111111111111111112 \
--output-mint EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v \
--amount 1000000000
```

### get-token-price — Get USD price for tokens

Returns the USD price for one or more token mint addresses.

```bash
raydium get-token-price \
--mints So11111111111111111111111111111111111111112,EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
```

### get-pools — Query pool info

Query pool info by pool IDs or by token mint addresses.

```bash
# By mint addresses
raydium get-pools \
--mint1 So11111111111111111111111111111111111111112 \
--mint2 EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v \
--pool-type all \
--sort-field liquidity

# By pool ID
raydium get-pools --ids 58oQChx4yWmvKdwLLZzBi4ChoCc2fqCUWBkwMihLYQo2
```

### get-pool-list — List pools with pagination

Paginated list of all Raydium pools.

```bash
raydium get-pool-list \
--pool-type all \
--sort-field liquidity \
--sort-type desc \
--page-size 20 \
--page 1
```

### swap — Execute token swap

**Ask user to confirm** before executing. This is an on-chain write operation.

Execution flow:
1. Run with `--dry-run` first to preview (no on-chain action)
2. **Ask user to confirm** the swap details, price impact, and fees
3. Execute only after explicit user approval
4. Reports transaction hash(es) on completion

```bash
# Preview (dry run)
raydium --dry-run swap \
--input-mint So11111111111111111111111111111111111111112 \
--output-mint EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v \
--amount 1000000000 \
--slippage-bps 50

# Execute (after user confirmation)
raydium swap \
--input-mint So11111111111111111111111111111111111111112 \
--output-mint EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v \
--amount 1000000000 \
--slippage-bps 50 \
--wrap-sol true \
--unwrap-sol true
```

**Safety guards:**
- Price impact ≥ 5%: warns the user
- Price impact ≥ 20%: aborts swap to protect funds

## Common Token Mint Addresses (Solana Mainnet)

| Token | Mint Address |
|-------|-------------|
| SOL (Wrapped) | `So11111111111111111111111111111111111111112` |
| USDC | `EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v` |
| USDT | `Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB` |
| RAY | `4k3Dyjzvzp8eMZWUXbBCjEvwSkkk59S5iCNLY3QrkX6R` |

## Notes

- Solana blockhash expires in ~60 seconds. The swap command builds and broadcasts the transaction immediately — do NOT add delays between getting the quote and submitting.
- The `--dry-run` flag skips all on-chain operations and returns a simulated response.
- Use `onchainos wallet balance --chain 501` to check SOL and token balances before swapping.