Commit Graph

14 Commits

Author SHA1 Message Date
Christian Kamm 26549ffd92
Bank: track deposits in serum oo accounts (#769) 2023-11-02 10:40:31 +01:00
Christian Kamm 2adc0339dc
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.
2023-09-13 09:35:10 +02:00
Christian Kamm 4f810edebc
Allow token withdraws/deposits even with stale oracles (#646) 2023-08-07 16:15:45 +02:00
Christian Kamm 35064d4ab0
Token conditional swaps (#604)
Users can request token swaps to happen when the oracle price
is within a price band. Once the price is right, an executor can
trigger the swap. The executors are rewarded with a premium
over the oracle price.

This allows limit and stop loss orders on arbitrary spot pairs.

The PR comes with basic ts support and adjustments to the liquidator,
to execute available token conditional swaps.

Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2023-07-03 14:09:11 +02:00
Christian Kamm eeef6711ab Update test_serum_loan_origination_fees test
Now that it always uses the v2 settle, fee buyback potential does
accumulate.
2023-06-19 14:48:08 +02:00
Christian Kamm 0281a1b8ed
Deprecate Serum3SettleFunds, require use of V2 instruction (#606) 2023-06-15 17:34:56 +02:00
Christian Kamm 57e1d981ac
Health: Allow actions while init health does not decrease (#592)
Instead of requiring a strict increase when init health < 0.

This allows users to still place reducing limit orders on the spot and
perp orderbooks as long as these orders keep the health unchanged.
2023-06-15 10:44:11 +02:00
Christian Kamm 0da1b6728b
OpenBook place order: respect bank reduce_only flags (#569) 2023-05-04 08:02:28 +02:00
Christian Kamm b7dd8e0663
Fee buyback: Respect USDC oracle (#504) 2023-03-20 11:18:11 +01:00
Christian Kamm 252210d194
Serum settle funds V2: fees can go to users (#484)
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2023-03-03 14:04:45 +01:00
Christian Kamm df4a7b0474
Fees buyback: Credit users for ui part of serum fees (#481)
At least for markets with USDC quote currency.
2023-02-28 09:48:15 +01:00
Christian Kamm f75e3ee656
Serum: Track referrer rebates as Mango platform fees (#469)
And start sharing code between serum3 settle and force cancel
2023-02-22 12:04:21 +01:00
Christian Kamm 8916c28b99
License: Mark instructions GPLv3 and everything else MIT (#454)
To do that, split up the Accounts objects and the instruction
implementations.

GPL code is only used when the "enable-gpl" feature is enabled. That
means compiling the program or running tests need explicit feature
activation now.
2023-02-15 08:42:07 +01:00
Christian Kamm d3cbb9e2ec
Create a single rust test binary (#425)
Speeds up the linking step, needs way less disk space for test binaries
and executes tests significantly faster.

Test execution went from 35s -> 29s for me and compilation improved a
lot.
2023-01-30 21:09:47 +01:00