Skip to content

fix: correct oracle account derivation in liquidate() (N1)#99

Open
0x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/n1-liquidation-oracle-account-mismatch
Open

fix: correct oracle account derivation in liquidate() (N1)#99
0x-SquidSol wants to merge 1 commit intodcccrypto:mainfrom
0x-SquidSol:fix/n1-liquidation-oracle-account-mismatch

Conversation

@0x-SquidSol
Copy link
Copy Markdown
Contributor

Summary

The liquidate() oracle account derivation only checked if indexFeedId was all-zeros, ignoring oracleAuthority. For admin-oracle markets with a non-zero indexFeedId, it derived a Pyth PDA instead of the slab address — causing the on-chain program to reject the transaction with OracleInvalid (0xc).

This meant liquidations silently failed for these markets. Undercollateralized positions went unliquidated.

Both crankMarket() and ADL scanMarket() correctly check oracleAuthority first.

Fix

Use the existing detectOracleMode() helper (already in the file, used by scanMarket()) to derive the oracle account:

Mode Oracle Account
admin slabAddress (regardless of indexFeedId)
hyperp slabAddress
pyth-pinned derivePythPushOraclePDA(feedHex)

Test plan

  • All 133 tests pass
  • Logic now matches crank.ts and adl.ts oracle derivation

🤖 Generated with Claude Code

…e markets (N1)

The liquidate() oracle account derivation only checked if indexFeedId
was all-zeros, ignoring oracleAuthority entirely. For admin-oracle
markets with a non-zero indexFeedId, it derived a Pyth PDA instead
of using the slab address — causing the on-chain program to reject
the transaction with OracleInvalid (0xc).

Both crankMarket() and ADL scanMarket() correctly check
oracleAuthority first and use slabAddress for admin-oracle markets.

Use the existing detectOracleMode() helper (already in the same file
and used by scanMarket()) to derive the oracle account consistently:
- admin → slabAddress (regardless of indexFeedId)
- hyperp → slabAddress
- pyth-pinned → derivePythPushOraclePDA(feedHex)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Warning

Rate limit exceeded

@0x-SquidSol has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 7 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 1 minutes and 7 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 77f8352d-4227-491e-b390-91de770446d0

📥 Commits

Reviewing files that changed from the base of the PR and between 3280971 and a34604d.

📒 Files selected for processing (1)
  • src/services/liquidation.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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