* perp: auto close perp market account when needing to open a new one with no slot available
* rust_client: do not send health accounts when deactivating a perp position (not needed on program side)
* rust_client: add perp place order command
Previously serum3_place_order would fail when deposit limits were
exhausted on the payer token side. Now the failure only happens when
payer tokens need to be borrowed.
(cherry picked from commit a4cddf3129)
Previously serum3_place_order would fail when deposit limits were
exhausted on the payer token side. Now the failure only happens when
payer tokens need to be borrowed.
Previously, we tried to keep track of "other" and "trade" realized pnl.
An issue occured when a perp base position went to zero: the way we
computed the trade pnl included potential non-trade unsettled pnl.
That caused follow-up trouble because the value could change sign and
reset the settle limit for trade pnl.
This change aims to simplify in some ways:
- explicitly talk about oneshot-settleable pnl (fees, funding,
liquidation) and recurring-settleable pnl (materialization of settle
limit derived from the stable value of the base position when reducing
the base position)
- instead of directly tracking realized settleable amounts (which
doesn't really work), just decrease the recurring settleable amount
when it exceeds the remaining unsettled pnl
- get rid of the directionality to avoid bugs of that kind
- stop tracking unsettled-realized trade pnl (it was wrong before, and
no client uses it) - we already track position-lifetime realized trade
pnl
(cherry picked from commit ae5907ba3a)
Previously, we tried to keep track of "other" and "trade" realized pnl.
An issue occured when a perp base position went to zero: the way we
computed the trade pnl included potential non-trade unsettled pnl.
That caused follow-up trouble because the value could change sign and
reset the settle limit for trade pnl.
This change aims to simplify in some ways:
- explicitly talk about oneshot-settleable pnl (fees, funding,
liquidation) and recurring-settleable pnl (materialization of settle
limit derived from the stable value of the base position when reducing
the base position)
- instead of directly tracking realized settleable amounts (which
doesn't really work), just decrease the recurring settleable amount
when it exceeds the remaining unsettled pnl
- get rid of the directionality to avoid bugs of that kind
- stop tracking unsettled-realized trade pnl (it was wrong before, and
no client uses it) - we already track position-lifetime realized trade
pnl
The liqor liquidation fee and platform liquidation fee for the asset and
liab token are both payed by the liqee.
The platform liquidation fee is added to the Bank's
collected_fees_native and tracked in collected_liquidation_fees.
(cherry picked from commit 8383109f0d)
* rename usd_opt to usdc_opt in OracleAccountInfos
* use fallbacks when fetching bank+ price in AccountFetcher struct
* feat: add derive_fallback_oracle_keys to MangoGroupContext
* test: properly assert failure CU in test_health_compute_tokens_fallback_oracles
* provide fallback oracle accounts in the rust client
* liquidator: update for fallback oracles
* set fallback config in mango services
* support fallback oracles in rust settler + keeper
* fix send error related to fetching fallbacks dynamically in tcs_start
* drop derive_fallback_oracle_keys_sync
* add fetch_multiple_accounts to AccountFetcher trait
* revert client::new() api
* deriving oracle keys uses account_fetcher
* use client helpers for deriving health_check account_metas
* add health_cache helper to mango client
* add get_slot to account_fetcher
* lint
* cached account fetcher only fetches uncached accounts
* ensure keeper client does not use cached oracles for staleness checks
* address minor review comments
* create unique job keys for CachedAccountFetcher.fetch_multiple_accounts
* fmt
* improve hashing in CachedAccountFetcher.fetch_multiple_accounts
---------
Co-authored-by: Christian Kamm <mail@ckamm.de>
The liqor liquidation fee and platform liquidation fee for the asset and
liab token are both payed by the liqee.
The platform liquidation fee is added to the Bank's
collected_fees_native and tracked in collected_liquidation_fees.