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
Christian Kamm
74f7282d4e
Bump program version to v0.12.0 and update idl
2023-04-13 09:46:58 +02:00
Christian Kamm
da2a7f4e0c
Net borrow limit: Separate out tracking and checking ( #534 )
...
That way it's easier to be specific about where the limit should be
checked.
2023-04-13 08:56:33 +02:00
Nicholas Clarke
0ba41e3471
Emit perp fees settled on update_funding. Required to have a full picture of total perp market fees. ( #530 )
2023-04-06 22:09:50 -07:00
Christian Kamm
535b0b2d0c
Changelog for program-v0.11.0, bump version, update idl
2023-03-31 18:47:34 +02:00
Christian Kamm
762608ecce
Limit funding and interest accrual during downtimes ( #529 )
...
Previously, if the funding or interest updating instruction wasn't
called for a long time (like for a solana downtime or the security
council halting the program), the next update would apply funding or
interest for the whole time interval since the last update.
This could lead to a bad downtime situation becoming worse. Instead,
limit the maximum funding and interest time interval to one hour.
2023-03-31 12:48:34 +02:00
microwavedcola1
7080c9bf3c
sync rate params to latest proposal ( #523 )
...
* sync rate params to latest proposal
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>
---------
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-03-31 12:45:26 +02:00
microwavedcola1
cd39a9f432
Fix test
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-03-31 12:45:05 +02:00
Christian Kamm
8559d3ef07
Perp funding: Fix logging in update funding + deactivate pos ( #528 )
2023-03-31 10:58:04 +02:00
Christian Kamm
312a60fe4f
Net borrow limits: Use correct price for check ( #527 )
2023-03-30 17:25:29 +02:00
microwavedcola1
2957796de8
in perp settle fees, dont error, rather return early, this enables blindly concatenating perp settle fees to perp settle pnl ( #526 )
...
* in perp settle fees, dont error, rather return early
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-03-30 17:00:41 +02:00
microwavedcola1
258d95d035
Fix bug: only account for borrows we are offsetting ( #513 )
...
* Fix bug: only account for borrows we are offsetting
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* Bank: Unittest for net borrow limits
---------
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2023-03-22 09:58:31 +01:00
Christian Kamm
7c02075c80
Bump program version to v0.10.0
2023-03-21 12:51:21 +01:00
Christian Kamm
b22a1e7f57
HealthRegion: Whitelist allowed instruction types ( #508 )
...
This fixes a security issue where bankruptcy related instructions could
be called inside a health region. Now health regions are limited to
compute optimization like when placing multiple orders in one
transaction.
This limitation also makes it impossible to abuse health regions for
flash loans. Use the FlashLoan instructions for that purpose.
2023-03-20 14:02:35 +01:00
Christian Kamm
658a220095
Allow token/market names to fill storage bytes completely
...
Previously the last byte was always zero.
2023-03-20 14:02:03 +01:00
Christian Kamm
99360e69a3
TokenRegister: Sanity checks on token_index
2023-03-20 14:02:03 +01:00
Christian Kamm
d1e3da2b75
IxGateSet: Log AccountBuybackFeesWithMngo state
2023-03-20 14:02:03 +01:00
Christian Kamm
b7dd8e0663
Fee buyback: Respect USDC oracle ( #504 )
2023-03-20 11:18:11 +01:00
Christian Kamm
b6bfb01879
token_liq_bankruptcy: Use oracle for valuing insurance fund tokens ( #503 )
...
Previously a token from the insurance fund was valued at 1 USD. Now it
uses the oracle associated with it (USDC oracle).
2023-03-16 11:23:45 +01:00
Christian Kamm
0349ace3b6
Downgrade the `fixed` crate to v1.11.0 ( #500 )
2023-03-12 08:50:42 +01:00
Christian Kamm
c7dd6cd9e3
Bump program version to v0.9.0
2023-03-12 08:19:05 +01:00
Christian Kamm
6ee3cb1e19
Perp: More comments on fields and funding computation ( #497 )
2023-03-07 20:53:07 +01:00
microwavedcola1
5cd9279a21
add todo
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-03-07 10:05:02 +01:00
Nicholas Clarke
97895dfb1e
buyback fees with mngo logging ( #489 )
...
* buyback fees with mngo logging
* add logging of usdc balances for account_buyback_fees_with_mngo
2023-03-06 14:42:10 +01:00
Christian Kamm
252210d194
Serum settle funds V2: fees can go to users ( #484 )
...
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2023-03-03 14:04:45 +01:00
microwavedcola1
1950d8c84a
support name edit for token and program ( #488 )
...
* support name edit for token and program
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
* undo
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-03-03 10:05:12 +01:00
Christian Kamm
f29fffd331
Perp: User-selected reduce-only behaves more intuitively ( #483 )
...
The previous strict behavior of taking existing open orders into account
is only used when the perp market itself is also flagged as reduce-only.
2023-03-03 09:53:27 +01:00
Christian Kamm
255c6fb138
Fee buyback: Limit MNGO price by stable price ( #485 )
...
This makes it much harder to temporarily manipulate the MNGO price to
get a more favorable buyback deal.
2023-03-01 09:58:47 +01:00
Christian Kamm
46c79af430
Security admin: Allow disabling token/perp init collateral ( #482 )
...
This allows the security council to say "users can't create new borrows
against this token/perp anymore". In some emergency situations this can
help reduce risk exposure.
For example, if the price of a wrapped asset permanently depegs from
its underlying or there is a successful long-term attack on an oracle,
this (and reduce-only) would significantly reduce exploitability until
the DAO's decision for how to resolve the issue goes through.
2023-02-28 11:49:07 +01:00
Christian Kamm
df4a7b0474
Fees buyback: Credit users for ui part of serum fees ( #481 )
...
At least for markets with USDC quote currency.
2023-02-28 09:48:15 +01:00
Christian Kamm
9a13c1366a
Fee buyback: Credit only perp fees that go to the dao ( #479 )
2023-02-27 19:51:09 +01:00
microwavedcola1
16599dd506
admins can also register trustless tokens ( #477 )
...
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-02-27 16:37:57 +01:00
Christian Kamm
e4d46c3c5b
Buyback fees: Add staggered expiry ( #478 )
2023-02-27 16:36:27 +01:00
microwavedcola1
d88d44b34a
buyback perp fees with mngo at a discount ( #464 )
...
buyback perp fees with mngo
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-02-25 20:34:16 +01:00
Christian Kamm
5c7a2e3e10
Use the overflow-checks=true equivalent with the fixed crate ( #476 )
...
* Vendor `fixed` crate to have checked math in release mode
* remove all cm!()
* drop superfluous parens
* drop use of checked_math crate
* manual removal of redundant checked_* functions
2023-02-24 11:56:33 +01:00
Christian Kamm
cfcda705e6
Bump program version to v0.8.0
2023-02-22 14:49:18 +01:00
Christian Kamm
f75e3ee656
Serum: Track referrer rebates as Mango platform fees ( #469 )
...
And start sharing code between serum3 settle and force cancel
2023-02-22 12:04:21 +01:00
microwavedcola1
ae2f74a928
security admin can move openbook market to reduce only ( #472 )
...
* security admin can move openbook market to reduce only
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-02-22 09:24:38 +01:00
Christian Kamm
5c7f23adb1
Perp place order: more logging for reduce only ( #468 )
2023-02-21 13:14:40 +01:00
Christian Kamm
8f9700ed2d
Settle pnl: Always grant the fractional fee on low health
2023-02-15 15:11:58 +01:00