Christian Kamm
4e45653c95
Audit fixes ( #613 )
...
* TokenForceCloseBorrows: Respect reduce-only flag
* ForceCancelOrders: Readability of early-out condition
(cherry picked from commit b5c9f6d039
)
2023-06-16 13:35:24 +02:00
Christian Kamm
57e1d981ac
Health: Allow actions while init health does not decrease ( #592 )
...
Instead of requiring a strict increase when init health < 0.
This allows users to still place reducing limit orders on the spot and
perp orderbooks as long as these orders keep the health unchanged.
2023-06-15 10:44:11 +02:00
Christian Kamm
bbf0186398
Pyth oracles: Check that status is "trading" ( #607 )
2023-06-15 10:43:44 +02:00
Christian Kamm
66c6926419
Audit fixes for the fee buyback feature ( #608 )
...
* reduce_buyback_fees_accrued: forbid reducing more than accrued
* Buyback fees: Expire accrued during event processing
2023-06-15 10:43:31 +02:00
Nicholas Clarke
23761ef28c
Add price to WithdrawLoanLog ( #603 )
2023-06-14 09:41:54 +02:00
Nicholas Clarke
defbd8c2b1
Add loan amount to WithdrawLoanLog. Add withdraw loan logging to toke… ( #599 )
...
* Add loan amount to WithdrawLoanLog. Add withdraw loan logging to token_force_close_borrows_with_token
* Address review comments.
2023-06-11 15:37:33 -07:00
Britt Cyr
7803f1dc9d
Fix warning when running tests
2023-06-01 08:16:11 +02:00
Christian Kamm
1cc77af7fa
Bump version to 0.17.0, changelog updates, idl update
2023-05-31 09:11:56 +02:00
Christian Kamm
56b010eb71
HealthRegion: Whitelist new perp_place_order_(pegged_)v2 ix ( #597 )
2023-05-26 16:48:19 +02:00
Britt Cyr
2ea8f73ad1
Fix typo in token_liq_with_token comment ( #594 )
2023-05-25 12:35:22 +02:00
Christian Kamm
9f9f3d257c
Docs: improve HealthCache comments ( #590 )
2023-05-19 14:42:14 +02:00
Maximilian Schneider
0b22e41acd
manage dependencies in workspace ( #588 )
...
* move important dependencies to workspace
* enable workspace inheritance
2023-05-17 20:48:14 +02:00
Christian Kamm
5fc7aa1092
Configurable perp settle token ( #550 )
...
This changes perp market margining to no longer assume all pnl is in USD
while settlement is in USDC. Instead, a configurable settle token is used for
pnl and settlement, defaulting to USDC.
There is no difference while the USDC price is forced to $1 and the init and liab
weights are 1. But with this patch, it becomes possible to change that.
For now it is not recommended to use a token other than USDC or USDT (or
another USD targeting stable token) for perp settlement.
The patch also updates all insurance vault use to be aware that the insurance
fund is not in USD but in USDC and apply the USDC price before payouts.
To do this, the previous PerpLiqNegativePnlOrBankruptcy was replaced by
a new PerpLiqNegativePnlOrBankruptcyV2 instruction.
Co-authored-by: microwavedcola1 <89031858+microwavedcola1@users.noreply.github.com>
2023-05-17 15:50:05 +02:00
Christian Kamm
be5618aa2b
PerpTakerTradeLog: Add decremented base lots ( #584 )
2023-05-16 11:10:26 +02:00
Maximilian Schneider
c006948319
Enable self-trading protection ( #533 )
...
Co-authored-by: Christian Kamm <mail@ckamm.de>
2023-05-15 10:40:41 +02:00
Maximilian Schneider
9166b761e9
log taker trade summary ( #579 )
...
* add new event for taker trade so arb bots can verify their execution cost without waiting for consume events
Co-authored-by: Nicholas <nicholasgclarke@gmail.com>
2023-05-13 17:54:27 +02:00
microwavedcola1
784ef88927
document unused ( #581 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-05-13 10:03:28 +02:00
Christian Kamm
5a05e9cb2e
Update anchor to v0.27.0, stop using submodule ( #582 )
2023-05-12 13:54:53 +02:00
Christian Kamm
9429d3991d
Bump program version to v0.16.0 and add deploy info
2023-05-11 13:46:43 +02:00
Christian Kamm
450f446032
Make clippy happy ( #580 )
2023-05-09 21:08:55 +02:00
Christian Kamm
2205fe7260
Changelog for program v0.15.0, version bump, idl update ( #577 )
2023-05-08 08:13:50 +02:00
Christian Kamm
d20ae0abcb
Perp: Exit matching loop when no more base lots can be filled ( #576 )
2023-05-08 06:40:38 +02:00
Nicholas Clarke
c0ea9970b6
Clarkeni/oracle confidence ( #568 )
...
* Add oracle confidence and oracle type to update funding logs.
* Return price and OracleState struct from oracle_price_and_state.
2023-05-05 23:44:14 -07:00
Christian Kamm
2f4976e81f
Improve error message for FixedAccountRetriever ( #566 )
...
When an invalid number of accounts is passed in, which is one of the
most common error messages new integrators will see.
2023-05-05 09:11:25 +02:00
microwavedcola1
abba3de4ce
Fix bug in flash loan for delegates where compute budget program was not allowed, also improved logging ( #572 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-05-04 14:46:09 +02:00
Christian Kamm
0da1b6728b
OpenBook place order: respect bank reduce_only flags ( #569 )
2023-05-04 08:02:28 +02:00
Christian Kamm
6f47ad92d6
token_register_trustless: Disable borrowing by default ( #567 )
...
Previously tokens listed this way could be borrowed. Now tokens start
with reduce-only set to the "no borrows" mode.
Also decrease the default soft borrow/deposit limits significantly, even
if they don't come into effect when there are no borrows and the deposit
weight is 0 anyway.
2023-05-04 07:59:39 +02:00
Christian Kamm
4504ed8ff9
Compile fix and idl update
2023-04-26 09:07:05 +02:00
microwavedcola1
4e4af83d98
Fix bugs for release ( #564 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-04-25 16:18:35 +02:00
Christian Kamm
7ec8fbffe5
Fix build without enable-gpl
2023-04-25 13:39:01 +02:00
Nicholas Clarke
2dce1398d3
Fix to seq num logging. Seq num was incremented between event and logging ( #556 )
2023-04-25 13:38:31 +02:00
Nicholas Clarke
5d77ba6834
Add PerpForceClosePositionLog and TokenForceCloseBorrowsWithTokenLog ( #555 )
2023-04-25 13:38:08 +02:00
Christian Kamm
507cb500e9
Fix settle limit accounting for positive pnl takeover ( #562 )
2023-04-25 13:37:34 +02:00
microwavedcola1
3741f78da5
insurance fund withdraw ix ( #561 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-04-25 09:20:44 +02:00
Christian Kamm
fe8d1a63bd
Fix building with "no-entrypoint" feature ( #558 )
...
Without this, anchor complains about a missing lifetime on a struct
relating to Benchmark.
2023-04-24 09:52:44 +02:00
Christian Kamm
898788909e
Fix account borrow issue in perp_liq_force_cancel_orders ( #557 )
2023-04-24 09:52:33 +02:00
Christian Kamm
10113443df
Minor test compile fix
2023-04-24 09:35:46 +02:00
microwavedcola1
497012042c
Force close for serum3 market ( #551 )
...
* force close for serum3 market
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* always require admin
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>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* format
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* update client
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
---------
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-04-20 10:19:23 +02:00
microwavedcola1
6fba1692e9
Fix type
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-04-20 10:13:14 +02:00
microwavedcola1
6ac9f19287
Perp force close positions in a market ( #525 )
...
* force close tokens
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>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* add test
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>
* 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>
* reset
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* force close perp market
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>
* rename
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* test
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* update
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* add back staleness slot check
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
---------
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-04-19 17:42:01 +02:00
microwavedcola1
55bfcc3a76
fix bug where flash loans couldnt be executed by delegates ( #552 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-04-19 16:17:26 +02:00
microwavedcola1
fa5b39adad
bump version for next release
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-04-14 16:59:02 +02:00
Christian Kamm
0e831db687
IxGate: Fix check for re-enabling instructions ( #540 )
...
The bug allowed the security admin to enable instructions. This was
supposed to require the group admin.
2023-04-14 16:12:17 +02:00
Christian Kamm
98a79505e1
FlashLoan: Don't deduce vault_len, add more checks ( #542 )
...
It looks like it wasn't possible to exploit the program by
re-initializing the user-owned token accounts used in flash loan because
the later use of health_ais with the health computation would error out
if any token account was included there.
However, the check and a few others were too indirect. In this patch:
- We pass the number of loans into FlashLoanEnd explicitly (verified
from FlashLoanBegin)
- Add explicit checks for token mints, so it's no longer possible to use
token accounts for foreign mints in Begin when the loan amount is zero,
and it's clearer to see that the bookkeeping in End won't break if the
user reinited the account for a different mint.
- Also add a few other extra comments and checks.
The updated FlashLoanEnd instruction is called FlashLoanEndV2
2023-04-14 15:18:02 +02:00
Christian Kamm
13279536aa
Drop leftover conflict markers
2023-04-14 08:26:05 +02:00
Nicholas Clarke
37ae7549fb
Clarkeni/perp trade logging ( #535 )
...
* Emit the slot corresponding to the oracle price to PerpUpdateFundingLog.
* Emit a new FilledPerpOrderLog consisting of just the group, perp market and seq num. This will be used to correlate perp fills to the transactions they were matched (not consumed).
2023-04-13 10:50:39 -07:00
microwavedcola1
c813940054
Fix method calls
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-04-13 19:34:45 +02:00
microwavedcola1
b07857c696
force close tokens program part ( #518 )
...
* force close tokens
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>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Fixes from review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* add test
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>
* 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>
* reset
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
---------
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-04-13 12:44:12 +02:00
microwavedcola1
2dca3003df
Don't incentivise using asset tokens with high liquidation fee during liquidation ( #536 )
...
* Don't incentivise using non-usdc coins to liquidate tokens
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix tests
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix tests
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* review: add back test comment
---------
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2023-04-13 12:43:31 +02:00
Christian Kamm
61a4f62ea4
Bump program version to v0.13.0 and update idl
2023-04-13 09:53:15 +02:00