-
Notifications
You must be signed in to change notification settings - Fork 51
Open
Description
Hi
Functions like the below don't mutate the RefMut that they're provided, and so they could be simplified by taking a reference.
pub fn meets_initial_margin_requirement(
user: &User,
- user_positions: &RefMut<UserPositions>,
+ user_positions: &UserPositions,
markets: &Ref<Markets>,
) ...The benefit of taking a reference is that it simplifies the function requirements for someone who wants to call the function from outside of your program.
Otherwise one has to use bytemuck to get the type, deref to copy, then create a new RefCell (unless I missed something).
Anchor has a check to prevent trying to get a RefMut from an external program, rightly as it wouldn't own the account.
Metadata
Metadata
Assignees
Labels
No labels