Commit Graph

701 Commits

Author SHA1 Message Date
Nicholas Clarke 96344d7de1
Clarkeni/perp logging (#265)
* Perp instruction logging
* Onchain funding calculation
* perp_spot_transfers field on perp positions
* Logging on register token, perp market
* Additional fields on update token index logging
* maker and taker volume fields on perp position
2022-10-07 12:12:55 -07:00
Christian Kamm f2cc869795 Perps: Prepare for settlement token != oracle token
Make sure the setting is available and that the needed accounts are
passed to the perp instructions.
2022-10-06 08:32:58 +02:00
microwavedcola1 5b549fb59f
program: fix bug where expansion would not move positions whose size remained same (#262)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-10-03 13:06:04 +02:00
Christian Kamm b906e3dc78 Token deposit: Split into signed and permissionless ix
Token accounts are a limited resource, so allowing other users to make
use of them can cause problems.
2022-10-02 16:06:39 +02:00
microwavedcola1 d1079bb1b9
Mc/ts increase error tolerance for binary search (#258)
* ts: a higher error tolerance is sufficient

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

* Fixes from review

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

* program: fix error size

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-30 14:59:12 +02:00
Christian Kamm 7e180c7b3a Perps: Support trusted markets 2022-09-29 15:40:31 +02:00
Christian Kamm 8ba52f46c2
Perp settle pnl: incentive for settler (#252)
This adds three new options to perp markets:
- a flat fee, that is paid for all perp settlements
- given that they exceed the configured min settle amount threshold to
  be eligible for fees
- and a fractional fee, that only applies when the benefiting account
  has low health and gradually becomes bigger as the account slides
  towards liquidation
2022-09-29 12:59:55 +02:00
Nicholas Clarke 01a958cd22
Clarkeni/onchain interest (#244)
* Onchain interest calculation
* Fix to TokenBalanceLog for token_liq_bankruptcy (was previously using liqee liab position for liqor liab position).
* Log cumulative interest when token position is deactivated.
2022-09-28 23:04:33 -07:00
Christian Kamm 984695e8d0 liquidator: Call liq_perp_bankruptcy 2022-09-29 07:36:00 +02:00
Christian Kamm 12864e15a6
Merge pull request #245 from blockworks-foundation/ckamm/perp-settle
Liquidator: Settle pnl on perp accounts
2022-09-29 07:35:37 +02:00
Christian Kamm 77abfd0529 Perp liq: Fix base position liquidation amount computation
It was wrong for quote weights != 1.
2022-09-29 07:34:52 +02:00
Christian Kamm 11daf4d0eb client: fetch top settle pnl counterparties 2022-09-28 10:48:41 +02:00
conj0iner a97b40a521
Merge pull request #234 from blockworks-foundation/cj/ioc_fees
Extra fees for IOC orders
2022-09-28 00:05:25 +08:00
Nicholas Clarke 1320451e1a
Add serum open orders balance logging. Remove price from token and perp balances. (#236) 2022-09-23 10:42:43 -07:00
Christian Kamm f6c9a93ac5 Health: Avoid overflow panic in health ratio for tiny liabs
Spotted by microwavedcola
2022-09-23 12:04:14 +02:00
microwavedcola1 bb6790e678
ts: use price factor in maxSourceForSwap + max perp bid and ask + tests (#237)
* ts: use price factor in maxSourceForSwap
ts: max perp bid and ask
ts: mocha test for max swap

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

* ts: comemnt

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-23 11:43:26 +02:00
Conj0iner 55f77ad6c6 Added IOC penalty 2022-09-23 00:55:12 +08:00
microwavedcola1 ae42356b22
program: remove todos for ix which have now been implemented or not relevant (#240)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-22 17:43:01 +02:00
Christian Kamm 0040a1477e
Client: Compute max perp trade amount (#231) 2022-09-21 11:45:05 +02:00
Christian Kamm a41a245e24 PerpLiqBankruptcy instruction 2022-09-21 09:46:54 +02:00
conj0iner 1c67b8ed5f
remove base_token_index from perps and include oracles (#224)
Co-authored-by: Conj0iner <conj0iner@users.noreply.github.com>
2022-09-21 09:42:45 +02:00
Christian Kamm ddb68b7991 Test build fix 2022-09-20 16:59:55 +02:00
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
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