Track cumulative net deposits (deposits - withdraws) using prices at the time of the deposit and withdraw.
This is used for calculating overall pnl (across all tokens).
I want to store UI amount * UI price = (native amount / base decimals) * (oracle price * base decimals / quote decimals) => native amount * oracle price / quote decimals.
I have used f32 here to reduce the space required on the mango account - we don't need so much precision for this as it's purely a display value.
I've also included a field for net_settled - this will be used for perp pnl but is not implemented yet (as perp settling instructions are not ready).
Co-authored-by: Christian Kamm <mail@ckamm.de>
- rearrange structs to have gPA data in front and add comments about the
offsets being relevant
- add insuranceMint to group creation in client
- drop quoteTokenIndex storage on PerpMarket
- fixes to editAccount in example1-user and client
* Add logging
* Added new_fixed_order_account_retriever to allow us to more easily access oracle prices outside of health calculations for logging purposes
* Add token balances logging to token and token liquidation and add logging to margin trade
* rust format
* fix clippy errors
* Address PR requested changes
* fix flash_loan
* Recalculate raw_token_index in token withdraw to account for position becoming inactive
* Fix retrieving oracle for logging
in get_mut_or_create(), return the raw index into the account's token
positions as well as the index into active positions only. The latter
index is useful for indexing into banks in the health account list.
* Add logging flash_loan2 and flash_loan3
* Refactoring flash loan logging
Co-authored-by: Christian Kamm <mail@ckamm.de>
FlashLoan2 requires the user to set up transfers to and from the Mango
vault accounts. This version directly provides the loaned funds into a
target token account and repays everything that exceeds the initial
token account balance at the end.
For FlashLoan users had to pass the target cpi programs, accounts and
data to the FlashLoan instruction itself.
The new API allows existing instructions to be used unchanged, they
just need to be bracketed by FlashLoan2Begin and FlashLoan2End.