Christian Kamm
7c72a1956a
Withdraw: Allow withdrawing all funds with allow_borrow=false
...
We should also add the ability to withdraw as much as possible without
borrowing and without specifying the exact amount, for convenience.
2022-08-09 11:56:08 +02:00
microwavedcola1
5516ecb132
remove unused param in context
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-08 21:11:15 +02:00
microwavedcola1
d594286266
reserve for ALTs ( #152 )
...
* reserve for ALTs
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* add explicit padding
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-08 18:50:59 +02:00
microwavedcola1
b8bf3a1c40
reorder mango account fields in idl to match on chain order according to MangoAccountFixed
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-08 17:04:54 +02:00
microwavedcola1
ca790c9ef3
add prioritization for token rate update ix in keeper ( #153 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-08 16:31:59 +02:00
microwavedcola1
4f72985f2d
also allow editing group insurance fund ( #149 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-07 14:16:23 +02:00
microwavedcola1
e06736660a
remove account size, make mango account feature position counts explicit ( #148 )
...
* remove account size from program, make position counts explicit
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* cargo-fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-07 14:16:06 +02:00
conj0iner
ff19940ee7
Merge pull request #140 from blockworks-foundation/cj/avgentryprice
...
Added avg entry + break even price
2022-08-07 12:20:33 +08:00
Christian Kamm
dded844693
Update dynamic interest and default token parameters
2022-08-06 21:06:34 +02:00
Conj0iner
dc4a770835
Merge remote-tracking branch 'origin/dev' into cj/avgentryprice
2022-08-06 22:32:59 +08:00
microwavedcola1
6f5f53c1d8
update comment
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-06 13:36:21 +02:00
microwavedcola1
59d28c97a1
fix name and error message check in flash loan ( #145 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-06 12:59:13 +02:00
Christian Kamm
2880a2ec88
Instruction introspection: don't hardcode discriminators
...
Patch anchor to allow access to the generated discriminators.
2022-08-05 23:24:17 +02:00
Nicholas Clarke
e4a073c83b
Clarkeni/group logging ( #142 )
...
* Add group logging and updateIndexAndRate anchor test
* Bugfix on health account ordering
2022-08-05 10:11:44 -07:00
microwavedcola1
dd22ca2ad6
format
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-05 16:17:29 +02:00
Conj0iner
977e85dcf0
Added avg entry + break even price
2022-08-04 22:53:14 +08:00
microwavedcola1
331bb7ebf0
refactor,format
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-04 12:13:36 +02:00
microwavedcola1
dd8086d8eb
format
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-04 12:04:08 +02:00
microwavedcola1
ca6b857a43
format
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-04 12:03:06 +02:00
microwavedcola1
d34dea961c
format
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-04 12:01:23 +02:00
microwavedcola1
a546f6fb3e
format
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-04 11:58:46 +02:00
microwavedcola1
f134f0257a
format
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-04 11:54:19 +02:00
microwavedcola1
7953e123cc
add simple logging
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-04 09:25:19 +02:00
Christian Kamm
22080fdcc1
TokenRegister: Fix anchor seed derivation
...
It likes names constant, but not constant literals.
2022-08-04 08:26:18 +02:00
microwavedcola1
b62c0cd9be
fix
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-03 15:45:10 +02:00
microwavedcola1
9d117c84ac
fix from review
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-03 15:45:10 +02:00
microwavedcola1
505cbd48aa
fixes from review
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-03 15:45:10 +02:00
microwavedcola1
59dd3aa66e
insurance fund for trustless vs not trustful
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-03 15:45:10 +02:00
microwavedcola1
e31ad9ce34
token register trustless
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-03 15:45:10 +02:00
microwavedcola1
9c10101166
remove traces of address lookup tables aka transactions v2
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-02 09:39:08 +02:00
microwavedcola1
374c0eb136
mc/clippy ( #135 )
...
* clippy pass 1
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* clippy pass 2
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-02 09:07:10 +02:00
microwavedcola1
a9a03b97ac
mc/registration time ( #132 )
...
* registration time
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* mc/u32 numbers - consistent numbers in pdas (#133 )
* consistent numbers in pdas
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-01 18:46:45 +02:00
microwavedcola1
5c3b2c1189
mc/kill flash loan 1 & 2 and rename flash loan 3 to flash loan ( #131 )
...
* remove flash loan 1 & 2
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* rename flash loan 3 to flash loan
* fix test
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-01 16:55:17 +02:00
microwavedcola1
c516e45d08
mc/review reserved on accounts ( #130 )
...
* review and extend reserved on accounts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* revert changes to node size, stack gets smashed in rust unit tests
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* max possible
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* max
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* header version
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-01 16:53:30 +02:00
microwavedcola1
e8e774a1a4
mc/feature gating ( #129 )
...
* feature gating
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-01 12:56:29 +02:00
microwavedcola1
91d59c1918
close insurance vault also
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-31 09:57:56 +02:00
microwavedcola1
45fd36642e
prepare group for ownership transfer to governance ( #125 )
...
* prepare group for ownership transfer to governance
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from reviews
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-31 09:28:16 +02:00
microwavedcola1
c88297f42e
mc/ts and keeper improvements ( #127 )
...
* ts and keeper improvements
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* remove stray heroku experiments
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from reviews
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-31 09:25:11 +02:00
microwavedcola1
dfa268dfd6
fix small things to make ci work again ( #126 )
...
* checkout submodules on ci
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* change to https, so that ci can clone
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix clippy
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* redundant clone
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-30 09:49:56 +02:00
microwavedcola1
f2bfb951fd
anchor as submodule ( #121 )
...
* anchor as submodule
* Use anchor submodule as dependency
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-07-27 08:52:41 +02:00
microwavedcola1
2fb92abad8
Mc/ts upgrade ( #122 )
...
* upgrade anchor fork, supports anchor idl close now
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* upgrade ts deps
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-26 17:14:07 +02:00
microwavedcola1
0b2e1e6e6c
Mc/realloc 4 ( #119 )
...
Realloc + dynamic mango account
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-07-25 16:07:53 +02:00
Christian Kamm
46b6bce14b
IDL: Remove NodeRef and NodeRefMut enums
...
Anchor cannot load idls that include enums with tuple variants.
2022-07-22 08:35:30 +02:00
Christian Kamm
ea85824ccb
Remove code copied from solana-address-lookup-table-program
...
This removes the ProgramInstruction enum from the IDL, which was unused
and could break clients.
2022-07-21 06:49:04 +02:00
microwavedcola1
39686d3d0f
CU of test has increased, accomodate only for this test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-20 15:51:10 +02:00
microwavedcola1
3eae2cdc34
upgrade anchor to latest, upgrade solana dependencies to match what latest anchor uses
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-20 15:51:10 +02:00
Christian Kamm
f8d4b2443c
Liq: Don't log common+expected simulation errors
2022-07-20 09:47:37 +02:00
Christian Kamm
2bff4bba3d
Drop being_liquidated after bankruptcy resolves
2022-07-20 09:47:37 +02:00
Christian Kamm
b5d3e2164c
Make Serum3Info and PerpInfo pub again
...
Accidentally reverted in bad merge
2022-07-20 09:47:37 +02:00
Christian Kamm
a82bab4ed7
Better error when vault doesn't have enough funds
...
The spl_token transfer cpi instruction just says "error code: 1", which
is too opaque.
2022-07-19 13:43:05 +02:00
Christian Kamm
348d8cfcd8
Liq/Client: Various improvements
...
- Abstract away account fetching, so it can be done via RPC or from a
websocket stream (or a geyser plugin) that populates a ChainData
instance.
- Separate out information about tokens, markets into MangoGroupContext.
- Separate all gPA calls into functions in a new file
- The liquidator re-fetches critical accounts via RPC before
liquidation. Unfortunately the websocket stream seems slower :/
- Don't re-implement health account derivation in the liquidator.
Instead reuse the existing code from the client.
- More smaller stuff.
2022-07-18 18:18:57 +02:00
Christian Kamm
b44f628c01
LiqTokenWithToken: More error contexts
2022-07-18 18:18:57 +02:00
Christian Kamm
5231ee7f98
Token edit: Fix bug where mintinfo.oracle goes out of sync
2022-07-18 18:18:57 +02:00
Christian Kamm
88a292e656
Health: Add max_swap_for_source function
2022-07-15 10:09:36 +02:00
microwavedcola1
bc4c57911a
Health from health components in ts/client ( #104 )
2022-07-13 19:18:55 +02:00
Christian Kamm
86a84396f5
Health: cleanup and new functions for ratio and assets/liabs
2022-07-12 09:47:23 +02:00
Christian Kamm
6f758ff25b
clippy
2022-07-12 09:46:17 +02:00
Christian Kamm
b77af54f15
Fix tests
2022-07-11 22:31:00 +02:00
microwavedcola1
ef7d2862da
wip: dynamic rates ( #98 )
...
* dynamic rates
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fmt
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-11 17:08:32 +02:00
Christian Kamm
f132f30874
Better error messages
2022-07-08 12:48:43 +02:00
Christian Kamm
469e7fd704
Use get() instead of get_mut() where possible
2022-07-08 09:10:08 +02:00
Christian Kamm
6c7245adaa
Serum3 liq force cancel orders: Deactivate inactive token positions
2022-07-07 13:22:25 +02:00
Christian Kamm
693333b71e
Serum3 place/settle: deactivate inactive token positions
2022-07-07 13:16:23 +02:00
Christian Kamm
9f90c3982f
Fix serum3 loan origination fee withdrawal
...
Paying the loan origination fee must be like a withdrawal and can't be
charged as a borrow if the user has deposits.
2022-07-07 12:33:21 +02:00
Christian Kamm
45da68c6ac
LiqTokenWithToken: Close inactive token positions
2022-07-07 12:24:48 +02:00
Christian Kamm
31831454b4
Return raw position index from get_mut()
2022-07-07 12:01:18 +02:00
microwavedcola1
0ff269c38c
Merge branch 'main' into dev
2022-07-06 17:47:45 +02:00
microwavedcola1
ab3abc69e7
Fix flash loan3 - fetching of bank from retriever
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-06 17:41:08 +02:00
microwavedcola1
b0f1585541
Merge branch 'main' into dev
2022-07-06 17:11:20 +02:00
microwavedcola1
8a1e9136a6
better error msg
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-06 17:11:12 +02:00
Christian Kamm
ffd83a7a05
Rename instructions to follow naming pattern ( #97 )
2022-07-06 14:51:15 +02:00
Nicholas Clarke
348fbc1cb9
Track cumulative net deposits (deposits - withdraws) ( #91 )
...
Track cumulative net deposits (deposits - withdraws) using prices at the time of the deposit and withdraw.
This is used for calculating overall pnl (across all tokens).
I want to store UI amount * UI price = (native amount / base decimals) * (oracle price * base decimals / quote decimals) => native amount * oracle price / quote decimals.
I have used f32 here to reduce the space required on the mango account - we don't need so much precision for this as it's purely a display value.
I've also included a field for net_settled - this will be used for perp pnl but is not implemented yet (as perp settling instructions are not ready).
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-07-06 12:07:30 +02:00
Christian Kamm
de86b69e1a
Client/program interface changes
...
- rearrange structs to have gPA data in front and add comments about the
offsets being relevant
- add insuranceMint to group creation in client
- drop quoteTokenIndex storage on PerpMarket
- fixes to editAccount in example1-user and client
2022-07-06 11:34:07 +02:00
Christian Kamm
35517bdb75
Review fixes
2022-07-06 11:34:04 +02:00
Christian Kamm
b25f6d5f4f
Insurance fund
2022-07-06 09:07:50 +02:00
Christian Kamm
35ca4d31b3
liq_token_bankruptcy instruction for socialized loss
2022-07-06 09:07:49 +02:00
Nicholas Clarke
30fc7def77
Add oracle price to update_index logging. ( #89 )
...
* Add oracle price to update_index logging.
* Update IDL with changes to update_index instruction and logging.
2022-07-05 11:59:44 -07:00
microwavedcola1
d74cc78a84
edit tokens, perp markets, mango accounts, allow delegate to perform certain operations ( #94 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-05 19:31:47 +02:00
microwavedcola1
dff3f7cd8c
client functions via program simulation
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-04 14:11:38 +02:00
microwavedcola1
39284c5705
Flash loan 3 minimal example ( #90 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-04 12:09:33 +02:00
microwavedcola1
6a99eb893b
Fix types
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-01 14:31:47 +02:00
Christian Kamm
30a221047c
Bank: rename indexed total deposits and schedule for removal
2022-07-01 14:08:28 +02:00
microwavedcola1
e8cb27610e
close mango account without checks when testing flag is set on the group, workaround weird issues when all dust cant be withdraw ( #92 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-01 13:38:50 +02:00
Christian Kamm
6d05306859
Improve FlashLoan3 docs
2022-06-30 18:45:17 +02:00
Nicholas Clarke
f8da1f6a40
Clarkeni/logging ( #81 )
...
* Add logging
* Added new_fixed_order_account_retriever to allow us to more easily access oracle prices outside of health calculations for logging purposes
* Add token balances logging to token and token liquidation and add logging to margin trade
* rust format
* fix clippy errors
* Address PR requested changes
* fix flash_loan
* Recalculate raw_token_index in token withdraw to account for position becoming inactive
* Fix retrieving oracle for logging
in get_mut_or_create(), return the raw index into the account's token
positions as well as the index into active positions only. The latter
index is useful for indexing into banks in the health account list.
* Add logging flash_loan2 and flash_loan3
* Refactoring flash loan logging
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-06-30 14:35:05 +02:00
microwavedcola1
1c02ccd21d
Transfer dust from bank vaults to a dust account, without this we wont be able to close bank vaults ( #88 )
2022-06-29 09:11:14 +02:00
Christian Kamm
86d635f5d0
FlashLoan3: Variant that transfers directly
...
FlashLoan2 requires the user to set up transfers to and from the Mango
vault accounts. This version directly provides the loaned funds into a
target token account and repays everything that exceeds the initial
token account balance at the end.
2022-06-28 15:32:26 +02:00
Christian Kamm
d786a672f1
FlashLoan2: API with Begin and End instructions
...
For FlashLoan users had to pass the target cpi programs, accounts and
data to the FlashLoan instruction itself.
The new API allows existing instructions to be used unchanged, they
just need to be bracketed by FlashLoan2Begin and FlashLoan2End.
2022-06-28 15:30:13 +02:00
Christian Kamm
3eedba67b1
Fix serum3_cancel_order
...
accidental removal of mut in 20fc9d557a
2022-06-27 11:38:55 +02:00
microwavedcola1
9fc8a5a56a
multiple banks ( #82 )
...
* multiple banks
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* test for closing multiple banks for a registered token
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix deregister_token
* update idl
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-06-27 11:27:17 +02:00
Christian Kamm
20fc9d557a
Satisfy anchor's lint by adding CHECK: comments
2022-06-24 12:36:35 +02:00
microwavedcola1
7a28a3bfb0
improvements to flash loan
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-23 16:41:24 +02:00
microwavedcola1
54c0306ae7
Fix flash loan
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-23 13:10:15 +02:00
Christian Kamm
0bd5b8fdf3
Rename margin_trade.rs -> flash_loan.rs
2022-06-23 10:23:52 +02:00
Christian Kamm
c8ebc1f611
Rename MarginTrade -> FlashLoan
2022-06-23 10:23:52 +02:00
Christian Kamm
d8a6a29e70
Renames: propagate to idl and ts
2022-06-23 10:04:54 +02:00
Christian Kamm
648b462352
Rename MangoAccount components
2022-06-23 10:04:54 +02:00
Christian Kamm
1143b38d3c
Health review comments
2022-06-22 16:52:11 +02:00
Christian Kamm
ba79995c01
Health: order-independent serum3 health
...
Now all the reserved funds in serum3 open orders accounts are added into
each possible token at the same time. Then the worse case from applying
the reserved funds to either quote or base is selected.
This is reasonably cheap to compute, leads to unchanged results when no
markets share (non USDC) base or quote tokens, but can underestimate
the "true" health value when markets do.
An additional advantage is that HealthCache is now indepenent of serum
open orders and can compute the init and maint health when the user has
active OpenOrders accounts.
2022-06-22 16:52:11 +02:00
Christian Kamm
d4cec8dfa4
Bank: Fix bug when when depositing to exactly 0
2022-06-22 16:51:16 +02:00
Christian Kamm
aeb94642ce
fix clippy warnings
2022-06-21 13:10:37 +02:00
Christian Kamm
5dd186ac13
Health: fix unittests
2022-06-21 13:02:47 +02:00
Christian Kamm
6f41efad0f
Health: helper for finding token info by index
2022-06-21 13:02:47 +02:00
microwavedcola1
b0fd4c2a61
Fix warnings
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-21 13:02:30 +02:00
microwavedcola1
86c8817e0b
serum3 loan origination fees ( #69 )
...
* serum3 loan origination fees
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fix tests
Fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-21 11:45:38 +02:00
Christian Kamm
cb0010b2b5
Health: never allow positive contributions from perps
2022-06-21 11:07:13 +02:00
Christian Kamm
be98f6524a
Orderbook: Avoid usize fields in data
2022-06-21 11:05:46 +02:00
Christian Kamm
6ff4ff5910
Add a ComputeHealth instruction
...
This way the client can ask for simulation to determine an account's
health.
2022-06-21 11:05:32 +02:00
Christian Kamm
712bece0b2
Remove stray log message from health computation
2022-06-20 18:21:26 +02:00
microwavedcola1
470292024e
Filter out bad switchboard prices ( #70 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-20 18:03:16 +02:00
microwavedcola1
5b78293c5c
minor refactoring
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-19 18:32:04 +02:00
microwavedcola1
9462be7f0b
Fix margin trade interface
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-18 17:14:20 +02:00
microwavedcola1
4864562ff3
margin trade, support multi cpi ( #68 )
...
* margin trade, support multi cpi
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* todo
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-18 16:43:45 +02:00
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
microwavedcola1
de481a4008
todo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-10 08:42:26 +02:00
microwavedcola1
740ff0c09e
Close various things ( #65 )
...
* close bank, vaults, mint infos, stub oracles, serum OO (doesnt work, throws https://github.com/project-serum/serum-dex/blob/master/dex/src/error.rs\#L88 ), close serum market
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* serum oo closing example in ts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fix from code review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-09 18:27:31 +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
a14f37362d
margin_trade: forbid direct self-calls
2022-06-07 13:25:30 +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
1b4063cd0d
remove misleading example
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-03 08:29:35 +02:00
microwavedcola1
47bccfeec8
Fix oracle price decimal usage
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-02 19:16:30 +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
microwavedcola1
383489ae34
Merge branch 'mc/liquidator-bot' into dev
2022-05-30 17:08:16 +02:00
Christian Kamm
48cb1f0b88
Compute health in perp_place_order
2022-05-29 20:50:21 +02:00
Christian Kamm
65a5139db7
Tests: Send perp markets as health accounts
2022-05-29 20:50:21 +02:00
Christian Kamm
4984bba71e
Health: Add perp health calculation
2022-05-29 20:50:21 +02:00
microwavedcola1
97e434fbb6
keeper: find/create account by account name
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-29 12:25:12 +02:00
microwavedcola1
34a8f0919f
serum taker bot ( #57 )
...
* taker bot
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* inline code
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* cleanup
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* add mints
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* add todo
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix todos
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* remove stray log
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* cleanup
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* remove dead code
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* use same rust as what solana uses, use same solana version as cargo toml
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fix from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix from reviews
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* linter
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-28 07:05:34 +02:00
microwavedcola1
cc2d46bf4a
add support for mint decimals on bank, for easy look up
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-27 14:52:03 +02:00
Christian Kamm
b1fcb4a7e6
CreateGroup: Allow multiple groups per admin
2022-05-27 11:36:50 +02:00
Christian Kamm
1844898280
margin_trade: Allow forwarding mint accounts
2022-05-26 21:12:02 +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
Christian Kamm
946e6b1c96
margin_trade: doc improvements
2022-05-25 08:02:55 +02:00
microwavedcola1
ed4e63a82f
Change tuple to a struct, seemingly anchor ts doesnt support tuples
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-24 22:03:35 +02:00
Christian Kamm
f844720130
Review fixes
2022-05-24 13:00:32 +02:00
Christian Kamm
53a5e208fd
margin_trade: loan origination fees, limited withdraws
2022-05-23 08:55:30 +02:00
Christian Kamm
21af012d1f
Improvements to margin_trade
...
- don't hard-code the group as the first passed account
- token::approve() banks for each token vault
- sign for each bank
- deal with using tokens without an existing position
- handle deactivation of token account if balance goes to 0
2022-05-20 10:16:09 +02:00
Christian Kamm
8a8b36e345
Fold loan origination fee handling into Bank
2022-05-18 22:53:03 +02:00
microwavedcola1
717b72857d
Remove anchor dummy type workaround ( #53 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-18 17:16:14 +02:00
microwavedcola1
ab0df0e7f2
unwrap
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-17 17:11:37 +02:00
microwavedcola1
2de149f74c
checked math + rustfmt
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-17 17:08:00 +02:00
microwavedcola1
6ecd4a0da9
Update funding for keeper
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-17 15:59:47 +02:00
microwavedcola1
2518ec24a6
Update client to match program changes
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-17 15:06:29 +02:00
microwavedcola1
f19f3da659
add todo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-17 13:01:48 +02:00
microwavedcola1
a4f3569a87
Fix merge
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-17 10:12:16 +02:00
microwavedcola1
fac9b4a57a
perp funding
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-17 10:07:24 +02:00
microwavedcola1
be73106ce1
perp funding ( #51 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-16 15:34:56 +02:00
microwavedcola1
f5c505f847
fix test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-16 15:26:38 +02:00
microwavedcola1
db82fcbbcc
perp cancel order instructions
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-16 10:49:11 +02:00
microwavedcola1
67c1d5d451
format
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-16 10:49:11 +02:00
microwavedcola1
967ce34002
move comment
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-16 10:49:11 +02:00
microwavedcola1
a1034c08b7
refactor
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-16 10:49:11 +02:00
microwavedcola1
ee6fe93b26
Fix tests
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-16 10:49:11 +02:00
microwavedcola1
fbd3fd410c
loan_origination_fees
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-16 10:49:11 +02:00
microwavedcola1
f1791be039
add todo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-11 20:25:09 +02:00
microwavedcola1
b903073ce6
add comment so that it doesnt get lost
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-11 20:09:12 +02:00
microwavedcola1
81f0f38188
ts client support for perps
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-11 20:06:07 +02:00
microwavedcola1
15961ec81c
fees for borrows
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-09 11:14:50 +02:00
microwavedcola1
5266668bc2
keeper: consume events
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-06 14:19:49 +02:00
microwavedcola1
7abfc417ac
reorg
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-06 10:13:33 +02:00
microwavedcola1
9f5a2fd32e
add a test for consume events, add debug impl for mango account for easy debugging in tests
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-05 10:25:32 +02:00
microwavedcola1
d38ca0de4c
refactor
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-03 18:17:58 +02:00
microwavedcola1
ec7c61327c
list of ix to implement
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-05-03 18:07:31 +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
3c469d7194
todo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-12 20:43:45 +02:00
microwavedcola1
1206109260
todo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-12 20:39:48 +02:00
microwavedcola1
7ead988ba4
small ticker size
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-12 20:38:35 +02:00
microwavedcola1
6db679d35e
support longer account names
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-12 20:23:45 +02:00
microwavedcola1
e3a60a637a
format
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-12 17:35:39 +02:00
microwavedcola1
bf2fa47a1c
fix viz
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-12 17:33:42 +02:00
microwavedcola1
62ee1bc5c0
prepare for multiple ts packages
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-12 17:28:47 +02:00
microwavedcola1
addb12736f
fixes from cr
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-12 16:53:45 +02:00
microwavedcola1
03ae43017c
account, market and bank names
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-12 16:19:58 +02:00
microwavedcola1
1b1dd1a541
poc keeper
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-09 21:18:07 +02:00
microwavedcola1
5ab48fb6e0
rust: Fix args in tests to more realistic values, ts: expose args, update idl
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-09 17:09:06 +02:00
microwavedcola1
57d9de86c8
comment
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-09 16:55:00 +02:00
microwavedcola1
257ccf76ad
multi legged interest rates + keeper ix
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-09 16:53:30 +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
Christian Kamm
6f3673bcdf
Perp: Track taker and maker orders in the account; test
2022-04-04 10:39:13 +02:00
microwavedcola1
a44120c470
add group to mintinfo, for better gpa support
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-03 19:07:43 +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
microwavedcola1
9debc63a6a
update idl, add tokenmint to stuboracle for gpa ( #34 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-03 05:43:32 +02:00
microwavedcola1
884d638e36
Merge pull request #33 from blockworks-foundation/mc/stub-oracle-ext
...
Mc/stub oracle ext
2022-04-03 05:36:24 +02:00
microwavedcola1
ace5df2a85
revert unintended changes
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-03 05:21:16 +02:00
microwavedcola1
d7a8c5c91d
add todo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-02 21:04:00 +02:00
microwavedcola1
77ddbd4eeb
fix test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-02 21:02:48 +02:00
microwavedcola1
c7d3103e6b
--wip-- [skip ci]
2022-04-02 20:42:17 +02:00
microwavedcola1
4d1a9e4556
refactor
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-02 20:15:56 +02:00
Christian Kamm
9f0a7f67ae
Orderbook: Port over unittests
2022-04-02 13:51:26 +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
microwavedcola1
1d15db37c5
clippy
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-02 10:02:12 +02:00
microwavedcola1
9cd08a1355
improve checks
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-02 09:52:40 +02:00
microwavedcola1
87bcc538cd
compiles
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-02 09:05:31 +02:00
microwavedcola1
0bdbd19ddd
Make Serum3 ix anchor friendly
...
Make work with changes in mango account, add no deploy part to release script
Clippy
Fixes from cr
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-04-02 08:59:07 +02:00
Christian Kamm
d26caf1c87
Perp: Rename fields to be explicit about being in lots
2022-04-01 15:47:12 +02:00
Christian Kamm
f2607889e3
Perps: Place accounts and open orders in MangoAccount::perp
...
Also make test_perp succeed by fixing the FillEvent size.
2022-04-01 12:45:01 +02:00
Christian Kamm
f48a7f5ed9
Clippy: Address issues
2022-04-01 12:21:19 +02:00
Christian Kamm
833a909aa4
Orderbook: unify new_bid/new_ask
2022-04-01 12:21:19 +02:00
Christian Kamm
6505abcd54
Side: Make inversion function be associated
2022-04-01 12:21:19 +02:00
Christian Kamm
10ab9804d1
Rename perp instructions to have perp_ prefix
2022-04-01 08:01:56 +02:00
Christian Kamm
8038f9e257
Add CloseAccount instruction to make testing easier
2022-03-31 17:22:56 +02:00
microwavedcola1
9e2d5de914
add gt 0 checks
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-31 16:02:18 +02:00
microwavedcola1
78df0082c4
Some progress on initial ts example
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-31 15:58:18 +02:00
Christian Kamm
56e3bd8740
Rearrange accounts to avoid padding bytes
2022-03-31 14:37:05 +02:00
Christian Kamm
9cf4f1a748
Rearrange MangoAccount to avoid padding bytes
2022-03-31 14:01:08 +02:00
Christian Kamm
85b0b420d4
Disable address lookup tables
...
Because the ALT program isn't available on devnet yet, so prohibits
testing there.
2022-03-31 09:25:47 +02:00
microwavedcola1
795fa532da
update program, and deploy to devnet
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-30 17:16:32 +02:00
microwavedcola1
faba5c47bf
remove unwanted code
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-30 17:03:56 +02:00
microwavedcola1
46cb811c99
Merge branch 'mc/consume_events'
2022-03-30 13:22:31 +02:00
Christian Kamm
afbfd3b7f9
serum3_register_market: better validation
...
Previously we just trusted the base and quote token index to be correct,
now the appropriate banks are validated.
2022-03-30 12:24:49 +02:00
Christian Kamm
babbff6bec
Add is_bankrupt check to most instructions
2022-03-30 12:24:49 +02:00
microwavedcola1
00ac0dfce9
comments and test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-30 11:58:45 +02:00
Christian Kamm
14d4147efa
liq test: Cover more cases
2022-03-30 09:37:31 +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
microwavedcola1
64e3ba0d7c
--wip-- [skip ci]
2022-03-28 21:13:16 +02:00
Christian Kamm
a6ff388e20
health: avoid divisions, reducing compute needs
2022-03-27 14:47:42 +02:00
Christian Kamm
d9ac178481
liq token: Adjust fee handling
...
Use the sum of the fees configured for the tokens.
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
microwavedcola1
b139f6beab
ask example test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-26 17:27:50 +01:00
microwavedcola1
b851dd13ad
add new ask
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-26 17:06:55 +01:00
microwavedcola1
c83be301e4
extend
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-26 06:41:39 +01:00
microwavedcola1
1e5a6f90bc
extend
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-26 06:37:32 +01:00
microwavedcola1
223179b278
basic test to measure cu
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-26 06:16:52 +01:00
microwavedcola1
c7bf53659c
fix warning
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-25 20:44:06 +01:00
microwavedcola1
00da3460ab
cleanuo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-25 20:35:19 +01:00
microwavedcola1
860b7aa1d4
cleanup
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-25 20:03:44 +01:00
microwavedcola1
27eaa5f8f5
ported fees
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-25 09:46:38 +01:00
microwavedcola1
3036ffa45c
clippy
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 19:27:00 +01:00
microwavedcola1
671c06da89
events
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 19:20:56 +01:00
microwavedcola1
0e953f5e80
more
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 19:15:46 +01:00
microwavedcola1
f895467bf5
weights
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 17:29:30 +01:00
microwavedcola1
21073d6b71
cleanup
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 16:12:55 +01:00
microwavedcola1
de0ce5ad8f
cleanup
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 15:29:42 +01:00
microwavedcola1
baf4b255c8
remove more dead code
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 14:48:11 +01:00
microwavedcola1
1eaf58812f
remove more dead code
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 14:46:09 +01:00
microwavedcola1
ba4300accc
simplify
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 14:40:08 +01:00
microwavedcola1
4a3d61a0b0
cleanup unused
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 14:08:10 +01:00
microwavedcola1
e6ee72b8b0
remove unused
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-24 13:45:46 +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
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
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
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
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
Christian Kamm
9692f9976f
Compile and warning fixes
2022-03-03 13:10:20 +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
6702cdbba6
mc/pyth ( #14 )
...
* pyth integration
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-02 21:11:05 +01:00
Christian Kamm
01e8458093
Tests: Read banks/oracles from address lookup table
2022-03-01 15:12:53 +01:00
Christian Kamm
fa008a8aa1
Move address map functions into separate module
2022-03-01 15:01:50 +01:00
Christian Kamm
eb38fb4f18
Make module for address_lookup_table functions
2022-03-01 13:57:46 +01:00
Christian Kamm
a7975d390d
Tests: Fix warnings
2022-03-01 13:49:59 +01:00
microwavedcola1
2a698f3135
Merge pull request #13 from blockworks-foundation/mc/oracle-in-withdraw
...
basic stub oracle integration in tests and withdraw
2022-03-01 06:38:13 +01:00
microwavedcola1
d9c7260375
code review
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-03-01 06:28:12 +01:00
Christian Kamm
3e6d722e01
Deposit: Don't add accounts to lookup table twice
2022-02-28 20:12:37 +01:00
Christian Kamm
5ebf425a65
Deposit: Extend the lookup table with bank and oracle
...
When the position goes from inactive to active.
2022-02-28 19:43:40 +01:00
microwavedcola1
5299e31ff8
basic stub oracle integration in tests and withdraw
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 17:17:01 +01:00
Christian Kamm
9a50325718
fix outdated comment
2022-02-28 15:45:56 +01:00
Christian Kamm
75092f7681
CreateAccount: Initialize an address lookup table
2022-02-28 15:43:08 +01:00
microwavedcola1
c7cd564d11
fix test, was missing oracle
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 14:48:59 +01:00
microwavedcola1
362b180069
add oracle to to token registration
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 14:44:08 +01:00
microwavedcola1
12d2a9f962
make clippy happy
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 12:56:26 +01:00
microwavedcola1
1c47f0d004
add ix handling for stub oracles
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 12:37:12 +01:00
microwavedcola1
3355ed1dcf
dont need special crate for this
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 11:18:55 +01:00
microwavedcola1
364f5d895b
fix use statement location
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 11:18:35 +01:00
microwavedcola1
e8b1563223
optimise imports
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 11:07:04 +01:00
microwavedcola1
3648cba0d0
use discriminator to differentiate between oracles, removes need for a magic constant, same could be done for other oracles
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 11:05:15 +01:00
microwavedcola1
6345d3ebd4
add todo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 10:45:03 +01:00
microwavedcola1
c0c115bd03
remove unused
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 10:44:08 +01:00
microwavedcola1
823fbeb6b5
stub oracle ix and account state
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-28 10:36:31 +01:00
Christian Kamm
b88989bf3a
Tests: Transport error info on send_tx()
2022-02-28 09:12:24 +01:00
Christian Kamm
7aa2cd7e13
Test cleanups
2022-02-28 09:03:43 +01:00
Christian Kamm
1b404cc652
Basic health check, no oracles yet
2022-02-26 17:47:16 +01:00
Christian Kamm
174d38a199
Don't check PDA seeds on use, instead store addresses
...
This saves about 5000 CU currently, making Deposit/Withdraw go from
26000 CU to 21000 CU.
2022-02-26 12:17:20 +01:00
Christian Kamm
2ef2424ac5
Move the asset/liab weights to the Bank account
2022-02-26 12:04:42 +01:00
Christian Kamm
8f5becc0d5
Asset/liab weights and withdraw amounts
2022-02-25 18:29:54 +01:00
Christian Kamm
d1e2cc28b7
Outline of withdraw instruction
2022-02-25 15:14:15 +01:00
Christian Kamm
5f5ba723d6
Add basic test setup
2022-02-25 13:12:16 +01:00
Christian Kamm
818bd6fe48
Enable anchor seeds extraction
2022-02-23 10:55:23 +01:00
Christian Kamm
70d3603cb4
Rename group.owner -> group.admin
2022-02-23 10:19:54 +01:00
Christian Kamm
9f013fb22a
Initialize bank indexes
2022-02-23 10:15:33 +01:00
Christian Kamm
5a4b6263ac
Add deposits/borrows tracking
2022-02-23 10:09:01 +01:00
Christian Kamm
8bc0416ef6
Helper functions to simplify
2022-02-22 17:13:26 +01:00
Christian Kamm
6b5162cce0
Remove root bank
2022-02-22 16:46:55 +01:00
Christian Kamm
1b935335fb
Drop Default impls, manually set account space
...
This fixes stack issues.
I don't know why anchor uses bytemuck::from_bytes(&T::default()).len()
2022-02-22 15:55:30 +01:00
Christian Kamm
13d1ebb614
Remove bad annotation
2022-02-22 14:40:49 +01:00
Christian Kamm
fdfab14e43
Drop unneeded associated token account program
2022-02-22 14:35:10 +01:00
Christian Kamm
c9ad4f0c94
Very basic deposit instruction
2022-02-22 14:23:13 +01:00
Christian Kamm
901062d0c1
Add token bank and vault accounts
2022-02-22 13:31:18 +01:00
Christian Kamm
76a4e717c3
Add forgotten create_account.rs
2022-02-22 13:31:03 +01:00
Christian Kamm
9b16feaf44
CreateAccount instruction outline
2022-02-22 13:15:13 +01:00
Christian Kamm
6a7881b725
RegisterToken instruction outline
2022-02-22 10:19:40 +01:00
Christian Kamm
cb94c7c598
CreateGroup instruction outline
2022-02-22 10:16:13 +01:00
Christian Kamm
6160a80457
First ideas for MangoGroup and MangoAccount accounts
2022-02-22 10:15:37 +01:00
Christian Kamm
d4246f7da1
Upgrade to anchor 0.22.0
2022-02-22 10:09:40 +01:00
Christian Kamm
a79ee2c8e2
Fix compile by disabling unadapted state/ structs
2022-02-22 10:09:40 +01:00
microwavedcola1
b362d3320b
notes for self
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-10 10:50:57 +01:00
microwavedcola1
f2921d2272
add todos
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-10 10:49:45 +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
microwavedcola1
d7229d7a48
Program struct
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-02-02 11:55:44 +01:00
microwavedcola1
b35802c555
turn off doc tests, make script executable
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-01-21 19:25:13 +01:00
microwavedcola1
66172881a1
First commit
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-01-21 19:21:46 +01:00