Commit Graph

106 Commits

Author SHA1 Message Date
Serge Farny e4098b4550
RustClient: propagate error in chain data fetcher instead of panicking (#952) 2024-04-25 14:30:57 +02:00
Christian Kamm 1ea4528557 Merge remote-tracking branch 'origin/dev' into dev 2024-04-23 11:01:06 +02:00
Christian Kamm 8fd7a5cc88 Merge deploy into dev 2024-04-23 11:00:25 +02:00
Christian Kamm ec2d10af6e
Allow the insurance fund to be for any bank (#946)
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2024-04-23 09:17:53 +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 0fe18b59af rust client: fix withdraws as delegate
they need to go to the owner's ata
2024-04-22 14:20:32 +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
Christian Kamm 4250e06364 fix build 2024-04-22 13:14:48 +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
Serge Farny c0b61b3b37
liquidator: add more LST for sanctum swap (#944) 2024-04-18 15:17:34 +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
Serge Farny e090104c69
keeper: add CU estimate for perp update funding, perp consume events and token update index & rates (#937) 2024-04-09 10:50:35 +02:00
Serge Farny 70b7bc74d8 rust client: add a CU estimate for token withdrawal (#934)
(cherry picked from commit 55105e085f)
2024-04-08 12:44:55 +02:00
Serge Farny 55105e085f
rust client: add a CU estimate for token withdrawal (#934) 2024-04-08 12:43:40 +02:00
riordanp 090ef649d5
Allow liquidator delegates to withdraw (#932)
* Add token_withdraw_as_delegate_instructions method
2024-04-04 15:43:28 +01: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
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 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
microwavedcola1 f2442428b6 Merge branch 'main' into deploy 2024-03-10 14:26:29 +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 27ecc14000 Merge tag 'program-v0.22.0' into deploy 2024-03-04 11:32:42 +01:00
Serge Farny a6ed29b5a1 service-mango-health: read env variable for more configuration entries (#901)
(cherry picked from commit af9b21c430)
2024-03-01 17:08:33 +01:00
Serge Farny af9b21c430
service-mango-health: read env variable for more configuration entries (#901) 2024-03-01 17:07:49 +01:00
Serge Farny a06801db5c service-mango-health: monitors/historizes accounts health (#890)
* 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)
2024-03-01 11:24:56 +01:00
Serge Farny 6aa8a883f4
service-mango-health: monitors/historizes accounts health (#890)
* service-mango-health:  add a new service that compute health for all mango accounts and persist an history in postgres sql
2024-02-29 17:05:29 +01:00
Lou-Kamades 6b13841513 add TokenBalanceLog in token_charge_collateral_fees (#894)
* add TokenBalanceLog in token_charge_collateral_fees

* increase cu_per_charge_collateral_fees_token

(cherry picked from commit e7f9af9261)
2024-02-29 08:10:13 +01:00
Lou-Kamades e7f9af9261
add TokenBalanceLog in token_charge_collateral_fees (#894)
* add TokenBalanceLog in token_charge_collateral_fees

* increase cu_per_charge_collateral_fees_token
2024-02-28 09:31:00 -08:00
Lou-Kamades 4c91d36255
Add raydium CLMM oracle fallbacks (#856)
* add RaydiumCLMM oracle type

* add deserializing raydium pool state

* test: consolidate clmm oralce unit tests

* test: add failure check to test_orca_fallback_oracle

* test: add test_raydium_fallback_oracle

* restore get_quote_oracle()

* ensure RaydiumCLMM is a valid fallback type
2024-02-26 09:45:14 -08:00
Christian Kamm 54674e4b20 keeper: fix tx size limits on charge collateral fee batching 2024-02-26 09:21:53 +01:00
Serge Farny 5d29eb2f0b
Rust client: auto close spot account if needed to place a new order (#877)
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
2024-02-16 14:01:18 +01:00
Christian Kamm 34d86ef0f4
collateral fees: better compute estimation (#881) 2024-02-16 11:30:32 +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 e57dcdc2a9
Add collateral fees (#868)
- New permissionless instruction to regularly charge collateral fees
- Bank and group configuration to set rate and interval
- Keeper addition to call the instruction
2024-02-13 12:39:28 +01:00
Serge Farny 08a5ee8f53
rust client: Perp - Auto close account when needed (#875)
* 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
2024-02-09 11:19:52 +01:00
Christian Kamm dd9ea78dde Settler: Fix bad health accounts in tcs_start ix (#871)
(cherry picked from commit 9f4cb0f776)
2024-02-07 14:13:14 +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 9f4cb0f776
Settler: Fix bad health accounts in tcs_start ix (#871) 2024-02-07 11:42:01 +01:00
Christian Kamm 6c6a75d90d
liquidator: batch serum-cancel step (#861) 2024-01-29 15:07:24 +01:00
Christian Kamm ed682cfd84 rs client: fix construction without explicit errors-by-type 2024-01-29 13:37:44 +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 511814ca97
Rust client: Revamp transaction confirmation (#850)
- Allow user configuration of confirmation settings
- Provide a timeout setting, default is 60s
2024-01-17 10:30:25 +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 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