Commit Graph

93 Commits

Author SHA1 Message Date
Serge Farny 2d9f248063
liquidator: settle and close open orders in that order (#959) 2024-05-06 11:03:06 +02:00
Serge Farny 98e6f147d4
Liquidator: do not try to settle/close open orders when not using limit orders for rebalancing (#956) 2024-05-06 09:45:03 +02:00
Christian Kamm 8fd7a5cc88 Merge deploy into dev 2024-04-23 11:00:25 +02:00
Christian Kamm d08ef26a99
rust client: rename Client::owner to "authority" (#948)
It could be the owner or the delegate
2024-04-22 14:52:36 +02:00
Christian Kamm 66c6ae1cff liquidator: fix rebalance loops
selling 100% with flash loan swap fee charged on top meant creating a
borrow
2024-04-22 14:10:01 +02:00
Serge Farny bf0d748d2d
Serge/deploy v24+ (#945)
* liquidator: randomly select token/perps for rebalancing to avoid failing at every try if one token is having an issue (#921)

(cherry picked from commit e3a7ed9e32)

* liquidator: do not panic if token or perp rebalancing fails (#927)

(cherry picked from commit 0b7e62e671)

* Liquidator: add Sanctum swap (#919)

liquidator: add sanctum swap
(cherry picked from commit 01d5237162)

* liquidator: add more LST for sanctum swap (#944)

(cherry picked from commit c0b61b3b37)
2024-04-22 13:27:15 +02:00
riordanp 2a6532f1c6
Openbook V2 Integration (#836)
Co-authored-by: Tyler <tjshipe@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
Co-authored-by: Serge Farny <serge.farny@gmail.com>
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2024-04-22 11:37:53 +02:00
microwavedcola1 fb6311e842 Merge branch 'main' into deploy 2024-04-18 15:15:44 +02:00
Serge Farny d0125e9fdf
liquidator: rebalance with openbook (limit order) (#938)
liquidator: rebalance with limit order
2024-04-10 16:47:45 +02:00
Serge Farny 01d5237162
Liquidator: add Sanctum swap (#919)
liquidator: add sanctum swap
2024-04-10 11:35:56 +02:00
Christian Kamm fa32449feb
liquidator: track fallback oracles (#931) 2024-04-04 11:23:58 +02:00
Serge Farny bf6d2a11ec liquidator: forcefully exit process if snapshot job die (#924)
* liquidator: forcefully exit process if snapshot job die

* client: return snapshot_job join handle so it can be watched for early unexpected exit

(cherry picked from commit 2520c7d095)
2024-04-04 09:28:48 +02:00
Serge Farny e38798ed0c
liquidator: add a sequence check in rebalancing (#926)
liquidator: add a sequence check in rebalancing
2024-04-03 11:55:04 +02:00
Christian Kamm 3937590fd1
liquidator: fix withdraws on rebalance (#929)
- always allow them, now that v0.22 is deployed and delegates can
  withdraw small token amounts to the owner's ata
- increase the dust amount to $0.001 to avoid issues where the logic is
  a few lamports off
2024-04-02 14:44:04 +02:00
Serge Farny 2520c7d095
liquidator: forcefully exit process if snapshot job die (#924)
* liquidator: forcefully exit process if snapshot job die

* client: return snapshot_job join handle so it can be watched for early unexpected exit
2024-04-01 14:45:01 +02:00
Serge Farny 0b7e62e671
liquidator: do not panic if token or perp rebalancing fails (#927) 2024-04-01 10:30:49 +02:00
Serge Farny e3a7ed9e32
liquidator: randomly select token/perps for rebalancing to avoid failing at every try if one token is having an issue (#921) 2024-03-27 14:07:32 +01:00
Serge Farny f54bb6f0b0
Serge/liquidator split tcs and liquidation (#914)
liquidator: split TCS triggering and liquidation job

Concurrent execution of candidate lookup and tx building/sending
- Also added an health assertion IX to protect liqor in multi liquidation scenario
- And a timeout for jupiter v6 queries (avoid blocking liquidation because of slow TCS)
2024-03-20 15:25:52 +01:00
Christian Kamm 6f85dfa42d Merge remote-tracking branch 'origin/deploy' into dev 2024-03-14 11:26:33 +01:00
Christian Kamm 4ea7c531ef
liquidator: make alternate routes configurable (#916) 2024-03-13 09:13:07 +01:00
Serge Farny 5affbb9cee
liquidator: add some latency metrics (#904)
liquidator: add some latency metrics
2024-03-07 11:44:23 +01:00
Christian Kamm 54674e4b20 keeper: fix tx size limits on charge collateral fee batching 2024-02-26 09:21:53 +01:00
Serge Farny ab8393b52d
liquidator: avoid logging same oracle error (same token) in loop (#889)
* liquidator: avoid logging same oracle error (same token) in loop
2024-02-21 16:35:28 +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
Serge Farny 7a8d46e362
rust client: remove jupiter v4 (#879)
* rust client: remove jupiter v4

* rust client: remove dead code

* rust client: allow large enum variant for RawQuote enum
2024-02-14 14:20:23 +01:00
Christian Kamm 007cf0da6e
liquidator: make tcs max amount configurable (#874) 2024-02-09 11:31:37 +01:00
Christian Kamm ea91d9d353
rust client: optionally derive prio fees from feed (#866)
This allows connecting to a lite-rpc feed to receive block priority
updates and computing recently good priority fee values based on that.
2024-02-07 12:52:32 +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 43b9cac3a1
Rust client: Allow sending transactions to multiple rpcs (#853) 2024-01-19 16:35:30 +01:00
Christian Kamm ce0713070a Merge remote-tracking branch 'origin/deploy' into dev 2024-01-09 12:31:20 +01:00
Christian Kamm 7a0cb6c8f4
Switch all tokio Interval to MissedTickBehavior::Delay (#840)
Burst can lead to undesired behavior, in particular with rate limits.
2024-01-09 11:25:55 +01:00
Lou-Kamades 9ce6b67831
Add an Orca oracle type (#813)
* deps: add whirlpool crate

* allow oracle to read price from Orca CLMM

* test: add test for raw orca CLMM price

* require the USD/USDC oracle when using a CLMM oracle

* test: add CLMM oracle tests

* use KeyedAccountReader instead of AccountInfoRef for fallback fetching functions

* calculate price for inverted orca pools

* ensure that Orca fallback oracles have USDC side

* remove unused Whirlpool impl

* clmm prices have correct decimals and pyth update slot

* manually deserialize the orca Whirlpool

* refactor: use OracleAccountInfos when checking oracle price

* properly handle inverted clmm prices

* update rs client with OracleAccountInfos struct

* refactor: simplify OracleAccountInfos impl

* add clmm oracle integration test

* use OracleAccountInfos::from_reader in account_retriever

* CLM oracles inherit deviation from supplementary quote oracle

* review fixes

* use f64 division for clmm sqrt price

* standardize fixed to f64 conversion

* review fixes
2024-01-04 11:29:54 -06:00
Christian Kamm 5e5900f94e liquidator: less error spam on bad jup price updates 2023-12-29 10:16:18 +01:00
Christian Kamm b18d0dd154 Rework ErrorTracking
- 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
2023-12-29 10:16:18 +01:00
Christian Kamm eb6622b4fc client/liq: support jupiter api tokens 2023-12-27 14:47:58 +01:00
Christian Kamm e2bfa9a1e6 client: configurable jupiter urls (#800)
(cherry picked from commit 71f0e5cc13)
2023-12-27 14:15:45 +01:00
Christian Kamm d2327f8d11 liquidator: rebalance asynchronously 2023-12-22 09:02:06 +01:00
Christian Kamm 0a55184ec7 liquidator: stop withdraw attempts on delgated accounts 2023-12-22 08:35:21 +01:00
Christian Kamm cdf804e971 liquidator: don't panic when unable to build health cache 2023-12-22 08:11:34 +01:00
Christian Kamm b12b998e3a liquidator: cover errors during tcs execution
previously they could abort the liquidator
2023-12-15 11:55:21 +01:00
Christian Kamm 99cb3d4f4c liquidator: Pick better asset/liab for liq_token 2023-12-15 11:40:25 +01:00
Christian Kamm b6ddd991b0 liquidator: early out when no tcs tx were sent 2023-12-14 21:48:01 +01:00
Christian Kamm 47faa8a7f1 liq: get rid of separate rebalance job (#815)
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)
2023-12-13 09:27:21 +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 5cfbb8386d liquidator: fix token info for same-name, fix delays (#795)
(cherry picked from commit 0483faef1e)
2023-12-13 09:20:52 +01:00
Christian Kamm e8e7e445d3
liq: get rid of separate rebalance job (#815)
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.
2023-12-11 17:41:11 +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 42e31ae859
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
2023-12-05 15:43:38 +01:00