Commit Graph

2464 Commits

Author SHA1 Message Date
Christian Kamm b5d49381ed rust clippy fix 2024-02-09 09:09:42 +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 712a2e3bd6
Settler: Keep going on error (#873)
in particular: don't panic when a health cache can't be constructed
2024-02-07 12:50:35 +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 a4cddf3129
deposit limit: always allow obv1-selling deposits (#869)
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.
2024-02-05 13:06:06 +01:00
Christian Kamm ae5907ba3a
fix perp settle limit materialization (#865)
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
2024-02-01 11:23:45 +01:00
Christian Kamm 719aee37ae delegate withdraw: require target to have expected owner 2024-01-29 15:13:29 +01:00
Christian Kamm afc2ff9e80 allocator: Don't allow growth beyond heap memory region 2024-01-29 15:13:29 +01:00
Christian Kamm 6c6a75d90d
liquidator: batch serum-cancel step (#861) 2024-01-29 15:07:24 +01:00
GoodDaisy 2f10a710c9
chore: fix typos (#854) 2024-01-29 13:39:33 +01:00
Christian Kamm ed682cfd84 rs client: fix construction without explicit errors-by-type 2024-01-29 13:37:44 +01:00
Christian Kamm 5519f77d8e ts: fallback oracles in bank and token_edit 2024-01-29 13:37:44 +01:00
Christian Kamm 5fc5646aff
ts: Fix registering tokens and stub oracles (#859) 2024-01-26 21:10:33 +01:00
Christian Kamm fcc8c85f6e
perp: Add platform liquidation fee for base (#858) 2024-01-26 10:24:20 +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 40b6b49680 Test: Max borrow with init asset weight scaling 2024-01-22 12:56:37 +01:00
Christian Kamm 43b9cac3a1
Rust client: Allow sending transactions to multiple rpcs (#853) 2024-01-19 16:35:30 +01:00
Christian Kamm 8383109f0d
Add a token-token platform liquidation fee (#849)
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.
2024-01-19 16:34:55 +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 18729cf04c
Configurable interest rate for 0% utilization (#848) 2024-01-15 12:45:00 +01:00
Christian Kamm 637b43fec4 Idl update 2024-01-12 10:56:24 +01:00
Christian Kamm 53bc52efe7
Update openbook v1 fast listing default parameter (#841) 2024-01-09 15:14:52 +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
Christian Kamm 857dcb397f
Allow fast listing admin to register openbook v1 markets (#839) 2024-01-08 14:18:43 +01:00
Adrian Brzeziński bc8bdaed89
small type fixes + post tx approve fcn (#830)
* background confirmations

* fixes

* background confirmation callback

* fix

* fix
2024-01-07 20:14:26 +01:00
Christian Kamm 40f2842c10
ts client: Support deposit-into-existing (#837)
And add a script for using it.
2024-01-04 20:21:09 +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
Britt Cyr 797e866f04
Add a type to the perp cancel order instructions when not found (#833) 2024-01-04 16:00:54 +01:00
Christian Kamm 7d177fdb26
Merge pull request #827 from blockworks-foundation/ckamm/persistent-errors
Liquidator: more useful logs by tracking repeated errors better
2024-01-03 16:22:08 +01:00
microwavedcola1 cf1ca29cee ts: stock mm, fix perp market name
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-03 10:25:54 +01:00
microwavedcola1 56e45ad7e4 ts: rndr stock mm, quote at liq price for liqudiations
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-03 10:17:26 +01:00
microwavedcola1 f3365d4e58 ts: make backup keeper relaxed
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-03 09:55:39 +01:00
microwavedcola1 375284df25 ts: update script
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-03 09:46:17 +01:00
microwavedcola1 5636146fac ts: clean up script
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-03 09:08:18 +01:00
microwavedcola1 55d22e07c5 risk: use know mm's endpoint + add fallback to known mms pubkeys
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-03 08:43:48 +01:00
Christian Kamm 34aebf01f2
oracle: don't force logging in OracleState functions (#828)
The msg!() caused writes to stdout in the liquidator etc in codepaths
that just wanted to check if the oracle was usable.
2024-01-03 08:37:35 +01:00
Christian Kamm f10fc01388
Fix idl generation, update it (#834) 2024-01-03 08:36:19 +01:00
Christian Kamm 332478dee6 Changelog update for v0.21.1 2024-01-02 11:09:22 +01:00
Christian Kamm 30e639fe84 Bank: require borrows <= deposits
- require borrows <= deposits, even if vaults have more tokens
- change min_vault_to_deposits_ratio to be about max utilization

Reviewed and audited as part of the v0.21.1 release, original
commit was 5c2f857112
2024-01-02 11:05:58 +01:00
Christian Kamm 0e3b52b0ef Clamp utilization at 100%
To avoid excessive interest rates or interest curve moves.

Reviewed and audited as part of the v0.21.1 release, original
commit was 3914e48c24
2024-01-02 11:05:22 +01:00
Adrian Brzeziński fd806dab9f v0.21.8 2023-12-29 14:27:07 +01:00
microwavedcola1 a57ec4018d
Mc/no usdc health cache (#831)
* ts: sim usdc pos for max perp trades even if no usdc token position exists

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

* Fixes from review

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-12-29 14:21:01 +01: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
Lou-Kamades 48993ed130
ts: improve sending txns using muiltiple connections (#826) 2023-12-28 21:48:59 -06:00
Christian Kamm 79ddbf21f1
Liquidation: Use asset and liab liq fee (#825) 2023-12-28 10:46:43 +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