microwavedcola1
cae10bcdae
Merge branch 'dev'
2022-11-02 11:52:43 +00:00
microwavedcola1
a66177a77e
ts: match client class definitions 1-1 to program state struct definitions ( #268 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-10-11 09:34:02 +02:00
Nicholas Clarke
96344d7de1
Clarkeni/perp logging ( #265 )
...
* Perp instruction logging
* Onchain funding calculation
* perp_spot_transfers field on perp positions
* Logging on register token, perp market
* Additional fields on update token index logging
* maker and taker volume fields on perp position
2022-10-07 12:12:55 -07: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
microwavedcola1
5b549fb59f
program: fix bug where expansion would not move positions whose size remained same ( #262 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-10-03 13:06:04 +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
microwavedcola1
d1079bb1b9
Mc/ts increase error tolerance for binary search ( #258 )
...
* ts: a higher error tolerance is sufficient
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* program: fix error size
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-30 14:59:12 +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
Nicholas Clarke
01a958cd22
Clarkeni/onchain interest ( #244 )
...
* Onchain interest calculation
* Fix to TokenBalanceLog for token_liq_bankruptcy (was previously using liqee liab position for liqor liab position).
* Log cumulative interest when token position is deactivated.
2022-09-28 23:04:33 -07:00
Christian Kamm
984695e8d0
liquidator: Call liq_perp_bankruptcy
2022-09-29 07:36:00 +02:00
Christian Kamm
12864e15a6
Merge pull request #245 from blockworks-foundation/ckamm/perp-settle
...
Liquidator: Settle pnl on perp accounts
2022-09-29 07:35:37 +02:00
Christian Kamm
77abfd0529
Perp liq: Fix base position liquidation amount computation
...
It was wrong for quote weights != 1.
2022-09-29 07:34:52 +02:00
Christian Kamm
11daf4d0eb
client: fetch top settle pnl counterparties
2022-09-28 10:48:41 +02:00
conj0iner
a97b40a521
Merge pull request #234 from blockworks-foundation/cj/ioc_fees
...
Extra fees for IOC orders
2022-09-28 00:05:25 +08:00
Nicholas Clarke
1320451e1a
Add serum open orders balance logging. Remove price from token and perp balances. ( #236 )
2022-09-23 10:42:43 -07:00
Christian Kamm
f6c9a93ac5
Health: Avoid overflow panic in health ratio for tiny liabs
...
Spotted by microwavedcola
2022-09-23 12:04:14 +02:00
microwavedcola1
bb6790e678
ts: use price factor in maxSourceForSwap + max perp bid and ask + tests ( #237 )
...
* ts: use price factor in maxSourceForSwap
ts: max perp bid and ask
ts: mocha test for max swap
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* ts: comemnt
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-23 11:43:26 +02:00
Conj0iner
55f77ad6c6
Added IOC penalty
2022-09-23 00:55:12 +08:00
microwavedcola1
ae42356b22
program: remove todos for ix which have now been implemented or not relevant ( #240 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-22 17:43:01 +02:00
Christian Kamm
0040a1477e
Client: Compute max perp trade amount ( #231 )
2022-09-21 11:45: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
ddb68b7991
Test build fix
2022-09-20 16:59:55 +02:00
Christian Kamm
6399e6cb6c
Fix PerpMarket data layout breakage
...
The new fees_settled must be added at the end and the reserved amount
needs to be reduced.
2022-09-20 16:58:07 +02:00
microwavedcola1
b7e79a4663
WIP: ts/perps ( #220 )
...
* ts: further fleshing out of perps code
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* cleanup scripts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from reviews
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-20 12:57:01 +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
a6d25071cd
Test: Fix test_alt compile
2022-09-15 19:06:46 +02:00
Christian Kamm
20eb61527b
Compile fixups after merge
2022-09-15 09:40:14 +02:00
Christian Kamm
1b3a2b07db
Update idl
2022-09-15 09:24:35 +02:00
Christian Kamm
14ca1dac35
Add alt_set / alt_extend instructions
...
alt_extend will only work in the future, when alt_set can receive lookup
tables where the authority is set to be the mango group pda.
2022-09-15 09:20:08 +02:00
Christian Kamm
50be520e99
Rename: LiqToken* -> TokenLiq*
2022-09-14 16:22:42 +02:00
Christian Kamm
f3bdfec6a6
Perp settle pnl: Limit to maint spot health ( #225 )
...
Perp settle pnl: Limit to maint spot health
We want to isolate perp markets. As such, it's not acceptable to convert
arbitrary perp losses into spot token borrows.
The safe amount for this conversion is given by the account's
maint health -- with all perp markets ignored.
2022-09-14 13:26:29 +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
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