Commit Graph

167 Commits

Author SHA1 Message Date
microwavedcola1 4459369c23
Merge pull request #30 from blockworks-foundation/mc/clippy
fix clippy warnings
2022-03-23 10:04:01 +01:00
microwavedcola1 5919a5a1df Merge branch 'main' into mc/clippy 2022-03-23 09:53:50 +01:00
microwavedcola1 f135ca4d9b fix clippy warnings
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-23 09:33:51 +01:00
microwavedcola1 fde4bce86f
Merge pull request #29 from blockworks-foundation/mc/event_queue
add event queue
2022-03-23 08:54:11 +01:00
microwavedcola1 b0d6a14d00 fix clippy warnings
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-23 08:34:23 +01:00
microwavedcola1 f7fb9b7e35 add event queue
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-23 07:53:45 +01:00
Christian Kamm 696806ee77 Add liq_token_with_token file outline 2022-03-22 19:25:33 +01:00
Christian Kamm bfcb672116 Health: allow account order to be fixed, or to scan for accounts
The latter is important when we want to compute health for two different
accounts. Then the remainingAccounts would hold the union of the
necessary accounts, and each health check would need to look for the
accounts that it needs.

This patch al so reduces the compute needs for fixed-layout health
checks significantly (Deposit for an account with 8 tokens and 7 markets
takes 65k instead of 70k cu)
2022-03-22 14:13:07 +01:00
microwavedcola1 3443ab0d70
Merge pull request #27 from blockworks-foundation/mc/ci
checked math
2022-03-22 11:47:10 +01:00
microwavedcola1 237d776e2b fix test cu requirement
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-22 11:33:06 +01:00
microwavedcola1 974724cfe1 fix some clippy warnings
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-22 11:19:12 +01:00
microwavedcola1 ed9368cb3d checked math
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-22 10:39:51 +01:00
Christian Kamm d1a7cd109d Serum: remove some duplicated functions 2022-03-22 09:58:10 +01:00
Christian Kamm 43eba0a529 Serum: Test for force cancel orders 2022-03-22 09:25:13 +01:00
silas d7e4fc3ea9
Add manual run 2022-03-22 07:45:36 +00:00
microwavedcola1 b8d84112d7 fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-22 07:09:49 +01:00
microwavedcola1 ec5e959804 further work on perps
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-22 07:06:33 +01:00
Christian Kamm 34d14ef267 Serum: serum3_liq_force_cancel_orders instruction
Still needs a test.
2022-03-21 17:39:52 +01:00
Christian Kamm 27f882a333 Tests: More flexible test context construction 2022-03-21 10:45:55 +01:00
Christian Kamm a6a31f226c Tests: Unify group + tokens setup 2022-03-21 07:49:51 +01:00
Christian Kamm 75ac224b6e Tests: Bank deposit/withdraw/active/dust tests 2022-03-21 07:01:25 +01:00
microwavedcola1 e7b32c6149 clippy
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-20 10:16:02 +01:00
microwavedcola1 fbedea9424 reorg, placeholder for place perp order
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-20 10:11:36 +01:00
Christian Kamm 1ad0826573 Clippy warnings 2022-03-19 12:53:24 +01:00
Christian Kamm 6f72cd27e8 Serum: Cancel order instruction 2022-03-19 12:19:16 +01:00
Christian Kamm 63050c3661 Serum: No health check needed after settle_funds
It just moves free funds from open_orders to the user account.
2022-03-19 09:05:42 +01:00
Christian Kamm 9fb16f3906 Add comments 2022-03-19 08:54:33 +01:00
microwavedcola1 9475d9545c add comment
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-19 08:52:38 +01:00
microwavedcola1 479bd60ecf extend perp market with indices, which make it easier to lookup the perp market and base and quote tokens
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-19 07:28:37 +01:00
Christian Kamm 70316fb927 Serum: Settle funds instruction
Also move serum3 cpi helpers to a separate file, to allow reuse of calls
like settle_funds from multiple mango instructions.
2022-03-18 19:27:23 +01:00
microwavedcola1 4987e072cd fix test
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-18 17:49:13 +01:00
microwavedcola1 ab61c6b244 remove unused
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-18 16:30:18 +01:00
microwavedcola1 ba9bc82df2 Merge branch 'mc/perps' 2022-03-18 15:16:13 +01:00
Christian Kamm 9d05db68f9 Serum: Prefix instructions with serum3_ and related renames 2022-03-18 13:42:20 +01:00
microwavedcola1 b5734e4f97 fix trailing space
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-18 13:00:52 +01:00
Christian Kamm a40eb94833 Serum: settle_funds after place_order
Avoid using anchor_spl::dex helpers, because calling serum through these
functions costs significantly more compute, likely because AccountInfos
need to be cloned twice.

Examples:
- new_order_v3: direct 26.8k CU, helpers 37.5k CU
- settle funds: direct 24.9k CU, helpers 31.8k CU
2022-03-18 12:17:09 +01:00
microwavedcola1 4f7e3a5738 create perp market wip
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-18 10:14:30 +01:00
Christian Kamm 57c06bc2da Health: add a missing group check for remainingAccount Banks 2022-03-18 07:54:20 +01:00
Christian Kamm 7b3cd9a81f Health: Use split_at_mut to get two element &muts
Previously we re-indexed token_infos every time, now we can just have
mutable references to the base and quote elements at the same time.
2022-03-18 07:44:44 +01:00
Christian Kamm 430d5c85fa Health: compute optimizations
Basic caching of multiplications and divisions.
2022-03-17 21:53:41 +01:00
Christian Kamm af2f4a0923 Health compute tests 2022-03-17 14:17:28 +01:00
Christian Kamm 9351d0652d Serum: health based on worst case order outcome 2022-03-17 12:05:07 +01:00
Christian Kamm 0593aa81f7 Serum: more health computation
Now the open orders are actually read
2022-03-16 18:33:11 +01:00
Christian Kamm 6aa4724b45 Serum: Health computation first steps 2022-03-16 16:45:54 +01:00
Christian Kamm f5d2964f1d Serum: Store base/quote token index in MangoAccount
To avoid having to pass SerumMarket when health needs to be computed.
2022-03-16 13:48:43 +01:00
Christian Kamm 1953d12f0f Health: expect serum open orders accounts 2022-03-16 13:42:29 +01:00
microwavedcola1 7a68aa71e5 simplify
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-15 16:38:24 +01:00
microwavedcola1 75721d8f06 fix bug where position mutation was not persisted in margin trade
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-15 16:25:44 +01:00
Christian Kamm 3bb94777f3 MangoAccount field renames
indexed_positions -> token_account_map
serum_open_orders_map -> serum_account_map

in the future we should add the perp_account_map
2022-03-15 15:08:53 +01:00
Christian Kamm 54641692fa PlaceSerumOrders: indexed positions are guaranteed to exist 2022-03-15 14:59:15 +01:00