Consolidates
PR | Description |
---|---|
#357 | remove rent from various ixes |
#362 | Bankruptcy handling improvements for super-bankrupt banks |
#364 | Broad refactor |
#370 | Remove Pyth migration functions |
#371 | Remove type layout |
#384 | Panic button to pause protocol |
#373 | Last update time for user accounts |
#382 | PDA-based mrgn accounts |
#372 | New Liquidation approach "Receivership" |
#386 | Emode no brakes |
#391 | Arena sunset ix |
#401 | Various minor fixes |
#394 | Kamino Lending integration |
Summary
- Kamino integration is now live! Allows users to deposit into Kamino Reserves through this program, using their positions as collateral to borrow while continuing to earn any yields or rewards they would normally earn on Kamino! See #394 for more details.
- New liquidation approach: execute liquidation without a mrgn account, simply by withdrawing and repaying as if you are the user! This novel approach also has a slightly higher premium to attract new developers to move over to it! We will support the old approach for the foreseeable future as well. See #372 for more details.
- All on-chain structs and many on-chain utility functions are now represented in the type-crate, which can be built without any dependencies. Rust consumers no longer to need to depend on our entire program with all of its cruft and layers of dependencies!
- Something you wanted missing from type-crate? Contact us or open an issue!
- Fixes to loss socialization and liquidation of heavily bankrupted banks. Certain bankrupted arena banks that were formerly frozen are now eligible to be liquidated. In the future, we expect banks will not be able to enter the super-bankrupt state currently affecting arena unless a price rapidly collapses or liquidators fail for an extended time.
- The global fee admin is now able to suspend all financial transactions in all groups in the entire protocol for a few minutes. This power has a limited number of uses per day (currently 2) and a limited time (currently 30 minutes). The purpose of this power is to respond quickly in event of a suspected hack/exploit or to give groups a brief window to conduct complex risk re-configurations. Once expired, the pause lifts permissionlessly.
- User accounts now have a
last_update
timestamp that can be used to see when they were last mutated in a meaningful way, for example when they last borrowed, deposited, withdrew, etc, but not when they did a no-op task like health pulse. Backend consumers can now use this timestamp as a "dirty flag" to know when they must update a database entry. - User accounts can now be created as a PDA. Legacy user accounts created with a keypair will also be supported indefinitely.
- Removes the 100% initial asset weight limit from emode, now enabling weights up to 200%. LTVs to the moon!
- Arena sunsetting: an arena-only instruction will withdraw all funds from the remaining Arena banks, to be returned to their owners OTC. Non-arena banks, e.g. those on the main mrgn or p0 app, are unaffected.
Important for Integrators
- Mrgn accounts can now be created with a PDA (see marginfi_account_initialize_pda). If you would like a
third_party_id
assigned to just your program, so you can easily fetch all accounts your program has created by CPI, contact us or open an issue in this repo. Seeds are shall-issue, and will be included in the next update, you don't need any special relationship with mrgn to request a seed.
Breaking Changes (Everyone)
- Many instructions require an idl update. Upgrade your IDL to the one attached to this release. We removed mut from various accounts that didn't need it. The only user facing instructions are: LendingAccountBorrow/LendingAccountLiquidate -> removed mut from liquidity vault authority
- Banks that did not yet migrate to the new Pyth oracle model are no longer supported, all functions associated with permissionless migration have been removed. Pyth banks configured in 1.3 and earlier that have not migrated will no longer be able to transact until the admin configures a new oracle. This does not affect any banks in production.
- Any instruction involving a risk check (borrow, withdraw, liquidate, etc) must now also support Kamino banks. Unlike regular banks, these have two oracle accounts: (1) the oracle, and (2) the Kamino reserve. You can still extract these from
oracle_keys
.
Breaking Changes (Rust consumers)
- The "Rent" sysvar has not been needed in a long time and has been removed from various ixes
New instructions
- (global fee admin only)
panic_pause
- suspend all financial interactions (borrow, withdraw, repay, etc) for a short preset time. Can only be called twice per day and twice consecutively. - (global fee admin only)
panic_unpause
- resume all financial interactions - (permissionless)
panic_unpause_permissionless
- reset the global pause state after a pause expires (does not need to be called for ixes to resume) - (group admin only)
lending_pool_add_bank_kamino
- Adds a new Kamino bank - (permissionless)
kamino_init_obligation
- Sets up the obligation for a new Kamino bank, which must occur before it can get deposits. Typically, the admin will do this, but anyone can pay the rent if they're feeling generous. - (permissionless)
kamino_harvest_reward
- Collect "farm rewards" (aka token emissions) from a Kamino lending bank. We currently collect these funds to an account under our control, then airdrop them to users at regular intervals. More details to follow. - (user)
marginfi_account_initialize_pda
- create a mrgn account with a PDA instead of a keypair - (user)
transfer_to_new_account_pda
- transfer an existing mrgn account to a new one that is PDA-based. - (user)
liquidate_start
andliquidate_end
- the novel liquidation approach no longer requires a mfi account. Calling start enables a liquidator to act as if they are the mfi user, but ONLY to withdraw or repay until the end of the tx. The user's health must improve at the end of the tx. For example, a liquidator might do [start, withdraw A, swap A->B on jup, repay B, end]. Typically the value of is A is slightly greater than B, allowing the liquidator to turn a profit. - (user)
kamino_deposit
- deposit funds to a Kamino bank - (user)
kamino_withdraw
- withdraw funds from a Kamino bank
New fields
- user accounts now have
last_update
, tracking the timestamp when they were last mutated in a meaningful way. - user accounts generated with the new PDA approach have the following fields. user accounts generated with the legacy keypair approach use all-zeros for these fields:
- account_index - a seed chosen arbitrarily
- third_party_index - if < 10,000, a seed chosen arbitrarily. third parties can reserve seeds above 10,000 by contacting us.
- bump - the bump used to derive the PDA
- user accounts now have
liquidation_record
, which points to the liquidation record if they have one, or pubkey default if they've never had a receivership liquidation. - the global FeeState now has
panic_state
, which tracks if the protocol is paused and when it can unpause. - groups have
panic_state_cache
, which tracks the global fee state'spanic_state
when propagated (see notes below) - Banks now have
kamino_reserve
/kamino_obligation
- tracks the Kamino position for Kamino banks, Pubkey Default for all other banks. Note thatkamino_reserve
is the second account that needs to be passed for any risk checks related to Kamino banks. - Banks and user balances have a new possible Asset Tag (3 - Kamino)
New accounts
- liquidation records - 1:1 relationship with accounts. the first time any user is liquidated using the Receivership approach, the liquidator must pay to create a liquidation record. This account stores intermediate information during liquidation events and also has a record of the last few successful receivership liquidations events on the associated account
Notes on Pause
- The pause state propagates to groups via propagate_fee_state, which is permissionless. Until propagated, the group is not participating in the pause, and can function normally. Typically, the global fee admin will queue up a pause and propagation to all major groups at the same time. Note that mrgn currently only maintains one group for the main pool you see on the app front page, but this may not always be the case, and anyone can open their own group as well. Message the global fee admin to make sure your group also receives the propagation instruction immediately after any pause.
Notes on Receivership Liquidation
- Like our old approach, this new approach is also permissionless, we encourage third-parties to build liquidators that utilize it.
- The classic liquidation approach will be supported indefinitely, but may be cumbersome to use with future integrations e.g. Kamino positions.
Audit Notes
Kamino-related commit hash and pr notes relate to #394, the original audit report was completed based on our internal private mirror of the public repo.
Hash: 4e7867