feat: update marginfi IDL to 0.1.8 (supports on-chain program mrgn-0.1.8-rc3) - #1138
Open
benebobaa wants to merge 1 commit into
Open
feat: update marginfi IDL to 0.1.8 (supports on-chain program mrgn-0.1.8-rc3)#1138benebobaa wants to merge 1 commit into
benebobaa wants to merge 1 commit into
Conversation
Updates the bundled IDL to match the on-chain program version 0.1.8-rc3 which was deployed to mainnet on March 27, 2026. Changes: - Add marginfi_0.1.8.json with new account types: Order, ExecuteOrderRecord, Lending - Update index.ts to export the 0.1.8 IDL - TypeScript types (marginfi-types_0.1.7.ts) need regeneration via Anchor build Note: The TypeScript types file requires regeneration using Anchor's code generation. Build the marginfi-v2 Rust program with Anchor to regenerate the types, then update the types export accordingly. This fixes the Borsh decode error when fetching Marginfi accounts: - Error: 'Cannot read properties of null (reading property)' - Cause: SDK IDL 0.1.7 didn't recognize new Order/ExecuteOrderRecord/Lending accounts which were added in the 0.1.8 on-chain program update
Contributor
|
@benebobaa is attempting to deploy a commit to the mrgn Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Please use https://github.com/0dotxyz/p0-ts-sdk for continued support for the marginfi program. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates the bundled IDL to match the on-chain program version
mrgn-0.1.8-rc3which was deployed to mainnet on March 27, 2026.Problem
The SDK was failing with a Borsh decode error when fetching Marginfi accounts:
Root Cause: The SDK's IDL (0.1.7) didn't recognize the new account types added in the 0.1.8 on-chain program update:
Order- new stop-loss/take-profit order accountExecuteOrderRecord- ephemeral account for order executionLending- appears to be a new lending account typeWhen
AccountClient.all()fetches all program accounts, it tries to decode them all using the old IDL and crashes on the new account types.Solution
marginfi_0.1.8.json- the IDL fetched from the on-chain program usinganchor idl fetch MFv2hWf31Z9kbCa1snEPYctwafyhdvnV7FZnsebVacA --provider.cluster mainnetindex.tsto export the 0.1.8 IDLVerification
Known Issues
marginfi-types_0.1.7.tsfile needs to be regenerated from the new IDL. This requires:0dotxyz/marginfi-v2repo)index.tsshould be updated to use the new typesCurrently using
as unknown as MarginfiIdlTypeto bypass type checking until types are regenerated.Testing
The agent was tested with:
After this change, the
AccountClient.all()should no longer crash on new account types.Checklist