Commit Graph

76 Commits

Author SHA1 Message Date
Christian Kamm 15b9b911d1 Bump program version to 0.3.0 2023-01-13 11:38:56 +01:00
Christian Kamm c238ed4f28 Bump version to v0.2.0 2023-01-13 11:25:08 +01:00
Christian Kamm bda8cb9387
v0.1.2 version bump and changelog (#383) 2023-01-13 10:36:47 +01:00
Christian Kamm 93d33edb74
Perp: liq with token instruction (#368)
The new instruction allows the liqor to take over negative pnl (limited
by liqee settle health and settle limits) before applying the bankruptcy
logic.
2023-01-12 09:07:13 +01:00
Christian Kamm c5d875e04d
Perp settle limit extension to realized pnl (#359)
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2023-01-11 14:32:15 +01:00
Christian Kamm 6cef8caa34
rust client: Make AccountFetcher futures Send (#357)
This required redoing the cached account fetcher logic to properly deal
with locking and repeated calls while a fetch is ongoing.
2023-01-04 16:15:46 +01:00
microwavedcola1 86c9331647
reduce only order type and mode for tokens and perp markets (#353)
* reduce only order type and mode for tokens and perp markets

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

* Fix from review

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

* Fix from review

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

* Fixes from review

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

* tests

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

* remove token

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

* fixes

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>

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-01-04 09:24:40 +01:00
Christian Kamm 5a38506f04
Liquidator, liqtest and rust client fixes (#336)
Liquidator, liqtest and rust client fixes

- Make rust MangoClient fully async
- Update and improve liquidation test setup scripts
- Update liquidator to use versioned transactions
- Update liquidator to use mango and jupiter account lookup tables
- Use jupiter v4 api to get versioned transactions

Perp liquidation is still not fully good. See discussion aboult perp_liq_pnl_with_token.
2022-12-16 13:10:46 +01:00
Christian Kamm 0ed7175341 Upgrade to solana ~1.14.9
- Update anchor submodule
- Fork and submodule switchboard-v2 package to update dep
2022-12-13 17:00:57 +01:00
Christian Kamm e0f50bf0d4
pnl limit: Clean up by adding functions, using it in get-settleable (#329) 2022-12-10 17:56:56 +01:00
Christian Kamm d3db44e7ba Client: Fix liq health accounts: no duplicate perp markets 2022-12-09 20:43:48 +01:00
Christian Kamm fe9c92e7ef Client: Fix ata idempotent creation 2022-12-09 20:43:48 +01:00
Christian Kamm a29a736ba2 Move src/state/health/ -> src/health/ 2022-12-08 20:48:44 +01:00
Christian Kamm 947d9b2b60
Split into perp bids and perp asks (#322)
Separate, smaller accounts that are easy to extend if needed.
2022-12-07 21:03:28 +01:00
Christian Kamm c8f1f3c821
Net borrow limits: Limit in quote, not native (#312)
* Net borrow limits: Limit in quote, not native
* make perp settle limit disableable
2022-12-02 12:24:11 +01:00
riordanp 748334d674
Fix liquidator (#302)
* Fix liquidator

* Remove redundant variable.

Co-authored-by: Nicholas Clarke <nicholasgclarke@gmail.com>
2022-11-22 07:10:23 +01:00
microwavedcola1 44d0170ea9
mc/settle pnl ts client (#292)
* oracle peg client support

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>

* perp pnl settle, candidate finder, and example

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-11-21 20:36:13 +01:00
microwavedcola1 d82608ebee Revert "add support for msrm vault for serum3 discounts (#285)"
This reverts commit 0a4f7150d6.
2022-11-20 15:31:16 +01:00
conj0iner 39ed94aa87
client additions + extra tests + safety (#281)
Co-authored-by: Conj0iner <conj0iner@users.noreply.github.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-11-18 08:58:56 +01:00
riordanp 5d780a86dc
Upgrade to Solana 1.10.35 (#291)
* 1.10.35 upgrade & compatibility

* Patch Anchor

* Fix test compile

* Serum program update

Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-11-16 10:50:40 +00:00
Christian Kamm 2ee152f7ea Oracle staleness: Check when accessing oracle price 2022-11-12 12:12:45 +01:00
microwavedcola1 0a4f7150d6
add support for msrm vault for serum3 discounts (#285)
* add support for msrm vault for serum3 discounts

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

* Fix client

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

* client support

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

* More client code and todos

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

* prettoer

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

* remove mint, not needed

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-11-09 09:59:42 +01:00
microwavedcola1 e8ba511c45
mc/flash loan for delegate (#271)
* flash loan for delegates

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

* Fix rust client

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

* prettier

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-11-09 09:35:13 +01:00
Christian Kamm 7da421ea1c Fix client and keeper for new perp orderbooks 2022-11-09 09:32:32 +01:00
Riordan Panayides 21e4b080e3 Fix incorrect open orders start index 2022-11-02 17:13:25 +00:00
Christian Kamm f2cc869795 Perps: Prepare for settlement token != oracle token
Make sure the setting is available and that the needed accounts are
passed to the perp instructions.
2022-10-06 08:32:58 +02:00
Christian Kamm b906e3dc78 Token deposit: Split into signed and permissionless ix
Token accounts are a limited resource, so allowing other users to make
use of them can cause problems.
2022-10-02 16:06:39 +02: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 d86b3dd757 Rust client: Fix remaining accounts perp oracles 2022-09-23 09:07:51 +02:00
Christian Kamm 50be520e99 Rename: LiqToken* -> TokenLiq* 2022-09-14 16:22:42 +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
Christian Kamm 8a2d54cce8 Fix some clippy warnings 2022-08-30 13:59:34 +02:00
Christian Kamm e0437305ee SerumPlaceOrder: Only pass the payer bank/vault 2022-08-30 12:05:07 +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
Nicholas Clarke 8a1c58e723
FlashLoan: Add flash_loan_type (#164)
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-08-17 12:36:55 +02:00
Christian Kamm 421b2d3d19 FlashLoan: Fix validation holes
- Pass the group to Begin and End and ensure it is the same.
- Enforce target token accounts can't be group-owned.
- Now End can consistently derive the number of vaults/token accounts.
2022-08-16 13:10:05 +02:00
Christian Kamm 54222c5b3f liq_token_bankruptcy: don't pass redundant index 2022-08-16 13:08:57 +02:00
Christian Kamm f169bcdafe Client: add token_withdraw 2022-08-10 16:24:48 +02:00
Christian Kamm 3139b0816a Client: Jupiter swaps preserve ata/token instructions 2022-08-10 16:24:48 +02:00
Christian Kamm 19153b8874 Client: Fix jupiter api field that is sometimes null 2022-08-10 16:24:48 +02:00
Christian Kamm 13e4d0a432 Client: Fix loan amount for jupiter ExactOut swaps 2022-08-10 16:18:41 +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