Commit Graph

1046 Commits

Author SHA1 Message Date
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
tjs ff7638f04b throw error when reloading account if simulation fails 2022-08-27 03:55:55 -04:00
tjs a12457eeb5 log in getTokenVaultBalanceByMint 2022-08-27 01:58:20 -04:00
tjs b35bca95a1 improve transaction confirmation 2022-08-26 15:42:10 -04:00
tjs 2e88889043 remove async and unused arg in getTokenVaultBalanceByMint 2022-08-26 13:54:14 -04: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 4025624738 Merge branch 'main' into dev 2022-08-26 10:45:56 +02:00
microwavedcola1 177770c580 small updates to debug scripts, also log vault balance in ui and native, filter mango accounts by name instead of pubkeys
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-26 10:45:50 +02:00
microwavedcola1 7fbf2b592a fix imports
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-26 10:10:33 +02:00
microwavedcola1 3e44dde696 Merge branch 'main' into dev 2022-08-26 10:09:52 +02:00
microwavedcola1 ab4c0e3de5 reset script
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-26 10:09:36 +02:00
microwavedcola1 b9a69bf59c extend debugging script to just take mango accounts directly
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-26 10:08:45 +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 3a1fc2b271
Merge pull request #191 from blockworks-foundation/ckamm/pre-health-perps
PlacePerpOrder: pre-health computation
2022-08-24 21:58:48 +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 4bad1b9b1a
Merge pull request #190 from blockworks-foundation/ckamm/pre-health
Compute pre-health, to allow some actions even if init_health<0
2022-08-24 15:07:56 +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
microwavedcola1 b65fb0f630 Merge branch 'main' into dev 2022-08-24 10:17:22 +02:00
microwavedcola1 aae3c32c78
mc/switchboard ts support (#182)
* switchboard oracle v2 parsing

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

* fix

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-24 10:16:43 +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
riordanp 0849354924
Add metrics output to crank (#186) 2022-08-24 09:53:46 +02:00
microwavedcola1 430e7469c4 fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 16:23:20 +02:00
microwavedcola1 4c4a9cbb73 Small changes for consistency
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 16:21:05 +02:00
microwavedcola1 9927e4800d Merge branch 'main' into dev 2022-08-23 13:48:52 +02:00
microwavedcola1 5947698af8 make functions consistent, always return positive values for deposits or borrows
provide ui alternative functions for many functions
provide a way to grab total vault balance for a token on a group
improve getMaxWithdrawWithBorrowForToken and getMaxSourceForTokenSwap and simHealthRatioWithTokenPositionUiChanges

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 13:47:08 +02:00
microwavedcola1 026a58d856 fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 13:39:32 +02:00
microwavedcola1 53b43bfdd1 fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 13:33:47 +02:00
microwavedcola1 6bde327a9e fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 11:57:32 +02:00
microwavedcola1 8a460352a0 fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 11:51:45 +02:00
microwavedcola1 363d7a306c fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 11:43:25 +02:00
microwavedcola1 7321df31be fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 09:42:00 +02:00
microwavedcola1 7f2fb0c04c fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-23 09:20:03 +02:00