Commit Graph

1008 Commits

Author SHA1 Message Date
Christian Kamm 3e94ff4605 ts: fix getMaxWithdrawWithBorrowForToken 2022-09-14 09:03:29 +02:00
Christian Kamm b579096264
Merge pull request #223 from blockworks-foundation/ckamm/perp-liq
Perp liquidation: force cancel orders, liq base position
2022-09-10 08:11:06 +02:00
Christian Kamm 5572242e6d Tests: PerpLiqBaseToken tests 2022-09-10 07:45:27 +02:00
Christian Kamm 45025a1145 Perp tests: Helper for market creation 2022-09-10 07:45:27 +02:00
Christian Kamm bb962c6781 Perp tests: Don't pass derivable accounts explicitly
This makes it impossible to test passing bad accounts for these through
this interface, but I think that's an ok tradeoff.
2022-09-10 07:45:25 +02:00
Christian Kamm 2dfada7377 Tests: initial perp force-cancel test 2022-09-10 07:42:58 +02:00
Christian Kamm 810998a2af Add PerpLiqForceCancelOrders instruction 2022-09-10 07:42:58 +02:00
Christian Kamm 845a32a7c2 Add PerpLiqBasePosition instruction 2022-09-10 07:42:58 +02:00
conj0iner 451d8a8d22
Merge pull request #219 from blockworks-foundation/cj/max_settle_u64
Changed max_settle_amount to u64
2022-09-09 22:49:20 +08:00
Conj0iner a6ddf232cb Fixed tests 2022-09-09 18:50:11 +08:00
Conj0iner 3b3286a5b3 Changed max_settle_amount to u64 2022-09-09 18:29:02 +08:00
Christian Kamm 1f26a54399
Perps: introduce explicit position close (#216)
* Perps: fix position lifetime; explicit closing

When an order is placed and the position needs to be created, the
settlement token is marked as in use. The perp position and the in-use
flag are only released with the new perp_close_position instruction.

* Tests: Factor out common floating-point comparisons

* Rename PerpClosePosition -> PerpDeactivatePosition
2022-09-09 10:50:09 +02:00
Christian Kamm 6c32077d1a Perps: Let all base lot changes go through a function
Direct access to base_position_lots and quote_position_native is not
allowed anymore.

Fixes an issue where quote_lots were used instead of quote_native, and
also takes fees into account for the entry price.
2022-09-08 13:12:50 +02:00
Christian Kamm e56ed3776c Perp: Api cleanups
- Clarification of close_order vs close_all_orders
- Remove of get_ prefixes
- Remove find_min/find_max/find_min_max, duplicated with
  min_leaf/max_leaf
2022-09-08 13:11:45 +02:00
Christian Kamm 1d7d5e9a6d Test: simplify by adding a TestKeypair that's Clone+Copy
This means a lot less annoyance because of &'a Keypair or Arc<Keypair>
2022-09-07 14:23:52 +02:00
Christian Kamm 4795286dbd Perps: Account for unsettled funding in health 2022-09-07 11:37:20 +02:00
Christian Kamm c714fb213d Tests: Auto-advance the slot after sending a transaction
This fixes a recurring error where it would look as if a transaction you
send would not be processed at all.
2022-09-07 11:34:47 +02:00
Christian Kamm 3128115dca PerpMarket: Add helper for getting oracle price 2022-09-06 14:26:06 +02:00
Christian Kamm 79a7bdc299 Checked math: support cm!(a += b) 2022-09-06 08:55:27 +02:00
Christian Kamm 3c51449040 Tests: Remove unused imports 2022-09-05 18:40:42 +02:00
conj0iner 2693a20e16
Merge pull request #204 from blockworks-foundation/cj/settle_fees
Add perp_settle_fees instruction
2022-09-05 23:30:55 +08:00
Conj0iner c34ee54233 Added perp_settle_fees instruction 2022-09-05 22:18:40 +08:00
Christian Kamm 3fbc3ca32d TokenEdit: remove bank_num arg 2022-09-02 13:55:00 +02:00
Christian Kamm 14913c70d2
Merge pull request #210 from blockworks-foundation/ckamm/liq-force-close
Liquidate serum open orders
2022-09-02 13:15:42 +02:00
Christian Kamm b1940eea43 Liquidator: Reduce likelihood of double-sending rebalancing tx 2022-09-02 12:24:28 +02:00
Christian Kamm ef5552c1c0 Liqtest: Build serum test case 2022-09-02 12:24:18 +02:00
Christian Kamm 90630fa3de ts client: Enable accounts to have serum slots by default 2022-09-02 12:24:04 +02:00
Christian Kamm d566db7db0 Liqtest: Settle-and-close settles and closes open serum orders 2022-09-02 12:24:04 +02:00
Christian Kamm 3b3258769f ts: TokenEdit takes optional arguments 2022-09-02 12:24:04 +02:00
Christian Kamm 8bde9e2bff Liquidator: Force cancel serum orders 2022-09-02 12:23:59 +02:00
Christian Kamm 22dc07df1d Liquidation test: Fix scripts 2022-09-02 10:22:35 +02:00
conj0iner 1ed1b684bc
Merge pull request #156 from blockworks-foundation/cj/settle_pnl
Added perp_settle_pnl instruction
2022-09-02 00:47:53 +08:00
Conj0iner 97eed4081d Added perp_settle_pnl instruction 2022-09-02 00:07:57 +08:00
Christian Kamm 511db72f8e Health token adjustment: Deal with odd I80F48 behavior
The identity
  a * b = -((-a) * b)
does not hold for I80F48, probably it's rounding to -inf.

This meant that withdrawing the full native token balance could
fail because the magnitude of -position * price was bigger than
position * price.
2022-09-01 14:38:48 +02:00
Christian Kamm 3b93a38395
Merge pull request #208 from blockworks-foundation/ckamm/fix-index-reservation
Serum: Index reservation account has 8 bytes
2022-09-01 13:23:27 +02:00
Christian Kamm 868c55fef1 Serum index reservation: use a real account
Makes it easier and more future-proof
2022-09-01 12:28:37 +02:00
Christian Kamm c31f11013f Serum deregister: Close index reservation account
Only safe because this is a testing-only instruction
2022-09-01 12:15:00 +02:00
microwavedcola1 c420d71943 ts: fix withdraw wrapped sol -> sol
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 12:11:31 +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 5e0001afb8 Serum: Index reservation account has 8 bytes
otherwise all code needs to be able to deal with mango accounts that are
smaller than 8 bytes in size.
2022-09-01 11:49:33 +02:00
microwavedcola1 3a1f6f08ee Merge branch 'dev' 2022-09-01 11:34:42 +02:00
microwavedcola1 0f75baeadd comment in on demand
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 11:27:22 +02:00
microwavedcola1 0222ca8954
ts fixes (#207)
* ts: use gpa path if rest services has not caught up yet

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

* ts: convert wrapped sol to sol when withdrawing

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 11:25:58 +02:00
microwavedcola1 149e0eb0c7 Fix client and remove excessive logging in scripts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 10:48:50 +02:00
microwavedcola1 38e3ea672e changelog
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 10:30:24 +02:00
microwavedcola1 2479107d9a
Prepare serum3 release (#206) 2022-09-01 10:18:47 +02:00
microwavedcola1 a889e6c206 Fix scripts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 09:56:17 +02:00
microwavedcola1 5ff181d01d Merge branch 'dev' 2022-09-01 09:52:29 +02:00
microwavedcola1 b30b2f8870
program: serum3 should work when group has version 1, perps and multiple banks should be moved to version 2 or beyond (#205)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 09:48:38 +02:00
microwavedcola1 5f62f15549
mc/i80F48 in-place cleanups (#203)
* ts: use in place I80F48 wherever applicable

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

* ts: dont overwrite I80F48 constants

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

* Fix script

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 09:48:23 +02:00