Releases: mrgnlabs/mrgn-ts
Major SDK Update 🚀 – Advanced Transaction Builders & Enhanced Staked Collateral Support
Major SDK Update 🚀
This release brings significant improvements, optimizations, and new features to the SDK—focusing on transaction builders, processing pipelines, and staked collateral support. Please update your implementation if you are using any transaction builders, as there are context and syntax changes (see provided JSDoc documentation for each function).
Breaking Changes
Flashloan Builder Overhaul
- Updated Builders:
- Builders such as
makeLooperTx
andmakeRepayWithCollateralTx
have been completely revamped. - These changes optimize transaction size and prevent instruction overflow.
- Builders such as
- Action Required:
- Update any code that utilizes these flashloan builders to accommodate the new builder logic and syntax.
Return Type Modification
- New Return Type:
- All transaction builders now return a
SolanaTransaction
, which is an extended version of the standard Solana web3.jsTransaction
andVersionedTransaction
.
- All transaction builders now return a
- Enhanced Properties:
- The new return type includes additional properties:
type
: Enum representing the available SDK actions.signers
: An array of signers required for the transaction.addressLookupTables
: Lookup tables used during transaction signing and decompilation.unitsConsumed
: A value (default or dynamically updated) to help compute the priority fee.
- The new return type includes additional properties:
- Impact:
- Adjust your type expectations and any transaction processing logic to handle the extended properties.
🔄 Transaction Builder Enhancements
-
Updated Builder Syntax
account.make<Action>Tx
functions now include minor context and syntax changes to allow for greater customization.- Flashloan Builders:
- Builders such as
makeLooperTx
andmakeRepayWithCollateralTx
have been revamped to optimize transaction size and prevent instruction overflow.
- Builders such as
-
Action Required:
- Update Your Code: Ensure you update your transaction builder usage to match the new syntax.
💼 Extended Solana Transaction Types
All builders now return a SolanaTransaction
, an extension of the standard Solana web3.js Transaction
and VersionedTransaction
. This extended type includes:
type
: Enum representing the available SDK actions.signers
: An array of signers required for the transaction.addressLookupTables
: Lookup tables used during transaction signing and decompilation.unitsConsumed
: A value (default or dynamically updated) to help compute the priority fee, ensuring an optimal landing rate.
Benefits:
- Improved transaction inspection and decompilation.
- Enhanced integration with custom transaction processing pipelines.
⚙️ Advanced Transaction Processing Pipeline
The new processing flow is modular and highly optimized for both standard and flashloan transactions. There are two ways to access the pipeline:
-
Within MarginfiAccountWrapper Actions:
- All account actions (e.g., deposit, withdraw, borrow) include the processing pipeline as part of their internal logic.
-
Standalone from the Client:
- Use the standalone function
processTransactions
or leverage prefilled configuration viaclient.processTransactions
.
- Use the standalone function
Pipeline Features
-
Simulate to Fetch Compute Unit (CU) Limits:
- The transaction is simulated (ignoring the blockhash) to determine the required compute unit size.
- The CU limit instruction is then updated accordingly.
-
Transaction Formatting via
formatTransactions
:- Heavily Optimized for Flashloans:
formatTransactions
is tailored for flashloan transactions to ensure maximum throughput and reliability.
- Ad-hoc Integration:
- This step can be integrated ad-hoc into your existing transaction processing logic.
- Updates Blockhash:
- Ensures the transaction uses the most recent blockhash.
- Jito Bundles Support:
- Appends a bundle tip if the transaction is destined for a jito bundle.
- Measures transaction size to decide whether the bundle tip should be appended inline or sent as a separate transaction.
- Note: Flashloan transactions will always have the bundle tip appended as a separate transaction due to fixed instruction index constraints.
- Accurate Priority Fee Assignment:
- Uses the computed CU size from simulation to assign a precise priority fee when sending over RPC.
- Optional Transaction Tagging:
- If
addTransactionTags
is enabled, a tag corresponding to the transaction action is added for easier parsing.
- If
- Heavily Optimized for Flashloans:
-
Pre-Execution Simulation:
- An additional simulation step is performed to validate the transaction before waiting for it to land.
-
Flexible Execution:
- Transactions are routed through jito bundles or RPC based on your configuration, with built-in fallbacks for optimal execution.
- Special routing logic is applied for flashloan transactions.
⭐ Additional Enhancements
-
Enhanced Flashloan Support 🏦
- Improved flashloan handling and execution.
- More efficient processing of flashloan transactions.
-
More Configurable SDK Functions ⚙️
- New options to fine-tune SDK behavior.
- Increased flexibility for integrators.
-
Optimized Flashloan Transaction Processing ⚡
- Reduced overhead.
- Improved speed and reliability.
-
Full JSDoc Support 📖
- Comprehensive documentation for improved developer experience.
- Enhanced type safety and inline guidance.
-
Staked Collateral Support 🔐
- New Functionality:
- The SDK now includes
makeAddPermissionlessStakedBankIx
within the group class to create new staked banks permissionlessly. - Pricing functions have been updated to handle this new staked collateral type.
- The SDK now includes
- Future Expansion:
- This functionality will be further expanded in future releases.
- For a full implementation (including uploading metadata and creating single SPL stake pools), please refer to:
mrgn-ts/apps/marginfi-v2-ui/src/pages/staked-assets/create.tsx
.
- New Functionality:
-
General Improvements:
- Resolved multiple issues from previous versions.
- Overall performance optimizations and stability improvements.
Feel free to reach out with any questions or feedback regarding these changes. Happy coding!