Skip to content

refactor(tests): update builder codes error code#2160

Closed
ChesterSim wants to merge 1 commit intomasterfrom
chester/update-tests
Closed

refactor(tests): update builder codes error code#2160
ChesterSim wants to merge 1 commit intomasterfrom
chester/update-tests

Conversation

@ChesterSim
Copy link
Collaborator

@ChesterSim ChesterSim commented Mar 23, 2026

Summary by CodeRabbit

  • New Features

    • Added event tracking for insurance fund admin withdrawals, capturing withdrawal details and vault state changes.
  • Chores

    • Removed Pyth pull-oracle related instructions from the protocol.
    • Adjusted internal error code mappings to accommodate new validation rules.

@coderabbitai
Copy link

coderabbitai bot commented Mar 23, 2026

Walkthrough

This PR updates the Drift protocol IDL schema and test assertions. It removes legacy Pyth pull-oracle instruction definitions, introduces a new AdminWithdrawFromInsuranceFundRecord event type, adds an InvalidInsuranceFundWithdrawalRecipient error code, and renumbers subsequent error codes accordingly. A corresponding test assertion is updated to reflect the new error code mapping.

Changes

Cohort / File(s) Summary
IDL Schema Updates
sdk/src/idl/drift.json
Removed four Pyth pull-oracle instruction entries; added AdminWithdrawFromInsuranceFundRecord event with nine fields (timestamp, market index, admin, withdrawal amount, shares burned, vault/protocol share snapshots); introduced InvalidInsuranceFundWithdrawalRecipient error (code 6146); incremented all subsequent error codes by +1.
Test Assertion Update
tests/builderCodes.ts
Updated error code expectation in "revoke builder with open orders" test from 0x18b3 to 0x18b4 to align with renumbered error codes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • program: withdraw from if vaults #2120: Implements the admin insurance-fund withdrawal feature, including the AdminWithdrawFromInsuranceFundRecord event and InvalidInsuranceFundWithdrawalRecipient error that are reflected in this IDL update.

Poem

🐰 Schemas shift and codes align,
New events in the ledger shine,
Insurance fund withdrawals flow,
Error numbers rearrange their show,
The protocol evolves once more! 🌱

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(tests): update builder codes error code' accurately describes the primary change: updating error code expectations in the builder codes test file from 0x18b3 to 0x18b4.
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.


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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@sdk/src/idl/drift.json`:
- Around line 18967-18972: The new error entry
"InvalidInsuranceFundWithdrawalRecipient" was inserted with code 6146 which
shifts all subsequent numeric mappings; revert this by either appending
"InvalidInsuranceFundWithdrawalRecipient" to the end of the existing published
error list (so it gets a new unused code) or, if you must insert here, renumber
only the new entry to an unused code and leave all existing codes unchanged;
ensure the mapping for "InvalidInsuranceFundWithdrawalRecipient" is referenced
by its name (not a shifted numeric) in any schema or docs and run any error-code
consistency checks to confirm no other codes changed.
- Around line 19156-19160: The JSON entry for the error with code 6184 (name:
MaxIFWithdrawReached) has an incorrect message value
"InvalidSpotPositionDetected"; update the "msg" field for the error object
identified by code 6184 / name MaxIFWithdrawReached to a clear, accurate message
such as "MaxIFWithdrawReached" or "MaxInsuranceFundWithdrawReached" so
clients/operators receive a descriptive, relevant error when the insurance fund
withdrawal cap is reached.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db8d7efa-6908-494e-947d-ffb11827aaa0

📥 Commits

Reviewing files that changed from the base of the PR and between fe48d95 and 4fadee6.

📒 Files selected for processing (2)
  • sdk/src/idl/drift.json
  • tests/builderCodes.ts

Comment on lines 18967 to +18972
"code": 6146,
"name": "InvalidInsuranceFundWithdrawalRecipient",
"msg": "Insurance fund withdrawal recipient must be the designated treasury address"
},
{
"code": 6147,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Preserve existing error codes.

Adding InvalidInsuranceFundWithdrawalRecipient at 6146 shifts every subsequent numeric mapping. That breaks any client, test, or indexer keyed on error numbers. Please allocate new codes at the end of the published list instead, or treat this as a deliberate breaking API change.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/src/idl/drift.json` around lines 18967 - 18972, The new error entry
"InvalidInsuranceFundWithdrawalRecipient" was inserted with code 6146 which
shifts all subsequent numeric mappings; revert this by either appending
"InvalidInsuranceFundWithdrawalRecipient" to the end of the existing published
error list (so it gets a new unused code) or, if you must insert here, renumber
only the new entry to an unused code and leave all existing codes unchanged;
ensure the mapping for "InvalidInsuranceFundWithdrawalRecipient" is referenced
by its name (not a shifted numeric) in any schema or docs and run any error-code
consistency checks to confirm no other codes changed.

Comment on lines 19156 to 19160
{
"code": 6183,
"code": 6184,
"name": "MaxIFWithdrawReached",
"msg": "InvalidSpotPositionDetected"
},
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

Fix the message for MaxIFWithdrawReached.

This error currently surfaces InvalidSpotPositionDetected, which is unrelated and will mislead clients and operators when the IF withdrawal cap is hit.

💡 Proposed fix
     {
       "code": 6184,
       "name": "MaxIFWithdrawReached",
-      "msg": "InvalidSpotPositionDetected"
+      "msg": "MaxIFWithdrawReached"
     },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
"code": 6183,
"code": 6184,
"name": "MaxIFWithdrawReached",
"msg": "InvalidSpotPositionDetected"
},
{
"code": 6184,
"name": "MaxIFWithdrawReached",
"msg": "MaxIFWithdrawReached"
},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@sdk/src/idl/drift.json` around lines 19156 - 19160, The JSON entry for the
error with code 6184 (name: MaxIFWithdrawReached) has an incorrect message value
"InvalidSpotPositionDetected"; update the "msg" field for the error object
identified by code 6184 / name MaxIFWithdrawReached to a clear, accurate message
such as "MaxIFWithdrawReached" or "MaxInsuranceFundWithdrawReached" so
clients/operators receive a descriptive, relevant error when the insurance fund
withdrawal cap is reached.

@ChesterSim ChesterSim closed this Mar 23, 2026
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.

1 participant