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
Christian Kamm
baa980c659
PlaceSerumOrder: Track vault balances before and after
2022-03-15 14:44:47 +01:00
Christian Kamm
28a26e66da
PlaceSerumOrder: More account validation
2022-03-14 21:53:30 +01:00
Christian Kamm
6b342ffeb9
PlaceSerumOrder basic test
2022-03-14 17:21:16 +01:00
Christian Kamm
a51fdd42f7
Serialization of new serum order instruction data
2022-03-14 15:28:06 +01:00
Christian Kamm
0b2f691f5b
RegisterSerumMarket: pass market_index explicitly
2022-03-14 13:47:34 +01:00
Christian Kamm
07c9b9de7e
Further harmonizing of PDA seeds
2022-03-14 13:39:54 +01:00
Christian Kamm
71cd1755ec
Stop storing token info in Group
...
It is just not needed, the individual Bank accounts have all the
necessary info.
2022-03-14 13:35:38 +01:00
Christian Kamm
1cd0f8d6be
RegisterToken: Pass token_index explicitly
...
This guarantees stability when a gov proposal adds a new token and a new
market in one transaction. This way the RegisterMarket instruction knows
exactly what index the new token will have.
Previously, the new token index was generated automatically, meaning
you couldn't be sure what index a new token would get in advance.
2022-03-14 13:19:50 +01:00
Christian Kamm
2502f0ac1b
checked_math: use a panic
...
This reduces compute use further and still produces good error messages.
2022-03-14 12:45:32 +01:00
Christian Kamm
38d239462f
checked_math: construct errors lazily
...
bad benchmark of compute needs for 100 add-assigns of I80F48:
3465 a + b
3465 a.checked_add(b).unwrap()
3465 cm with unwrap() <- maybe future if we fix panics
4366 cm with ok_or_else() <- now
56494 cm with ok_or() <- old
2022-03-13 20:55:28 +01:00
Christian Kamm
6964340773
CI: Fix test runs
...
For some reason an explicit build-bpf step is needed, otherwise test-bpf
will fail with an error.
2022-03-13 15:45:50 +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
e742926ce2
change seeds literals to camelcase, camel case was how mango did in v3, also matches struct names
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-11 20:10:15 +01:00
microwavedcola1
241dd6080a
Merge pull request #24 from blockworks-foundation/mc/re-org
...
move unused to a unused mod, preparation for working on perp markets
2022-03-11 17:51:32 +01:00
Christian Kamm
693ac17996
Serum: Store open orders pubkey in account
2022-03-11 17:50:04 +01:00
microwavedcola1
c2f91489af
move unused to a unused mod
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-11 17:11:46 +01:00
microwavedcola1
59220f762e
update regex pkg due to vulnerability in the old one
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-11 17:11:35 +01:00
Christian Kamm
c86a6f8d29
Serum: Create OOs is functional and called from a test
2022-03-11 15:28:27 +01:00
Christian Kamm
9be5ad6488
Test: Add CreateSerumOpenOrders test stub
2022-03-11 14:26:42 +01:00
Christian Kamm
da31b6317f
Drop unnecessary rent accounts
2022-03-11 13:02:20 +01:00
Christian Kamm
dbd8409ce8
Test: Add RegisterSerumMarket test stub
2022-03-11 12:59:42 +01:00
Christian Kamm
e3960dc5e2
Outlines of RegisterSerumMarket / CreateSerumOpenOrders
2022-03-11 12:40:16 +01:00
microwavedcola1
4dc0262546
reformat
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-08 12:45:59 +01:00
microwavedcola1
b3f2ca51fa
fixes from cr
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-08 11:11:28 +01:00
Christian Kamm
f6d2df1ad4
Rename to Bank and Group
2022-03-07 16:16:34 +01:00
Christian Kamm
2d65078c23
Fix margin_trade instruction call
2022-03-07 15:43:29 +01:00
Christian Kamm
cea0f9441a
Build fixes
2022-03-07 15:29:44 +01:00
microwavedcola1
8921ac0441
todo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-07 15:24:50 +01:00
microwavedcola1
2882476724
clipppy
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-07 15:24:50 +01:00
microwavedcola1
dcacadbcbf
margin trade test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-07 15:24:50 +01:00
Christian Kamm
425e22a086
Deposit: Compute account health
...
Even if it's currently unused, it will become useful in the future.
Make a function to get the list of accounts needed for health checks in
tests, which is now shared between deposit and withdraw.
2022-03-07 15:22:23 +01:00
Christian Kamm
98cf8a7cff
Position lifetime, dust etc
...
- withdraw and deposit may deactivate positions explicitly
- adjusting bank positions may collect dust for positions between
0 and 1 native tokens
- health check always assumes all active and new banks/oracles are
passed
2022-03-07 15:21:19 +01:00
Christian Kamm
51991d8546
Add global address lookup table test
2022-03-04 20:57:33 +01:00
Christian Kamm
c6031acbdb
Move to global address lookup tables
2022-03-04 20:57:33 +01:00
microwavedcola1
e7736a8c88
Merge pull request #15 from blockworks-foundation/mc/py
...
wip mangopy
2022-03-03 13:12:45 +01:00
Christian Kamm
9692f9976f
Compile and warning fixes
2022-03-03 13:10:20 +01:00
microwavedcola1
528baab867
Merge pull request #17 from blockworks-foundation/mc/margin_trade
...
wip: mc/margin trade
2022-03-03 11:44:23 +01:00