microwavedcola1
0f34851c64
switchboard support ( #67 )
...
* switchboard support
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-18 16:38:46 +02:00
microwavedcola1
95c06c2bfc
Mc/liquidator ( #64 )
...
* Copy over and integrate liquidatable-accounts-feed (doesn't compile)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Liquidator
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Adapt to refactoring
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* remove dead code
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Use copies of AccountSharedData
* Implement AccountReader for AccountSharedData
* use LoadZeroCopy in liquidator
* Fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-06-18 16:31:28 +02:00
Christian Kamm
40023fcef1
Health: Make FixedOrderAccountRetriever more flexible
2022-06-08 14:38:49 +02:00
Christian Kamm
b3568b7f3e
Make health/oracle functions usable from clients ( #63 )
...
* Make health/oracle functions usable from clients
By creating a shared trait that is implementable for AccountInfo and
AccountSharedData.
* Health: fixup tests
2022-06-08 13:43:12 +02:00
Christian Kamm
685fd3122f
Perps: Limit overall health contribution from perp markets
...
We don't want to allow borrowing against unsettled pnl in perp markets.
This makes it safer to create perp markets for untrustworthy assets.
2022-06-06 12:58:08 +02:00
microwavedcola1
a20d04b6ff
Fix oracle price read by using decimals from pyth ( #62 )
...
* Fix oracle price read by using decimals from pyth
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-02 10:36:04 +02:00
Christian Kamm
48cb1f0b88
Compute health in perp_place_order
2022-05-29 20:50:21 +02:00
Christian Kamm
4984bba71e
Health: Add perp health calculation
2022-05-29 20:50:21 +02:00
Christian Kamm
536ec8a84a
Make health iteration code work with pyth oracles
...
They have a different account owner, that error must be skipped.
2022-05-26 20:38:03 +02:00
microwavedcola1
f09b3cc965
First attempt at finishing perp health
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-03 15:15:34 +02:00
microwavedcola1
2587cd914c
checked math
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-07 21:04:02 +02:00
Christian Kamm
68ef58248c
Perp health: Some code and comments
2022-04-05 09:09:12 +02:00
Christian Kamm
256397593d
Health: Support PerpMarkets in remainingAccounts
2022-04-04 11:25:05 +02:00
microwavedcola1
e6727cbfae
fix clippy warning
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-03 06:21:34 +02:00
microwavedcola1
7803cae654
fix clippy warning
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-03 06:16:41 +02:00
microwavedcola1
dfd1dc5216
fix clippy warning
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-03 06:11:41 +02:00
microwavedcola1
204ab6963d
checked math
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-03 06:09:01 +02:00
microwavedcola1
d6fe317ac9
checked math
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-03 06:06:03 +02:00
Christian Kamm
cbc3cc7bbd
MangoAccount: Rename how tokens/serum3/perps data is stored
...
token_account_map -> tokens
serum3_account_map -> serum3
perp -> perps
2022-04-02 13:51:26 +02:00
Christian Kamm
f48a7f5ed9
Clippy: Address issues
2022-04-01 12:21:19 +02:00
microwavedcola1
00ac0dfce9
comments and test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-30 11:58:45 +02:00
Christian Kamm
d6ebffd346
liq: functionality fixes and test
2022-03-29 17:47:19 +02:00
Christian Kamm
69426d6d96
liq: Introduce HealthCache to get init/maint health after liquidation
...
The concept only works if all serum3 open orders have been fully
cancelled and settled.
2022-03-29 09:18:13 +02:00
Christian Kamm
a6ff388e20
health: avoid divisions, reducing compute needs
2022-03-27 14:47:42 +02:00
Christian Kamm
82819720e0
liq token: progress
...
Change bank.deposit()/withdraw() to work with I80F48 values so we don't
need to round during liquidation.
2022-03-27 14:46:51 +02:00
Christian Kamm
c391c29347
liq token: Instruction outline
2022-03-27 14:46:51 +02: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
Christian Kamm
d1a7cd109d
Serum: remove some duplicated functions
2022-03-22 09:58:10 +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
9d05db68f9
Serum: Prefix instructions with serum3_ and related renames
2022-03-18 13:42:20 +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
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
1953d12f0f
Health: expect serum open orders accounts
2022-03-16 13:42:29 +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
28a26e66da
PlaceSerumOrder: More account validation
2022-03-14 21:53:30 +01:00
Christian Kamm
449fe4dc6d
Add checked_math library for convenient overflow checking
...
Instead of
x.checked_add(y).ok_or(error!(MangoError::MathError))?
we can write
cm!(x + y)
2022-03-13 15:45:50 +01:00
Christian Kamm
fce2316b03
Simplify health fn call, use in place serum order
2022-03-12 14:13:19 +01:00
Christian Kamm
16c0a95679
PlaceSerumOrder instruction stub
2022-03-12 14:13:19 +01:00
microwavedcola1
4dc0262546
reformat
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-08 12:45:59 +01:00
Christian Kamm
f6d2df1ad4
Rename to Bank and Group
2022-03-07 16:16:34 +01:00
microwavedcola1
dcacadbcbf
margin trade test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-07 15:24:50 +01:00
microwavedcola1
ce5f2027a1
extract health, flesh out margin trade, todo - test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-03 11:43:56 +01:00
microwavedcola1
268db58294
fix imports
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-10 10:04:47 +01:00
microwavedcola1
5ab8f6e09e
copy structs from v3, next goal is to see what we can retain and what to change
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-10 09:07:34 +01:00