Commit Graph

834 Commits

Author SHA1 Message Date
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
microwavedcola1 b977556426 fix debug scripts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-14 13:30:08 +02:00
microwavedcola1 017581e863 fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-13 20:51:09 +02:00
microwavedcola1 d59d05eae5 default group is group num 2 on mainnet
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-13 20:10:49 +02:00
microwavedcola1 5221bbd53b Merge branch 'dev'
--wip-- [skip ci]
2022-08-13 19:55:37 +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
microwavedcola1 41e42da620 debug banks helper script
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-13 19:36:09 +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
tjs d68951e77d add custom sendTransaction to support post send callbacks 2022-08-12 17:15:12 -07:00
Riordan Panayides 8335c5495e Fix liquidator command 2022-08-12 15:31:53 +01:00
Riordan Panayides fa82980508 Upgrade docker runtime distro 2022-08-12 14:17:18 +01:00
Riordan Panayides bd5f874609 Add glibc to runtime image 2022-08-12 13:36:50 +01: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
microwavedcola1 a484aed42b
simulate on non existent token positions (#162)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-12 11:05:39 +02:00
microwavedcola1 164303e005 uncomment
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-12 10:21:06 +02:00
microwavedcola1 00c533d9d7 Merge branch 'dev' 2022-08-12 08:31:20 +02:00
microwavedcola1 4f25742b26 simHealthWithTokenPositionChanges -> simHealthRatioWithTokenPositionChanges
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-12 08:30:13 +02:00
tjs ac0155b79d fix for simHealthWithTokenPositionChanges
needs to keep track of health changes in the loop
2022-08-11 16:43:46 -07: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
tjs 4507a6a72a health ratio ui function 2022-08-11 12:06:01 -07:00
conj0iner 52660f1476
Merge pull request #158 from blockworks-foundation/cj/optimisedentryprice
Optimised entry position calculation
2022-08-12 01:36:25 +08:00
microwavedcola1 5402012064 apply loan origination fee buffer
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-11 17:59:49 +02:00
microwavedcola1 185b077285 remove stray log
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-11 17:48:43 +02:00
microwavedcola1 eee10a22bb
mc/max swap (#159)
* rework getMaxSourceForTokenSwap

* Fix assets and liabs method

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-11 17:44:12 +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 7dc3fc2ad9 Merge remote-tracking branch 'origin/main' into dev 2022-08-10 17:18:42 +02:00
microwavedcola1 cfdd59379e improve logging
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-10 17:17:16 +02:00
Christian Kamm fbdc5ee6b4
Merge pull request #147 from blockworks-foundation/ckamm/liq-and-rebalance
Liquidate and buy/sell to keep only quote
2022-08-10 17:09:16 +02:00
Christian Kamm 2f3c5e281c ts: prettier 2022-08-10 16:25:06 +02:00
Christian Kamm b52aad82e1 Liquidator: more pyth -> oracles renames 2022-08-10 16:24:48 +02:00
Christian Kamm 405c41edcf Liquidator: Fix rebalance to empty token accounts
By withdrawing to the liqor wallet if necessary.
2022-08-10 16:24:48 +02:00
Christian Kamm f169bcdafe Client: add token_withdraw 2022-08-10 16:24:48 +02:00
Christian Kamm 7fcee1af96 Liquidator: reload account between rebalance steps 2022-08-10 16:24:48 +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 3139b0816a Client: Jupiter swaps preserve ata/token instructions 2022-08-10 16:24:48 +02:00
Christian Kamm 38f5502dc7 Liquidator: round up when paying back borrows to close token pos 2022-08-10 16:24:48 +02:00
Christian Kamm 19153b8874 Client: Fix jupiter api field that is sometimes null 2022-08-10 16:24:48 +02:00
Christian Kamm 6d8290bebd ts: script to decode anchor events 2022-08-10 16:22:58 +02:00
Christian Kamm ad3cee5568 ts: improve liqtest scripts 2022-08-10 16:22:58 +02:00
Christian Kamm 222358ff14 ts: script to make liquidation candidates 2022-08-10 16:22:58 +02:00