Commit Graph

20 Commits

Author SHA1 Message Date
Christian Kamm 54674e4b20 keeper: fix tx size limits on charge collateral fee batching 2024-02-26 09:21:53 +01:00
Serge Farny 338a9cb7b8
liquidator: add allow/forbid token list (#883)
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)
2024-02-19 10:20:12 +01:00
Christian Kamm d9a9c7d664
liquidation: Add flag to disable asset liquidation (#867)
This can be used to remove the oracle dependency for tokens with zero maint asset
weight that are not borrowable.
2024-02-07 12:52:01 +01:00
Christian Kamm 6c6a75d90d
liquidator: batch serum-cancel step (#861) 2024-01-29 15:07:24 +01:00
Lou-Kamades db98ba5edf
Use fallback oracles in Rust client (#838)
* 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>
2024-01-23 10:26:31 -06:00
Christian Kamm cdf804e971 liquidator: don't panic when unable to build health cache 2023-12-22 08:11:34 +01:00
Christian Kamm 99cb3d4f4c liquidator: Pick better asset/liab for liq_token 2023-12-15 11:40:25 +01:00
Christian Kamm 9ba0004760 bins: Fix restarting on new or changed listings (#802)
- 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)
2023-12-13 09:27:04 +01:00
Christian Kamm e7bfa4e03e Deposit limits (#806)
- 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)
2023-12-05 15:57:26 +01:00
Christian Kamm 7af1d58558
Some clippy fixes (#776) 2023-11-08 09:51:36 +01:00
Christian Kamm f690514638
rust client: ix cu limits based on health compute cost (#768)
Many instructions now return PreparedInstructions instead of a direct
Instruction or Vec<Instruction>. That way they can keep track of the
expected cu cost of the instructions for the compute limit instruction
that gets added once all instructions are made.
2023-11-03 11:20:37 +01:00
Christian Kamm 0f10cb4d92
client/liquidator: jupiter v6 (#684)
Add rust client functions for v6 API that are usuable in parallel to the v4 ones.
2023-08-24 16:45:01 +02:00
Christian Kamm 1f55d549a6
liquidator: execute tcs with volume-weighted randomness (#670) 2023-08-11 12:08:34 +02:00
Christian Kamm a7705a2a1b
liquidator: Allow overriding compute limit for potentially costly ix (#669) 2023-08-09 15:26:13 +02:00
Christian Kamm db8f5ae30d liquidator: when rebalancing allow multi-hop jupiter routes
and if that doesn't fit into a transaction, try a direct route with USDC
or SOL.
2023-07-12 08:57:21 +02:00
Christian Kamm c58ee91356 Client: jupiter swap and tx builder improvements
- jupiter swap now supports multiple hops
- tx builder can check resulting tx size
2023-07-12 08:57:21 +02:00
Christian Kamm b8376b4b89
logging improvements (#641)
- switch logging to tracing crate
- update liquidator logging to use tracing features
2023-07-12 08:38:38 +02:00
Christian Kamm 35064d4ab0
Token conditional swaps (#604)
Users can request token swaps to happen when the oracle price
is within a price band. Once the price is right, an executor can
trigger the swap. The executors are rewarded with a premium
over the oracle price.

This allows limit and stop loss orders on arbitrary spot pairs.

The PR comes with basic ts support and adjustments to the liquidator,
to execute available token conditional swaps.

Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2023-07-03 14:09:11 +02:00
Christian Kamm 5fc7aa1092
Configurable perp settle token (#550)
This changes perp market margining to no longer assume all pnl is in USD
while settlement is in USDC. Instead, a configurable settle token is used for
pnl and settlement, defaulting to USDC. 

There is no difference while the USDC price is forced to $1 and the init and liab
weights are 1. But with this patch, it becomes possible to change that.

For now it is not recommended to use a token other than USDC or USDT (or
another USD targeting stable token) for perp settlement.

The patch also updates all insurance vault use to be aware that the insurance
fund is not in USD but in USDC and apply the USDC price before payouts.
To do this, the previous PerpLiqNegativePnlOrBankruptcy was replaced by
a new PerpLiqNegativePnlOrBankruptcyV2 instruction.

Co-authored-by: microwavedcola1 <89031858+microwavedcola1@users.noreply.github.com>
2023-05-17 15:50:05 +02:00
Christian Kamm 7b9e19cc08
Organize paths, rename crates (#466)
liquidator, keeper, cli and settle-bot moved to bin/
client moved to lib/client

All crates have a "mango-v4-" prefix
2023-02-20 14:08:38 +01:00