Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
48a4685
feat(scenarios): add Velocity support - state templates
92Infinitus92 Nov 2, 2026
319335f
ci: claude code review
failfmi Oct 7, 2026
ba50432
fix(scenarios): bundle the Velocity 2.170.0 IDL and move the pin
92Infinitus92 Nov 3, 2026
467c698
docs(scenarios): explain Velocity reloads and pauses
92Infinitus92 Nov 3, 2026
b807bfe
docs(scenarios): read the Velocity oracle exponent
92Infinitus92 Nov 3, 2026
25bc1b5
docs(scenarios): read the Velocity oracle exponent in the price note
92Infinitus92 Nov 3, 2026
be444ef
Merge upstream/main into feat/velocity-support
92Infinitus92 Nov 6, 2026
fb68145
feat(scenarios): keep the Velocity oracle posted with keep-alive
92Infinitus92 Nov 9, 2026
187ebb6
feat(scenarios): let a scenario make Velocity fills read the oracle o…
92Infinitus92 Nov 9, 2026
42fa047
Merge feat/scenarios/keep-alive-toggle into feat/velocity-support
92Infinitus92 Nov 9, 2026
3aae662
feat(scenarios): keep every loaded Velocity oracle posted with owned …
92Infinitus92 Nov 9, 2026
0ff3610
docs(scenarios): say every loaded Velocity oracle is kept posted
92Infinitus92 Nov 9, 2026
4f8f3b6
docs(scenarios): say in each price template that it keeps every loade…
92Infinitus92 Nov 10, 2026
dfeec60
Merge feat/scenarios/keep-alive-toggle into feat/velocity-support
92Infinitus92 Nov 10, 2026
bf9949d
test(scenarios): price the Velocity taker at its auction end so it cr…
92Infinitus92 Nov 10, 2026
f713474
docs(scenarios): explain how to keep one Velocity oracle stale while …
92Infinitus92 Nov 10, 2026
757eb4e
test(scenarios): drop the pinned deploy slot from the Velocity tests
92Infinitus92 Nov 19, 2026
26f1c82
feat(scenarios): Velocity funding, leverage, position and position to…
92Infinitus92 Nov 20, 2026
871423a
test(scenarios): prove the Velocity lookup recipes against mainnet
92Infinitus92 Nov 20, 2026
8a13065
Merge feat/scenarios/keep-alive-toggle into feat/velocity-support
92Infinitus92 Nov 20, 2026
384dff0
feat(scenarios): keep only the oracle a Velocity price override write…
92Infinitus92 Nov 20, 2026
bc02a4d
docs(scenarios): give each Velocity oracle a transaction reads its ow…
92Infinitus92 Nov 20, 2026
930665c
test(scenarios): give the Velocity tests their own diff_indices and l…
92Infinitus92 Nov 20, 2026
3952bf1
test(scenarios): move the Velocity tests under tests/protocols
92Infinitus92 Nov 20, 2026
4de1498
docs(scenarios): let a Velocity reposting override write any posted_slot
92Infinitus92 Nov 20, 2026
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
141 changes: 141 additions & 0 deletions .github/workflows/claude-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: Perform a code review when a pull request is created.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This new CI workflow is out of scope for a Velocity templates PR. It needs ANTHROPIC_API_KEY and has a job with pull-requests: write. Please submit it in a separate PR so maintainers can review it on its own.

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
claude:
# Skip drafts, and skip fork PRs: on `pull_request` they don't get the
# ANTHROPIC_API_KEY secret, so the review would only fail.
if: >-
!github.event.pull_request.draft &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
structured_output: ${{ steps.run_claude.outputs.structured_output }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
with:
# Explicitly check out the PR's merge commit.
ref: refs/pull/${{ github.event.pull_request.number }}/merge
persist-credentials: false

- name: Pre-fetch base and head refs for the PR
env:
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
# Pass GitHub expressions through env and quote shell expansions.
git fetch --no-tags origin \
"$PR_BASE_REF" \
"+refs/pull/$PR_NUMBER/head"

# If you want Claude to build and run code, install any dependencies that
# need to be downloaded before the "Run Claude" step, and add the commands
# it may run to --allowedTools below (e.g. "Bash(npm test:*)"). Any tool
# not listed there is denied.

- name: Run Claude
id: run_claude
uses: anthropics/claude-code-action@86d88e619d8e6caf07b5c3944dd14f441c533718 # v1.0.243
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
# Use this job's read-only token instead of the Claude GitHub App,
# which needs `id-token: write` and would get write access.
github_token: ${{ github.token }}
prompt: |
This is PR #${{ github.event.pull_request.number }} for ${{ github.repository }}.

Review ONLY the changes introduced by the PR, so consider:
git log --oneline ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}
git diff ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}

