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
Christian Kamm
d0fef4a586
Test: simplify allow(dead_code) to be per-file
2022-08-30 15:32:59 +02:00
Christian Kamm
8a2d54cce8
Fix some clippy warnings
2022-08-30 13:59:34 +02:00
Christian Kamm
801b68b93c
MangoAccount: add unittests
2022-08-30 13:11:47 +02:00
Christian Kamm
77b8e6e8b9
SerumPlaceOrder: Fix vault balance check for base_lot_size
...
As spotted by microwavedcola
2022-08-30 12:05:07 +02:00
Christian Kamm
1f0138d1de
SerumCloseOO: Reduce in_use_count of token positions
2022-08-30 12:05:07 +02:00
Christian Kamm
8e30870689
SerumLiqForceClose: Proper health/liq checking
2022-08-30 12:05:07 +02:00
Christian Kamm
e0437305ee
SerumPlaceOrder: Only pass the payer bank/vault
2022-08-30 12:05:07 +02:00
Christian Kamm
36723792a1
SerumRegister: Block using the same market index twice
2022-08-30 12:05:07 +02:00
Christian Kamm
dc4acd0dd7
Serum: loan origination fee, don't auto-settle, fix vault check
...
- Loan origination fees: The previous approach of tracking the reserved
amount did not work because OutEvents will also reduce the reserved
amount. This means we can't know if it was an OutEvent-cancel or an
order execution that caused the reduction.
Instead, we now track the amount of borrows that was made (without
applying origination fees) in place order. Whenever we try to settle
and the amount of tokens on the oo account is less than the potential
borrows, we can be certain that the borrow has actualized.
- Place order is no longer automatically followed by a settle.
This can reduce compute use when people want to place multiple orders
in sequence. Now they can use the HealthRegion instructions to place
their orders, settle once at the end, and then have health checked.
- Vault check: Place order previously rejected valid orders because it
didn't consider that there could be free tokens on the oo account.
- Tests: Some infrastructure for less verbose serum testing.
2022-08-30 08:38:13 +02:00
Christian Kamm
e1adbf0217
Tests: Fix concurrent log capture
2022-08-30 08:37:29 +02:00
Christian Kamm
d6d66402f7
Tests: Helper for create + fund
2022-08-30 08:37:29 +02:00
Christian Kamm
7d508e5df5
MangoAccount: Fixes after audit
2022-08-29 16:13:15 +02:00
Christian Kamm
d63c5bfc76
Serum: Don't attempt deactivating token positions after serum actions
...
While a serum open orders is active, the base and quote token positions
for it are locked to active. It's pointless to check if they need to be
deactivated after place/settle etc.
2022-08-26 11:45:54 +02:00
Christian Kamm
1a95a84ed4
Serum: Comments on account constraints
2022-08-26 11:45:54 +02:00
microwavedcola1
453248bbe5
token_deregister: remove redundant token index and add doc ( #192 )
...
* token_deregister: remove redundant token index
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix test
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-25 19:25:56 +02:00
Christian Kamm
dfa8166aee
Health: Put common pre/post check logic into functions
2022-08-24 16:39:36 +02:00
Christian Kamm
bba27ed6f0
PlacePerpOrder: pre-health computation
2022-08-24 16:07:22 +02:00
Christian Kamm
38b349a401
Rename PerpOpenOrders -> PerpOpenOrder, since it's a single one
2022-08-24 15:22:55 +02:00
Christian Kamm
cb0a9e5d2b
Tests: allow checking of logged "post_health"
2022-08-24 14:15:01 +02:00
Christian Kamm
c8159746e7
Tests: Remove unnecessary argument
2022-08-24 14:15:01 +02:00
Christian Kamm
45f52ae535
Serum3PlaceOrder: compute pre-health
2022-08-24 14:15:01 +02:00
Christian Kamm
40f467024d
FlashLoan: Add pre-health check
2022-08-24 14:15:01 +02:00
Christian Kamm
1ebbac7d6f
Withdraw: Add pre-health check
2022-08-24 14:15:01 +02:00
Christian Kamm
2d2cef35a0
Add HealthRegion instructions
...
You can do
- HealthRegionBegin
- ... mango instructions ...
- HealthRegionEnd
and the account health will only be checked at the start and end
instead of for every instruction.
2022-08-24 10:07:45 +02:00
Christian Kamm
c9fb4c7133
Tests: Fix program log capture
2022-08-24 10:07:45 +02:00
Nicholas Clarke
704dfcaa27
Clarkeni/loan fee logging ( #180 )
...
Logging for loan origination fees and token bankruptcy
2022-08-19 18:50:54 -07:00
Christian Kamm
09fc5f716b
Renames in MangoAccount
...
- Accessors in MangoAccountValue
- PerpPositions -> PerpPosition
2022-08-19 14:58:20 +02:00
Christian Kamm
ec850b7bd3
Fix size of account_num in idl
2022-08-19 14:52:31 +02:00
Christian Kamm
403226dc28
BeingLiquidated: Deactivate flag on positive health
2022-08-18 13:12:13 +02:00
Christian Kamm
a23afed7de
Fix computation of utilization time-weighted average
2022-08-17 15:29:11 +02:00
Nicholas Clarke
8a1c58e723
FlashLoan: Add flash_loan_type ( #164 )
...
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-08-17 12:36:55 +02:00
Christian Kamm
e8bbfbef83
Bank: fix collection of loan fee
...
Instead of changing indexed_borrows, change borrow_index!
2022-08-16 16:27:45 +02:00
Christian Kamm
4c65204c19
Liquidator: Fix condition for starting to liquidate
2022-08-16 16:19:04 +02:00
Christian Kamm
421b2d3d19
FlashLoan: Fix validation holes
...
- Pass the group to Begin and End and ensure it is the same.
- Enforce target token accounts can't be group-owned.
- Now End can consistently derive the number of vaults/token accounts.
2022-08-16 13:10:05 +02:00
Christian Kamm
54222c5b3f
liq_token_bankruptcy: don't pass redundant index
2022-08-16 13:08:57 +02:00
Christian Kamm
e92561d32e
Liquidation: Fix rounding issues in liq_token_bankruptcy
...
By explicitly dusting trace positive positions.
2022-08-16 13:08:43 +02:00
Christian Kamm
961a81b94f
Liquidation: Fix positive dust issues
2022-08-16 13:08:43 +02:00
Christian Kamm
af5f622bd8
Liquidator: bankruptcy requires borrows
2022-08-16 12:13:54 +02:00
Christian Kamm
c9a5fb5fc1
ScanningAccountRetriever: Don't mut-borrow oracles ( #170 )
...
This allows using the same oracle for different banks, like for ETH and
soETH.
2022-08-15 11:32:54 +02:00
Christian Kamm
58105207af
Make anchor's lint pass
2022-08-15 10:48:43 +02:00
Christian Kamm
0265b9b0a9
Account: Change type of net_deposts / net_settled
...
Because f32 doesn't have enough significant digits for large deposits.
2022-08-15 10:48:43 +02:00
Christian Kamm
18857c7b72
Add "client" feature annoations
2022-08-15 10:48:43 +02:00
Christian Kamm
6a77a5c349
tests: fix compilation warnings
2022-08-15 10:48:43 +02:00
Christian Kamm
fcecd21cdb
health: remove duplicated code
2022-08-15 10:48:43 +02:00
microwavedcola1
1b6ed725be
over explaining the code ( #168 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-14 20:45:57 +02:00
Christian Kamm
7a343a9a8d
checked_math: support casts and I80F48::from
2022-08-14 15:01:15 +02:00
Christian Kamm
d91a676e3d
Oracle: Decimal constant cleanup
2022-08-14 15:01:15 +02:00
Christian Kamm
724824d21a
Bank: small fixes from audit
2022-08-14 15:01:15 +02:00
Christian Kamm
ccba4ee597
Cleanups and bugfixes from the audit ( #163 )
...
* AccountExpand: cleanups from audit
* Group instructions: cleanups from audit
* AccountClose: cleanups from audit
* TokenAddBank: Audit fixes, including significant bugs
Must not take collected_fees and bump from the existing bank.
* Instruction comment updates
* GroupEdit: Add version/testing flag changes
Ported from mc/vanity
2022-08-13 19:54:58 +02:00
Christian Kamm
21815612ae
Let all PDA seeds start with a unique prefix ( #166 )
...
This is mostly paranoia. Now it's guaranteed that different PDA types
have unique seeds.
2022-08-13 19:30:35 +02:00
Christian Kamm
a3067e2448
Avoid custom Debug impls by using derivative crate
2022-08-13 10:18:04 +02:00
microwavedcola1
261c856bb2
reduce max source swap targetError so that we dont error out
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-12 11:08:08 +02:00
Christian Kamm
92a37f23ed
Remove is_bankrupt
...
Instead, check for any liquidatable assets in liq_token_bankruptcy.
Bankrupt accounts may use the same operations as any other
negative-health account.
2022-08-11 22:57:53 +02:00
Conj0iner
02c19a6eb4
Optimise entry price calculations
2022-08-11 22:58:47 +08:00
Christian Kamm
ac58081430
Audit: Fix some account constraints
2022-08-11 13:30:04 +02:00
Christian Kamm
e8479e2e7c
liq_token_with_token: Correctly adjust health cache for dusting
...
Previously the health cache adjustments didn't take into account that
positions between 0 and 1 native token would be dusted to 0.
This makes a difference for valuable tokens with few decimals. For
example 1 BTC-native token is currently worth 500k SOL-native tokens.
That means 0.9 BTC-native would easily be enough collateral for a 10k
SOL-native borrow -- but if the 0.9 get dusted, then the whole account
is bankrupt instead.
2022-08-10 16:24:48 +02:00
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