Commit Graph

59 Commits

Author SHA1 Message Date
silas d54f957cb4
Run as least privilege user 2022-10-26 20:27:31 +01:00
Christian Kamm 7e180c7b3a Perps: Support trusted markets 2022-09-29 15:40:31 +02:00
Christian Kamm 8ba52f46c2
Perp settle pnl: incentive for settler (#252)
This adds three new options to perp markets:
- a flat fee, that is paid for all perp settlements
- given that they exceed the configured min settle amount threshold to
  be eligible for fees
- and a fractional fee, that only applies when the benefiting account
  has low health and gradually becomes bigger as the account slides
  towards liquidation
2022-09-29 12:59:55 +02:00
Christian Kamm 984695e8d0 liquidator: Call liq_perp_bankruptcy 2022-09-29 07:36:00 +02:00
Christian Kamm 15d0a98c94 liquidator: settle pnl on liquidatable accounts 2022-09-28 10:48:41 +02:00
Christian Kamm 11daf4d0eb client: fetch top settle pnl counterparties 2022-09-28 10:48:41 +02:00
Christian Kamm 9cbc352197 liquidator: force-cancel perp orders, liq perp base positions 2022-09-28 10:47:05 +02:00
Christian Kamm a41a245e24 PerpLiqBankruptcy instruction 2022-09-21 09:46:54 +02:00
conj0iner 1c67b8ed5f
remove base_token_index from perps and include oracles (#224)
Co-authored-by: Conj0iner <conj0iner@users.noreply.github.com>
2022-09-21 09:42:45 +02:00
Christian Kamm 11160ae2fe Health: Pass price to max_swap_source_for_health_ratio
Because it's not correct to think we'll always swap at oracle price.
That was an ok assumption for liquidations, where we'll swap at slightly
better than that, but not for jup.
2022-09-20 10:41:33 +02:00
Christian Kamm b1940eea43 Liquidator: Reduce likelihood of double-sending rebalancing tx 2022-09-02 12:24:28 +02:00
Christian Kamm 8bde9e2bff Liquidator: Force cancel serum orders 2022-09-02 12:23:59 +02:00
Christian Kamm 1f0cd62846 Don't panic if accounts are shorter than 8 bytes 2022-09-01 12:00:09 +02:00
riordanp 3cca63c735
Docker CI Improvements (#195)
* Push separate images for binaries to GCR

* Add base image version arg to heroku deployment

* Test docker build

* Try setting mode

* Fix tags

* switch back to dev

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-31 11:37:58 +02:00
Christian Kamm 8a2d54cce8 Fix some clippy warnings 2022-08-30 13:59:34 +02:00
Christian Kamm 2d2cef35a0 Add HealthRegion instructions
You can do
- HealthRegionBegin
- ... mango instructions ...
- HealthRegionEnd

and the account health will only be checked at the start and end
instead of for every instruction.
2022-08-24 10:07:45 +02:00
Christian Kamm 09fc5f716b Renames in MangoAccount
- Accessors in MangoAccountValue
- PerpPositions -> PerpPosition
2022-08-19 14:58:20 +02:00
Christian Kamm 4c65204c19 Liquidator: Fix condition for starting to liquidate 2022-08-16 16:19:04 +02:00
Christian Kamm 82864e5f6f Liquidator: disable allow-borrow, now that fixed program is deployed 2022-08-16 12:13:54 +02:00
Christian Kamm af5f622bd8 Liquidator: bankruptcy requires borrows 2022-08-16 12:13:54 +02:00
Riordan Panayides 8335c5495e Fix liquidator command 2022-08-12 15:31:53 +01:00
Christian Kamm 92a37f23ed Remove is_bankrupt
Instead, check for any liquidatable assets in liq_token_bankruptcy.

Bankrupt accounts may use the same operations as any other
negative-health account.
2022-08-11 22:57:53 +02:00
Christian Kamm b52aad82e1 Liquidator: more pyth -> oracles renames 2022-08-10 16:24:48 +02:00
Christian Kamm 405c41edcf Liquidator: Fix rebalance to empty token accounts
By withdrawing to the liqor wallet if necessary.
2022-08-10 16:24:48 +02:00
Christian Kamm 7fcee1af96 Liquidator: reload account between rebalance steps 2022-08-10 16:24:48 +02:00
Christian Kamm 38f5502dc7 Liquidator: round up when paying back borrows to close token pos 2022-08-10 16:24:48 +02:00
Christian Kamm 2552bffc66 Liquidator: blocking-wait for data after actions
To avoid sending a second jupiter-swap while the first one is still
in-flight.
2022-08-10 16:18:41 +02:00
Christian Kamm cce1881223 Liquidator: basic sell/buy to keep only quote 2022-08-10 16:18:41 +02:00
Christian Kamm 5c40c12cf5 Liquidator: cleanups 2022-08-10 16:18:41 +02:00
Riordan Panayides 3a4327f50d Change registry URL, tidy up diff 2022-08-08 23:34:15 +01:00
riordanp 5af39e7956
Merge branch 'dev' into mc/docker 2022-08-08 20:54:31 +01:00
microwavedcola1 24c359ef92
keeper token rate update - group multiple ixs into one (#151)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-08 13:40:33 +02:00
Riordan Panayides bddb0f363e Add bin dockerfiles to subdirectories 2022-08-05 17:50:43 +01:00
Christian Kamm 681c69e3a5
Client: Add jupiter_swap (#139) 2022-08-04 17:01:00 +02:00
Christian Kamm b0dae7ec22 client: construct from account pubkeys 2022-08-02 09:45:12 +02:00
Christian Kamm 16290e07f4 client: fix mango account reading 2022-08-02 09:45:12 +02:00
Christian Kamm 16e1e83e26 Client: Move chain_data to client for reuse 2022-07-31 11:03:54 +02:00
microwavedcola1 c88297f42e
mc/ts and keeper improvements (#127)
* ts and keeper improvements

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

* remove stray heroku experiments

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

* Fixes from reviews

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-31 09:25:11 +02:00
microwavedcola1 dfa268dfd6
fix small things to make ci work again (#126)
* checkout submodules on ci

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

* change to https, so that ci can clone

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

* fix clippy

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

* redundant clone

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-30 09:49:56 +02:00
microwavedcola1 f2bfb951fd
anchor as submodule (#121)
* anchor as submodule
* Use anchor submodule as dependency

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-07-27 08:52:41 +02:00
microwavedcola1 2fb92abad8
Mc/ts upgrade (#122)
* upgrade anchor fork, supports anchor idl close now

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

* upgrade ts deps

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-26 17:14:07 +02:00
microwavedcola1 0b2e1e6e6c
Mc/realloc 4 (#119)
Realloc + dynamic mango account

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-07-25 16:07:53 +02:00
Christian Kamm 7c4d052979 ChainData: Fix returning stale data
1. Only the CreatedBank message contains the parent and often that was
   not the first message received. That confused the data structure,
   because it then considered a chain of slots alive that had only a
   single slot in it.
   Fixed by tracking as "best_chain" only the top slot that actually has
   a parent set.
2. OptimisticallyConfirm messages sometimes arrive before CreateBank,
   which would change the slot status from Confirmed back to Processed.
   Nothing dependend on confirmed vs processed, but it's been fixed
   anyway by making slot status only increase confirmation status.
3. Accept account writes for slots newer than the current best_chain
   head as alive.
2022-07-21 12:33:03 +02:00
microwavedcola1 3eae2cdc34 upgrade anchor to latest, upgrade solana dependencies to match what latest anchor uses
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-20 15:51:10 +02:00
Christian Kamm f8d4b2443c Liq: Don't log common+expected simulation errors 2022-07-20 09:47:37 +02:00
Christian Kamm 999bb4b597 Liq/Keeper: allow --dotenv=<file> arg
Makes it easier to run the tools with different configs, without either
passing everything explicitly or making separate directories for .env
files.
2022-07-19 14:57:25 +02:00
Christian Kamm 7e0e6e4506 Liq: use clap+dotenv instead of toml config file 2022-07-19 11:35:59 +02:00
Christian Kamm ca8b900913 Liq: explain re-fetching reason 2022-07-18 18:18:57 +02:00
Christian Kamm 348d8cfcd8 Liq/Client: Various improvements
- Abstract away account fetching, so it can be done via RPC or from a
  websocket stream (or a geyser plugin) that populates a ChainData
  instance.

- Separate out information about tokens, markets into MangoGroupContext.

- Separate all gPA calls into functions in a new file

- The liquidator re-fetches critical accounts via RPC before
  liquidation. Unfortunately the websocket stream seems slower :/

- Don't re-implement health account derivation in the liquidator.
  Instead reuse the existing code from the client.

- More smaller stuff.
2022-07-18 18:18:57 +02:00
Christian Kamm 1be22faf0d Liq: Fix up max_swap call when liquidator didn't use tokens yet 2022-07-18 18:18:57 +02:00