Commit Graph

788 Commits

Author SHA1 Message Date
Christian Kamm dfde7ec43f
serum health: use lower-precision division (#750)
This saves around 1/3rd of the compute for active serum markets.
2023-10-11 15:19:24 +02:00
Christian Kamm 20eb02af01
program-test improvements: performance, cu test output, warnings (#749)
* tests: Upgrade tx log capturing

Instead of overriding the system logger to intercept the logs, we can
now ask solana to return the logs of a tx execution directly.

This speeds up tests a lot because we don't need to hold a global lock
on tx execution anymore!

* tests: Improve token, serum, perp cu test
* benchmark: add a few more operations
2023-10-11 15:18:23 +02:00
Christian Kamm 817bf9bbc6
Tcs: linear and premium auctions (#717) 2023-10-07 21:27:19 +02:00
Christian Kamm 81fd7951dd
FlashLoanSwapBegin: small tx-size FlashLoanBegin for swaps (#744) 2023-10-06 16:18:59 +02:00
Christian Kamm fd997e2e2c Cargo: Remove explicit workspace-inheritance feature use
solana-release cargo version was updated
2023-10-05 11:05:12 +02:00
Steve f625284593
Update to solana 1.16.14 and anchor 0.28.0 (#718)
- Change fixed to be a git dependency (no more submodules!)
- Upgrade fixed to a version compatible with borsh 0.10
- Upgrade openbook-v2 dependency (for anchor compat)
- Move services from mango-feeds repo into bin/
- Update mango-feeds-connector

Co-authored-by: Christian Kamm <mail@ckamm.de>
Co-authored-by: Riordan Panayides <riordan@panayid.es>
2023-10-05 10:56:45 +02:00
Christian Kamm 1afcff5dc2
Changelog and version bump for v0.20.0 (#739) 2023-10-04 09:18:57 +02:00
microwavedcola1 2df4df048c
program: be more relaxed with max rate (#734)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-10-03 21:13:50 +02:00
Christian Kamm ea7fae4687 Changelog, version bump for program v0.19.1 2023-10-02 19:54:09 +02:00
Christian Kamm 1d241de75a
FlashLoan: Allow jup v6 for delegates (#737) 2023-10-02 19:40:43 +02:00
microwavedcola1 39ed3a3fb5
program: if position is not negative then continue ahead with withdrawal, also deactivate if position is 0 (#736)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-10-02 09:11:44 +02:00
Christian Kamm ac38ccc687
Drop HealthCache from idl, disable ComputeAccountData ix (#723)
It's used for tests, we don't want people depending on it.
2023-09-19 10:01:44 +02:00
Christian Kamm 2c4009eab1
Token deposit: Require valid oracle for new token positions (#722)
This avoids making an account accidentally or intentionally unusable
(except for deposits/withdraws) by depositing a token with a stale
oracle.
2023-09-19 09:08:32 +02:00
Christian Kamm 2adc0339dc
Serum3 open orders: Fix health overestimation (#716)
When bids or asks crossed the oracle price, the serum3 health would be
overestimated before.

The health code has no access to the open order quantites or prices and
used to assume all orders are at oracle price.

Now we track an account's max bid and min ask in each market and use that
as a worst-case price. The tracking isn't perfect for technical reasons
(compute cost, no notifications on fill) but produces an upper bound on
bids (lower bound on asks) that is sufficient to make health not
overestimate.

The tracked price is reset every time the serum3 open orders on a book
side are completely cleared.
2023-09-13 09:35:10 +02:00
Christian Kamm ba6bd96784
Allow account shrinking and migration (#692)
- The AccountExpand instruction can now shrink accounts by reducing
  the number of token/perp/serum/tcs/perp oo slots.
- A new AccountSizeMigration instruction can permissionlessly shrink
  accounts that are too large and migrate them to the v3 layout.
2023-09-04 09:30:57 +02:00
Christian Kamm c07978fb68
max_swap: Fix swapping between zero weight tokens (#699)
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2023-08-31 14:01:18 +02:00
Christian Kamm 03378bb808
FlashLoan: Log the approved amount (#696)
Previously only the part of the approved amount that was a loan got
logged, missing some interesting information.
2023-08-30 10:57:41 +02:00
Christian Kamm 020a978270
Account expansion: Transfer more lamports only if needed (#694)
Result of audit feedback
2023-08-29 10:03:24 +02:00
Christian Kamm 1d6ce550f3
FlashLoan: fee fixes (#693)
- Rename the new "swap fee" to "deposit fee" and let it apply to all
  deposits, not just for Swap-type flash loans.
- But don't apply it to withdrawals (effectively giving rebates!)

Result of audit feedback
2023-08-29 10:03:07 +02:00
Christian Kamm 6e2363c86f
Improve CU benchmarks (#690) 2023-08-24 16:33:08 +02:00
Christian Kamm f63163d737
Account limits: Prefer 4 perp + 4 serum (#689) 2023-08-21 16:26:49 +02:00
Christian Kamm a151ebcf11
Account size: restict more, but only increases (#688)
* Account size: Don't fail on unrelated resize

If the account was previously resized to larger than is allowed now,
don't fail unrelated resizes.

* Further reduce account size limits

Out of caution and future-proofing. Can always raise again.

Perp settle pnl needs 6 accounts plus 2 health account lists that could
be nearly fully disjoint.
2023-08-21 14:34:52 +02:00
Christian Kamm 34a875d968
Restrict account growth (#686)
Because of the 64-accounts-per-tx limit. Making a single account use
more than half of these could be problematic.
2023-08-19 08:20:40 +02:00
Christian Kamm 6fd158ff6c
account_create_v2: fix bad account size (#685) 2023-08-19 08:17:03 +02:00
Christian Kamm 3480b62945
Changelog and version bump for program v0.19.0 (#683) 2023-08-18 15:38:28 +02:00
Christian Kamm 6e9878e31d
Tcs trigger: Avoid building a health cache for expired tcs (#682) 2023-08-18 15:37:59 +02:00
Christian Kamm cbc96fe79f
FlashLoan: Allow mango ix after flash loan end (#681)
This lifts an unnecessary restriction, making it possible to do things
like flash loan and then liquidate with the resulting balances in a
single transaction.

The "no mango ix after FlashLoanEnd" limitation was unnecessary:
After the flash loan ends, the mango accounts are in a valid state
again. And it's impossible to use a two FlashLoanEnd for a single
FlashLoanBegin for the same reason that isolated FlashLoanEnds are
rejected.
2023-08-18 15:37:15 +02:00
Christian Kamm a244c27df6
Add account_create_v2 instruction (#680)
This one allows specifying the number of tcs slots. That way accounts
can be created without needing a separate extend instruction afterwards.
2023-08-18 15:36:36 +02:00
Christian Kamm 0c26977ec9
Merge pull request #677 from blockworks-foundation/ckamm/tcs-net-borrow
Tcs and liquidator and net borrow limits
2023-08-18 15:35:16 +02:00
Adrian Brzeziński 27097faa2f
listing fixes (#678)
* remove listing tools

* adjust stalness slots in trustless instruction
2023-08-15 13:33:48 +02:00
Christian Kamm 727f9a2400 tcs: Change low-health-closure to absolute $1
Health ratio was too expensive to compute on-chain
2023-08-14 16:14:30 +02:00
Christian Kamm 7e804b228f tcs: net borrow checks 2023-08-14 16:14:30 +02:00
Christian Kamm 643a997723
Oracles: Fix units of deviation in OracleState (#675) 2023-08-11 16:47:52 +02:00
Christian Kamm 1f55d549a6
liquidator: execute tcs with volume-weighted randomness (#670) 2023-08-11 12:08:34 +02:00
Christian Kamm e4a9a56f89
Pass all params to token_register (#665)
Makes governance a little easier
2023-08-09 13:55:53 +02:00
Maximilian Schneider e4162a8281
Leverage & Balance Sheet helpers (#637) 2023-08-09 13:54:09 +02:00
Christian Kamm 6dcd5c925c
FlashLoan swaps: Allow charging a fee (#660)
To give more flexibility to the DAO.

The fee is deducted from any deposits that happen during the flash loan
and controlled per-bank with TokenEdit.
2023-08-09 13:27:25 +02:00
Christian Kamm faa0649c6a Fix program tests after temporary delegate addition 2023-08-09 13:18:28 +02:00
microwavedcola1 8d924a8b9b
Delegate with expiry (#663)
* delegate with expiry

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

* update idl

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>

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-08-09 12:05:16 +02:00
Christian Kamm 4810b6afbc
Tcs: store a display-only intention enum (#667)
This way the ui can know what the user created the tcs order for.

Introduces tcs create and trigger v2 logs.
2023-08-08 18:16:59 +02:00
Christian Kamm 785e6353c1 Fix compile after merges 2023-08-08 10:36:21 +02:00
Christian Kamm 774c67909e
Tcs: Use fees config from Bank instead of Group (#659)
To give more flexibility to the DAO, the maximum tcs fees from
the buy and sell banks will be used.
2023-08-08 10:21:13 +02:00
Christian Kamm 4f810edebc
Allow token withdraws/deposits even with stale oracles (#646) 2023-08-07 16:15:45 +02:00
Lou-Kamades 98cbf2df59
Merge pull request #652 from blockworks-foundation/lou/token-conditional-logs 2023-08-03 12:30:40 -05:00
Christian Kamm 44f0f4ffa3
Clippy fixes (#656) 2023-08-03 13:27:04 +02:00
Christian Kamm 1be38d14cb
Tcs: Add price display style enum (#654)
Tcs orders always store prices in a fixed "sell per buy" style, but users
can create them in either price direction. When they look at them later,
the ui needs to know what their preferred style is for this order.
2023-08-03 12:37:01 +02:00
Christian Kamm 06f6d75b98
Fix typo in admin_token_withdraw_fees ix (#655) 2023-08-03 12:34:33 +02:00
Lou-Kamades 55a3a28ad7
use indexed position in token conditional balance logs 2023-08-01 18:33:21 -07:00
Christian Kamm 5dd5c507f2
Tcs: reserve token positions while tcs is open (#647)
- Update in_use_count to u16
- Pass banks to TCS cancel instruction
- Increase the in_use_count when a tcs is created and decrease on
  trigger/cancel
2023-07-17 13:14:53 +02:00
Christian Kamm 1ba6513b5e
Compile and test fix (#645) 2023-07-14 16:27:52 +02:00