mrgn-0.1.8 #515
jgur-psyops
announced in
Announcements
mrgn-0.1.8
#515
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Orders
Introduces "Orders". An Order is a stop-loss and/or take-profit trigger that a "Keeper" can permissionlessly execute. For example, a user is lending $100 in SOL and borrowing $50 in BONK. They set a take-profit at $70. If SOL goes to $120, the Keeper can execute, closing their BONK position and leaving them with $70 in SOL. A Keeper can also execute if BONK falls to $30, likewise leaving the user with $70 in SOL.
Project Zero will run Keepers initially upon feature public launch (ETA Q2/Q3 2026), but any third-party can run a Keeper. Users configure their max slippage tolerance when setting the order, Keepers are permitted to keep whatever is leftover after completing the order execution as profit, and they also get to keep the rent from the Order (currently worth about $0.25). If you are an integrator expecting to use this feature, you are strongly recommended to run your own Keepers. Keepers are permissionless, any wallet can be a Keeper.
Juplend
Juplend banks can now be used as collateral! See
JUPLEND_INTEGRATION.mdfor more details of how juplend banks work.Other
"Rate Limiter" feature: Implements a sliding window rate limiter system at both bank and group levels to protect against rapid fund extraction. Limits are net outflow: outflows minus inflows, so deposits/repays offset usage. Banks enforce a daily limit in tokens, and the group (all banks that live on the 0.xyz app) enforces a USD limit. Flashloans and liquidations do not affect the window.
Substantial reductions in CU and heap usage, especially in receivership liquidation flows, enabling liquidators to burn more CU on other tasks, especially for accounts with more positions.
Breaking Changes (Rust Integrators only)
lending_account_deposit:groupaccount is now writable (mut).lending_account_repay:groupaccount is now writable (mut); forrepay_all = truethere is new remaining-accounts validation requiring risk accounts for all active balances.lending_account_borrow:groupaccount is now writable (mut).kamino_deposit,solend_deposit,drift_deposit:groupaccount is now writable (mut).lending_pool_pulse_bank_price_cache:groupaccount is now writable (mut).Breaking Changes (everyone)
lending_account_withdraw,kamino_withdraw,solend_withdraw,drift_withdraw: withwithdraw_all = true, now requires the bank being withdrawn to be passed last in risk accounts (formerly omitted entirely).Example
User has balances:
Before this update:
After this update:
Noting that the bank to closed does NOT respect the all-accounts-must-be-ordered-by-bank rule: it is always passed last.
New Accounts
Order- tracks information about a single take-profit and/or stop-loss order for an asset/liability pair on the user's account.ExecuteOrderRecord- an ephemeral account that is always closed in the same TX it is opened in, used to pass information between the start and end of order execution. None of these should exist in production.New Instructions
Orders
PlaceOrder(user) - Place a new Stop Loss, Take Profit, or Both type Order on a pair of balances the user currently holds.StartExecuteOrder(Keeper) - Keepers run this to begin the execution of an Order. Must be at the start of the tx, andEndExecuteOrdermust appear last in the tx. Withdraw/Repay of the involved balances typically follows this ix. Requires a risk check of just the balances involved in the Order.EndExecuteOrder(Keeper) - Must be the last tx in executing an Order. Requires a risk check of just the balances involved in the Order.CloseOrder(user) - Clear an unwanted Order, user gets their rent back.SetKeeperCloseFlags(user) - Enables the Keeper to close Orders viaKeeperCloserOrder, typically useCloseOrderinstead.KeeperCloseOrder(Keeper) - Close an Order on an account where neither of the original positions exists or all the tags have been cleared by the userJuplend
lendingPoolAddBank_juplend(admin) - Adds a wrapped JupLend bank to a group. The bank startsin
Pausedstate and is unusable untiljuplend_init_positionruns.juplendInitPosition(permissionless, one-time per bank) - Performs a seed deposit into JupLendand flips the bank from
PausedtoOperational. This activates the bank for user flows.juplendDeposit(amount)(user) - Deposit underlying tokens (native amount). Internally callsJupLend
updateRate, deposits through CPI, verifies minted fTokens, and credits the user'smarginfi position.
juplendWithdraw(amount, withdraw_all)(user) - Withdraw underlying tokens (native amount).Internally calls JupLend
updateRate, burns fTokens via CPI, then transfers tokens from thewithdraw intermediary ATA to the user's destination token account.
Other
configureBankRateLimits(admin) - Configure hourly/daily bank-level outflow limits for withdraw/borrow (in native token units).configureGroupRateLimits(admin) - Configure hourly/daily group-level aggregate outflow limits (in USD). Same net-outflow model, applied across the group.Changes to Existing Instructions
Admin-only
marginfi_group_configure: admin key args changed from requiredPubkeytoOption<Pubkey>(new_admin,new_emode_admin,new_curve_admin,new_limit_admin,new_emissions_admin,new_metadata_admin,new_risk_admin), whereNonenow means "leave unchanged".init_global_fee_stateandedit_global_fee_state: added argsorder_init_flat_sol_feeandorder_execution_max_fee.lending_pool_update_emissions_parameters: Fixed a bug where the emissions admin could update other flags.User
lending_account_deposit:groupaccount is now writable (mut).lending_account_repay:groupaccount is now writable (mut); forrepay_all = truethere is new remaining-accounts validation requiring risk accounts for all active balances.lending_account_borrow:groupaccount is now writable (mut).kamino_deposit,solend_deposit,drift_deposit:groupaccount is now writable (mut).lending_pool_pulse_bank_price_cache:groupaccount is now writable (mut).lending_account_withdraw,kamino_withdraw,solend_withdraw,drift_withdraw: withwithdraw_all = true, now requires the bank being withdrawn to be passed last in risk accounts (formerly omitted entirely).lending_account_repay,lending_account_withdraw,kamino_withdraw,drift_withdrawnow allowed during order-execution context.Liquidator
start_liquidationinstruction gating was extended: allowed pre-actions now include JuplendupdateRate; allowed body instructions now includeJUPLEND_WITHDRAW.start_liquidation,start_deleverage,end_liquidation,end_deleverage,lending_account_start_flashloan, andlending_account_end_flashloancannot run during Order execution.Other Information
Consolidates
Minor bugfixes
test-program-remixscript corrupts metadata and requires ananchor cleanwhen the program is updated, however the tests now build to a different target directory, which increases disk usage.BlockhashNotFoundsome longer Rust tests occasionally run into.Credits
Thank you to https://github.com/abelmarnk for contributing most of the work to the Orders feature.
Audit Information
TBD
Release information
Staging (stag8sTKds2h4KzjUw3zKTsxbqvT4XKHdaR9X9E6Rct) - Approximately Feb 18, 2026
Mainnet - ETA late March 2026
This discussion was created from the release mrgn-0.1.8.
Beta Was this translation helpful? Give feedback.
All reactions