Suggest any improvements, potential bugs, or issues.
Be concise and specific in your feedback.

Return your review in two parts:
- `summary`: a short Markdown overview of the PR and your overall assessment.
- `comments`: one entry per specific issue, anchored to the line it concerns.
`path` is relative to the repository root. `line` is the line number in
the PR head version of the file (${{ github.event.pull_request.head.sha }}),
and must be a line shown in the diff above. The working tree is the merge
commit, so its line numbers can differ; check them with
`git show ${{ github.event.pull_request.head.sha }}:<path>`.
Put issues that don't belong to a single line in `summary` instead.

Pull request title and body:
----
${{ github.event.pull_request.title }}
${{ github.event.pull_request.body }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This CI workflow has nothing to do with Velocity support; please move it into its own PR. Also, the PR title and body go into the prompt unescaped. The tool allowlist is read-only and fork PRs are skipped, so the risk is limited, but any same-repo author can steer the review output that post_feedback posts with pull-requests: write.

claude_args: |
--allowedTools "Read,Grep,Glob,Bash(git log:*),Bash(git diff:*),Bash(git show:*)"
--json-schema '{
"type": "object",
"properties": {
"summary": {
"type": "string",
"description": "Overall review as Markdown, posted as the review body."
},
"comments": {
"type": "array",
"description": "Inline comments, each anchored to one line of the PR diff.",
"items": {
"type": "object",
"properties": {
"path": { "type": "string", "description": "File path relative to the repository root." },
"line": { "type": "integer", "minimum": 1, "description": "Line number in the PR head version of the file. Must be within the diff." },
"body": { "type": "string", "description": "The comment, as Markdown." }
},
"required": ["path", "line", "body"]
}
}
},
"required": ["summary", "comments"]
}'

post_feedback:
runs-on: ubuntu-latest
needs: claude
if: needs.claude.outputs.structured_output != ''
permissions:
issues: write
pull-requests: write
steps:
- name: Report Claude feedback
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
env:
CLAUDE_STRUCTURED_OUTPUT: ${{ needs.claude.outputs.structured_output }}
with:
github-token: ${{ github.token }}
script: |
const { summary = '', comments = [] } = JSON.parse(process.env.CLAUDE_STRUCTURED_OUTPUT);
const pr = context.payload.pull_request;
if (!summary.trim() && comments.length === 0) {
core.info('Claude returned an empty review; nothing to post.');
return;
}

try {
await github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pr.number,
commit_id: pr.head.sha,
event: 'COMMENT',
body: summary.trim() || 'See inline comments.',
comments: comments.map(({ path, line, body }) => ({ path, line, side: 'RIGHT', body })),
});
} catch (error) {
// GitHub rejects the whole review if any comment points outside the
// diff. Fall back to a single PR comment so no feedback is lost.
core.warning(`Could not post inline review (${error.message}); posting a plain comment instead.`);
const details = comments.map(({ path, line, body }) => `**\`${path}:${line}\`**\n\n${body}`);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
body: [summary.trim(), ...details].filter(Boolean).join('\n\n---\n\n'),
});
}
1 change: 1 addition & 0 deletions crates/core/src/scenarios/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Protocols that are natively supported by Surfpool will have their IDLs included
- **Pump v1** - Bonding curve launchpad with curve reserve and global config override templates
- **Phoenix Eternal** - Perpetuals venue with trader collateral, mark price, maintenance margin, market fee, withdraw limit, trader capability, stop-loss trigger and delegated permission templates. See [protocols/phoenix-eternal/README.md](./protocols/phoenix-eternal/README.md)
- **PumpSwap v1** - Constant-product AMM with pool state and global config override templates, including canonical pool derivation for migrated pump.fun coins
- **Velocity** - Perpetuals exchange built on the Drift v2 program, with oracle price, perp market risk, exchange status, trading fee and spot market risk templates; an oracle a scenario moves is kept alive. See [protocols/velocity/v1/README.md](./protocols/velocity/v1/README.md)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"an oracle a scenario moves is kept alive" understates the behaviour. The keep-alive import uses an owned address, so every loaded Velocity oracle is reposted, not just the moved one.


For custom protocols, an IDL can be registered at runtime using the [`surfnet_registerIdl`](https://docs.surfpool.run/rpc/cheatcodes#surfnet-registeridl) RPC cheatcode.

Expand Down
Loading
Loading