Commit Graph

30 Commits

Author SHA1 Message Date
Maximilian Schneider 9166b761e9
log taker trade summary (#579)
* 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>
2023-05-13 17:54:27 +02:00
Nicholas Clarke c0ea9970b6
Clarkeni/oracle confidence (#568)
* Add oracle confidence and oracle type to update funding logs.

* Return price and OracleState struct from oracle_price_and_state.
2023-05-05 23:44:14 -07:00
Nicholas Clarke 5d77ba6834
Add PerpForceClosePositionLog and TokenForceCloseBorrowsWithTokenLog (#555) 2023-04-25 13:38:08 +02:00
Nicholas Clarke 37ae7549fb
Clarkeni/perp trade logging (#535)
* 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).
2023-04-13 10:50:39 -07:00
Nicholas Clarke 0ba41e3471
Emit perp fees settled on update_funding. Required to have a full picture of total perp market fees. (#530) 2023-04-06 22:09:50 -07:00
Nicholas Clarke 97895dfb1e
buyback fees with mngo logging (#489)
* buyback fees with mngo logging

* add logging of usdc balances for account_buyback_fees_with_mngo
2023-03-06 14:42:10 +01:00
Christian Kamm f75e3ee656
Serum: Track referrer rebates as Mango platform fees (#469)
And start sharing code between serum3 settle and force cancel
2023-02-22 12:04:21 +01:00
Christian Kamm 8916c28b99
License: Mark instructions GPLv3 and everything else MIT (#454)
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.
2023-02-15 08:42:07 +01:00
Nicholas Clarke 4c93a2740a
Add market index to Serum3OpenOrdersBalanceLog (#429) 2023-02-02 10:01:19 +01:00
Christian Kamm 5328003183
Perp: Reorganize fill events, add client order id to LeafNodes (#426)
- 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
2023-02-02 09:15:06 +01:00
Christian Kamm a91a9ae998
Perp: Fix liq instructions (#424)
- 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
2023-02-02 09:00:37 +01:00
Christian Kamm 93d33edb74
Perp: liq with token instruction (#368)
The new instruction allows the liqor to take over negative pnl (limited
by liqee settle health and settle limits) before applying the bankruptcy
logic.
2023-01-12 09:07:13 +01:00
Nicholas Clarke e2295b2daa
Add instantaneous interest rates to update index log (#314) 2022-12-09 10:14:06 +01:00
Christian Kamm 57e4510b08 Remove mango-macro 2022-12-08 20:48:44 +01:00
Christian Kamm 450007d34b
Perp: Drop client order id from LeafNodes (#323)
This saves 8 bytes and only the FillEvents, FillLogs were populated from
the data.
2022-12-08 19:55:32 +01:00
Christian Kamm c276353289
Implement a stable_price on banks and perp markets (#303)
It is tracked in the StablePriceModel and updated on
TokenUpdateIndexAndRate and PerpUpdateFunding instructions.

The stable price is used in health computations.
2022-11-24 11:55:22 +01:00
Christian Kamm 5731ce8faa
Perp oracle peg feature (#264)
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.
2022-11-08 15:27:56 +01:00
Nicholas Clarke 96344d7de1
Clarkeni/perp logging (#265)
* 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
2022-10-07 12:12:55 -07:00
Nicholas Clarke 01a958cd22
Clarkeni/onchain interest (#244)
* 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.
2022-09-28 23:04:33 -07:00
Nicholas Clarke 1320451e1a
Add serum open orders balance logging. Remove price from token and perp balances. (#236) 2022-09-23 10:42:43 -07:00
Christian Kamm 6c32077d1a Perps: Let all base lot changes go through a function
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.
2022-09-08 13:12:50 +02:00
Nicholas Clarke 704dfcaa27
Clarkeni/loan fee logging (#180)
Logging for loan origination fees and token bankruptcy
2022-08-19 18:50:54 -07:00
Christian Kamm 09fc5f716b Renames in MangoAccount
- Accessors in MangoAccountValue
- PerpPositions -> PerpPosition
2022-08-19 14:58:20 +02:00
Nicholas Clarke 8a1c58e723
FlashLoan: Add flash_loan_type (#164)
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-08-17 12:36:55 +02:00
Nicholas Clarke e4a073c83b
Clarkeni/group logging (#142)
* Add group logging and updateIndexAndRate anchor test
* Bugfix on health account ordering
2022-08-05 10:11:44 -07:00
microwavedcola1 0b2e1e6e6c
Mc/realloc 4 (#119)
Realloc + dynamic mango account

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-07-25 16:07:53 +02:00
microwavedcola1 ef7d2862da
wip: dynamic rates (#98)
* dynamic rates

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

* fmt

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-11 17:08:32 +02:00
Nicholas Clarke 30fc7def77
Add oracle price to update_index logging. (#89)
* Add oracle price to update_index logging.

* Update IDL with changes to update_index instruction and logging.
2022-07-05 11:59:44 -07:00
microwavedcola1 6a99eb893b Fix types
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-01 14:31:47 +02:00
Nicholas Clarke f8da1f6a40
Clarkeni/logging (#81)
* 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>
2022-06-30 14:35:05 +02:00