Commit Graph

579 Commits

Author SHA1 Message Date
Christian Kamm 6399e6cb6c Fix PerpMarket data layout breakage
The new fees_settled must be added at the end and the reserved amount
needs to be reduced.
2022-09-20 16:58:07 +02:00
microwavedcola1 b7e79a4663
WIP: ts/perps (#220)
* ts: further fleshing out of perps code

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

* cleanup scripts

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

* Fixes from reviews

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-20 12:57:01 +02:00
Christian Kamm 11160ae2fe Health: Pass price to max_swap_source_for_health_ratio
Because it's not correct to think we'll always swap at oracle price.
That was an ok assumption for liquidations, where we'll swap at slightly
better than that, but not for jup.
2022-09-20 10:41:33 +02:00
Christian Kamm a6d25071cd Test: Fix test_alt compile 2022-09-15 19:06:46 +02:00
Christian Kamm 20eb61527b Compile fixups after merge 2022-09-15 09:40:14 +02:00
Christian Kamm 1b3a2b07db Update idl 2022-09-15 09:24:35 +02:00
Christian Kamm 14ca1dac35 Add alt_set / alt_extend instructions
alt_extend will only work in the future, when alt_set can receive lookup
tables where the authority is set to be the mango group pda.
2022-09-15 09:20:08 +02:00
Christian Kamm 50be520e99 Rename: LiqToken* -> TokenLiq* 2022-09-14 16:22:42 +02:00
Christian Kamm f3bdfec6a6
Perp settle pnl: Limit to maint spot health (#225)
Perp settle pnl: Limit to maint spot health

We want to isolate perp markets. As such, it's not acceptable to convert
arbitrary perp losses into spot token borrows.

The safe amount for this conversion is given by the account's
maint health -- with all perp markets ignored.
2022-09-14 13:26:29 +02:00
Christian Kamm 5572242e6d Tests: PerpLiqBaseToken tests 2022-09-10 07:45:27 +02:00
Christian Kamm 45025a1145 Perp tests: Helper for market creation 2022-09-10 07:45:27 +02:00
Christian Kamm bb962c6781 Perp tests: Don't pass derivable accounts explicitly
This makes it impossible to test passing bad accounts for these through
this interface, but I think that's an ok tradeoff.
2022-09-10 07:45:25 +02:00
Christian Kamm 2dfada7377 Tests: initial perp force-cancel test 2022-09-10 07:42:58 +02:00
Christian Kamm 810998a2af Add PerpLiqForceCancelOrders instruction 2022-09-10 07:42:58 +02:00
Christian Kamm 845a32a7c2 Add PerpLiqBasePosition instruction 2022-09-10 07:42:58 +02:00
Conj0iner a6ddf232cb Fixed tests 2022-09-09 18:50:11 +08:00
Conj0iner 3b3286a5b3 Changed max_settle_amount to u64 2022-09-09 18:29:02 +08:00
Christian Kamm 1f26a54399
Perps: introduce explicit position close (#216)
* Perps: fix position lifetime; explicit closing

When an order is placed and the position needs to be created, the
settlement token is marked as in use. The perp position and the in-use
flag are only released with the new perp_close_position instruction.

* Tests: Factor out common floating-point comparisons

* Rename PerpClosePosition -> PerpDeactivatePosition
2022-09-09 10:50:09 +02:00
Christian Kamm 6c32077d1a Perps: Let all base lot changes go through a function
Direct access to base_position_lots and quote_position_native is not
allowed anymore.

Fixes an issue where quote_lots were used instead of quote_native, and
also takes fees into account for the entry price.
2022-09-08 13:12:50 +02:00
Christian Kamm e56ed3776c Perp: Api cleanups
- Clarification of close_order vs close_all_orders
- Remove of get_ prefixes
- Remove find_min/find_max/find_min_max, duplicated with
  min_leaf/max_leaf
2022-09-08 13:11:45 +02:00
Christian Kamm 1d7d5e9a6d Test: simplify by adding a TestKeypair that's Clone+Copy
This means a lot less annoyance because of &'a Keypair or Arc<Keypair>
2022-09-07 14:23:52 +02:00
Christian Kamm 4795286dbd Perps: Account for unsettled funding in health 2022-09-07 11:37:20 +02:00
Christian Kamm c714fb213d Tests: Auto-advance the slot after sending a transaction
This fixes a recurring error where it would look as if a transaction you
send would not be processed at all.
2022-09-07 11:34:47 +02:00
Christian Kamm 3128115dca PerpMarket: Add helper for getting oracle price 2022-09-06 14:26:06 +02:00
Christian Kamm 79a7bdc299 Checked math: support cm!(a += b) 2022-09-06 08:55:27 +02:00
Christian Kamm 3c51449040 Tests: Remove unused imports 2022-09-05 18:40:42 +02:00
Conj0iner c34ee54233 Added perp_settle_fees instruction 2022-09-05 22:18:40 +08:00
Christian Kamm 3fbc3ca32d TokenEdit: remove bank_num arg 2022-09-02 13:55:00 +02:00
Conj0iner 97eed4081d Added perp_settle_pnl instruction 2022-09-02 00:07:57 +08:00
Christian Kamm 511db72f8e Health token adjustment: Deal with odd I80F48 behavior
The identity
  a * b = -((-a) * b)
does not hold for I80F48, probably it's rounding to -inf.

This meant that withdrawing the full native token balance could
fail because the magnitude of -position * price was bigger than
position * price.
2022-09-01 14:38:48 +02:00
Christian Kamm 868c55fef1 Serum index reservation: use a real account
Makes it easier and more future-proof
2022-09-01 12:28:37 +02:00
Christian Kamm c31f11013f Serum deregister: Close index reservation account
Only safe because this is a testing-only instruction
2022-09-01 12:15:00 +02:00
Christian Kamm 1f0cd62846 Don't panic if accounts are shorter than 8 bytes 2022-09-01 12:00:09 +02:00
Christian Kamm 5e0001afb8 Serum: Index reservation account has 8 bytes
otherwise all code needs to be able to deal with mango accounts that are
smaller than 8 bytes in size.
2022-09-01 11:49:33 +02:00
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