* service-mango-health: add a new service that compute health for all mango accounts and persist an history in postgres sql
(cherry picked from commit 6aa8a883f4)
liquidator: add a way to restrict token accepted by the liquidator
- add allow/forbid list of token for liquidation & conditional token swap triggering
- add allow/forbid list for perp market liquidation
- housekeeping: extract cli args to a dedicated file
- move more hardcoded thing to config and stop using token name (replace with token index)
rust client:
- add serum3 place order to command
- add serum3 create open orders command
- add serum3 close open orders command
- auto create serum3 open orders if needed when placing a new order
- auto close serum3 slot if needed when placing a new order & also close unused token if needed to place a serum3 order
- New permissionless instruction to regularly charge collateral fees
- Bank and group configuration to set rate and interval
- Keeper addition to call the instruction
* 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
* 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>
- keep track of different error types per key
- skip for a given duration once too many errors came in
- wipe if no new errors are seen for a while
- simplify logging of actively skipped cases
Previously, the separate job and the post-liquidation rebalance could
run at the same time and would occasionally perform the same action at
the same time, leading to overshooting.
Now rebalancing never happens twice. In the future it should potentially
just run separately from liquidation, but that needs a review of the
assumptions the liquidation job is making first.
(cherry picked from commit e8e7e445d3)
- Don't just restart on new listings, but also on significant changes to
old listings such as oracle changes.
- Cover the liquidator and settler in addition to the keeper.
(cherry picked from commit ce16d79b13)
Previously, the separate job and the post-liquidation rebalance could
run at the same time and would occasionally perform the same action at
the same time, leading to overshooting.
Now rebalancing never happens twice. In the future it should potentially
just run separately from liquidation, but that needs a review of the
assumptions the liquidation job is making first.
- limit deposits (via deposit, flash loan, tcs)
- limit potential deposits via openbook settle
by restricting placable orders via potential_serum_tokens
- introduce Serum3PlaceOrderV2 for this purpose
- account for new limits in liquidator, max_swap
(cherry picked from commit 42e31ae859)
- limit deposits (via deposit, flash loan, tcs)
- limit potential deposits via openbook settle
by restricting placable orders via potential_serum_tokens
- introduce Serum3PlaceOrderV2 for this purpose
- account for new limits in liquidator, max_swap
- Don't just restart on new listings, but also on significant changes to
old listings such as oracle changes.
- Cover the liquidator and settler in addition to the keeper.