* add new event for taker trade so arb bots can verify their execution cost without waiting for consume events
Co-authored-by: Nicholas <nicholasgclarke@gmail.com>
* Emit the slot corresponding to the oracle price to PerpUpdateFundingLog.
* Emit a new FilledPerpOrderLog consisting of just the group, perp market and seq num. This will be used to correlate perp fills to the transactions they were matched (not consumed).
To do that, split up the Accounts objects and the instruction
implementations.
GPL code is only used when the "enable-gpl" feature is enabled. That
means compiling the program or running tests need explicit feature
activation now.
- don't store internal order ids: unneeded
- provide the maker client order id for user correlation
- store fees as f32 to waste fewer bytes
- new FillLogV2
- Rename to perp_liq_base_or_positive_pnl and perp_liq_negative_pnl_or_bankruptcy
- Deal with situations where overall asset weight is zero and base position reduction
would not improve liqee health
- Add ability for liqors to take over positive unsettled pnl if that improves liqee health
The new instruction allows the liqor to take over negative pnl (limited
by liqee settle health and settle limits) before applying the bankruptcy
logic.
It is tracked in the StablePriceModel and updated on
TokenUpdateIndexAndRate and PerpUpdateFunding instructions.
The stable price is used in health computations.
This introduces the ability to use oracle peg orders on perp markets.
This PR has significant non-backwards compatible changes, for example all
order trees are now in a single account instead of separate.
* Perp instruction logging
* Onchain funding calculation
* perp_spot_transfers field on perp positions
* Logging on register token, perp market
* Additional fields on update token index logging
* maker and taker volume fields on perp position
* Onchain interest calculation
* Fix to TokenBalanceLog for token_liq_bankruptcy (was previously using liqee liab position for liqor liab position).
* Log cumulative interest when token position is deactivated.
Direct access to base_position_lots and quote_position_native is not
allowed anymore.
Fixes an issue where quote_lots were used instead of quote_native, and
also takes fees into account for the entry price.
* 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>