Commit Graph

80 Commits

Author SHA1 Message Date
microwavedcola1 f2442428b6 Merge branch 'main' into deploy 2024-03-10 14:26:29 +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 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
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
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
Christian Kamm e2bfa9a1e6 client: configurable jupiter urls (#800)
(cherry picked from commit 71f0e5cc13)
2023-12-27 14:15:45 +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
microwavedcola1 e75d279b15 Merge branch 'deploy-v0.21.0' into deploy 2023-12-13 09:04:44 +01:00
Christian Kamm add1647d37 rs client: Use finalized commitment for blockhash
confirmed say occasional errors
2023-12-11 10:31:34 +01:00
Christian Kamm 0d6d0d2837 rs client: Fix blockhash to be from confirmed commitment 2023-12-11 09:42:03 +01:00
Christian Kamm 71f0e5cc13
client: configurable jupiter urls (#800) 2023-12-05 13:23:11 +01:00
Christian Kamm ce16d79b13
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.
2023-12-05 13:22:24 +01:00
Lou-Kamades a0a47af6a4 ScanningAccountRetriever uses fallback oracles 2023-11-22 11:35:26 -06:00
Christian Kamm 93d85c3f71
Bank: allow maint weights to change over time (#780)
- token_edit can set it up to gradually scale to new target values
- security admin can abort an ongoing change via token_edit
- all health computations are now time dependent and get the weight
  based on it
- when the change is done, the keeper "cleans up" and moves the new
  values into the default fields
2023-11-14 14:52:04 +01:00
Christian Kamm 8e1f512639 Client: remove stray debug output 2023-11-08 13:52:12 +01:00
Christian Kamm 7af1d58558
Some clippy fixes (#776) 2023-11-08 09:51:36 +01:00
Christian Kamm 0ad26d845f
liquidator: Allow excluding tokens from rebalance (#774) 2023-11-08 08:51:41 +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 a81d0918cc tcs start: use same naming convention as in other ix
liqee/liqor over account/caller
2023-10-30 13:41:19 +01:00
microwavedcola1 edaf874174
deploy -> dev (#759)
* ts: get yarn lock from dev

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

* v0.19.20

* ts: add missing dependency

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

* ts: add error when no free token position is found (#707)

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

* Mc/tcs improvements (#706)

* ts: additional tcs helpers

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

* Fixes from review

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

* Revert "Fixes from review"

This reverts commit 1def10353511802c030a100fd23b2c2f4f198eaa.

---------

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

* v0.19.21

* v0.19.22

* ts: tcs fix price display input to tx

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

* v0.19.23

* v0.19.25

* script: log all

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

* ts: fix tcs order price limits

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

* v0.19.27

* ts: fix getTimeToNextBorrowLimitWindowStartsTs (#710)

* ts: fix getTimeToNextBorrowLimitWindowStartsTs

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

* Fixes from review

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

---------

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

* Mc/keeper (#714)

* v0.19.28

* ts: tokenWithdrawAllDepositForMint

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

* Fix

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

* Fix

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

* rust: dont include tokens with errors in crank

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

* Fixes from review

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

* review fixes

* Fixes from review

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

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>

* v0.19.29

* ts: update debug script

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

* release 19.1 -> deploy + serum3 open orders estimation ts patch (#719)

* Serum3 open orders: Fix health overestimation (#716)

When bids or asks crossed the oracle price, the serum3 health would be
overestimated before.

The health code has no access to the open order quantites or prices and
used to assume all orders are at oracle price.

Now we track an account's max bid and min ask in each market and use that
as a worst-case price. The tracking isn't perfect for technical reasons
(compute cost, no notifications on fill) but produces an upper bound on
bids (lower bound on asks) that is sufficient to make health not
overestimate.

The tracked price is reset every time the serum3 open orders on a book
side are completely cleared.

(cherry picked from commit 2adc0339dc)

* Changelog, version bump for program v0.19.1

* ts: ts patch for the PR

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

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>

* Rust client: Use alts for every transaction (#720)

(cherry picked from commit 40ad0b7b66)

* Jupiter: ensure source account is initialized

Backport of 9b224eae1b / #721

* client/liquidator: jupiter v6 (#684)

Add rust client functions for v6 API that are usuable in parallel to the v4 ones.

(cherry picked from commit 0f10cb4d92)

* Jupiter: Ensure source account is initialized (#721)

(cherry picked from commit 9b224eae1b)

* Mc/update cu budget for perp settle pnl (#724)

* ts: bump perp settle pnl cu budget

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

* ts: helpers for withdrawing tokens from bad oracles (#726)

* ts: helpers for withdrawing tokens from bad oracles

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

* Fixes from review

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

* Fixes from review

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

* Fixes from review

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

* Fixes from review

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

* rename

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

* rename

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

* Fix usage of field

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

* Fixes from review

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

---------

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

* v0.19.31

* ts: higher min. cu limit for each tx (#727)

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

* v0.19.32

* ts: if more ixs then more cu (#728)

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

* Mc/tcs p95 (#708)

* use more fine grain price impact

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

* ts: for computing tcs premium use more fine grain price impact

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

---------

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

* update

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

* Mc/settler cu limit (#725)

* v0.19.30

* settler: extend cu limit to 250k for perp pnl settling

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

* TransactionBuilder: add cu limit/price based on config

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>

* ts: rename params to indicate that they are in native

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

* ts: cleanup tcs create parameter naming (#730)

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

* wip: Mc/update risk params (#729)

* v0.19.33

* ts: script to update risk params

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

* create proposals helpers

* fix

* Update env params

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

* Update

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

* Update

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

* simulate before run

* fix presets

* fix

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Adrian Brzeziński <a.brzezinski94@gmail.com>

* ts: upgrade anchor (#735)

* ts: upgrade anchor

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

* Fixes from review

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

---------

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

* script for tx error grouping, and ts helper code for finding tx error reason (#747)

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

* v0.19.34

* ts: fix script for updating token params

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

* Fix typo

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

* script: update script to remove files which are of 0 size

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

* script: error tx grouping, blacklist some more

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

* fix (#753)

* jupiter: clearer slippage_bps argument name

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
Co-authored-by: Adrian Brzeziński <a.brzezinski94@gmail.com>
2023-10-19 10:03:07 +02:00
Christian Kamm b123a3c5ae jupiter: clearer slippage_bps argument name 2023-10-19 09:24:32 +02:00
Christian Kamm 817bf9bbc6
Tcs: linear and premium auctions (#717) 2023-10-07 21:27:19 +02:00
Christian Kamm fd997e2e2c Cargo: Remove explicit workspace-inheritance feature use
solana-release cargo version was updated
2023-10-05 11:05:12 +02:00
Steve f625284593
Update to solana 1.16.14 and anchor 0.28.0 (#718)
- Change fixed to be a git dependency (no more submodules!)
- Upgrade fixed to a version compatible with borsh 0.10
- Upgrade openbook-v2 dependency (for anchor compat)
- Move services from mango-feeds repo into bin/
- Update mango-feeds-connector

Co-authored-by: Christian Kamm <mail@ckamm.de>
Co-authored-by: Riordan Panayides <riordan@panayid.es>
2023-10-05 10:56:45 +02:00
Christian Kamm eca4550fa2
Client: fix issue when no serum program is registered (#732)
The serum StreamMap exiting aborts the whole streaming job.
2023-09-27 12:56:52 +02:00
Christian Kamm 9b224eae1b
Jupiter: Ensure source account is initialized (#721) 2023-09-18 09:21:46 +02:00
Christian Kamm 40ad0b7b66
Rust client: Use alts for every transaction (#720) 2023-09-18 09:21:30 +02:00
Christian Kamm aca2b2e679
liquidator: Work on groups without openbook markets (#701) 2023-09-01 15:05:43 +02: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 f63163d737
Account limits: Prefer 4 perp + 4 serum (#689) 2023-08-21 16:26:49 +02:00
Christian Kamm a151ebcf11
Account size: restict more, but only increases (#688)
* Account size: Don't fail on unrelated resize

If the account was previously resized to larger than is allowed now,
don't fail unrelated resizes.

* Further reduce account size limits

Out of caution and future-proofing. Can always raise again.

Perp settle pnl needs 6 accounts plus 2 health account lists that could
be nearly fully disjoint.
2023-08-21 14:34:52 +02:00