Commit Graph

112 Commits

Author SHA1 Message Date
Christian Kamm 450007d34b
Perp: Drop client order id from LeafNodes (#323)
This saves 8 bytes and only the FillEvents, FillLogs were populated from
the data.
2022-12-08 19:55:32 +01:00
microwavedcola1 5cc88b0d97
mainnet setup script for vanity address (#324)
* mainnet setup script for vanity address

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

* rename

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

* update

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

* update

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

* update

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-12-08 16:04:58 +01:00
Christian Kamm b66dc7ae80 IDL: Fix missing OrderTreeRoot 2022-12-08 11:22:37 +01:00
Christian Kamm 947d9b2b60
Split into perp bids and perp asks (#322)
Separate, smaller accounts that are easy to extend if needed.
2022-12-07 21:03:28 +01:00
Christian Kamm 777c1a7804
Rename bank fields, make weight scale limits editable (#319) 2022-12-06 09:34:02 +01:00
microwavedcola1 fa09c557a1
ts client sync with program (#311)
mostly health related code
2022-12-02 15:48:43 +01:00
Christian Kamm c8f1f3c821
Net borrow limits: Limit in quote, not native (#312)
* Net borrow limits: Limit in quote, not native
* make perp settle limit disableable
2022-12-02 12:24:11 +01:00
Christian Kamm 512eef96ea Perp pegged orders: Add stub max oracle staleness arg 2022-12-02 08:19:51 +01:00
microwavedcola1 d64d9285f4
limit settleable pnl (#295)
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-11-30 13:20:19 +01:00
microwavedcola1 1732a5aff4
net borrow limits (#301)
* net borrow limits

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

* fix client

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

* Fixes from review

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

* Fix tests

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-11-25 13:45:17 +01:00
microwavedcola1 d3661bac7b
mc/oracle peg ts client (#290)
* oracle peg client support

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>

* Fix from review

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-11-21 19:34:41 +01:00
microwavedcola1 d82608ebee Revert "add support for msrm vault for serum3 discounts (#285)"
This reverts commit 0a4f7150d6.
2022-11-20 15:31:16 +01:00
Christian Kamm 58f7ff2e0e Add staleness param to OracleConfig
Since Bank can't expand the existing OracleConfig, add a new one to Bank
and (temporarily!) copy over the old value to the new one in
TokenUpdateIndexAndRate.

Add some reserved space to OracleConfig to make this easier in the
future.

Breaks the PerpMarket and PerpPosition layouts
2022-11-12 12:11:09 +01:00
microwavedcola1 0a4f7150d6
add support for msrm vault for serum3 discounts (#285)
* add support for msrm vault for serum3 discounts

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

* Fix client

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

* client support

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

* More client code and todos

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

* prettoer

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

* remove mint, not needed

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-11-09 09:59:42 +01:00
microwavedcola1 e47e17d79f
reduce only flag for perp place order (#286)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-11-09 09:59:34 +01:00
microwavedcola1 e8ba511c45
mc/flash loan for delegate (#271)
* flash loan for delegates

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

* Fix rust client

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

* prettier

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-11-09 09:35:13 +01:00
Christian Kamm 5731ce8faa
Perp oracle peg feature (#264)
This introduces the ability to use oracle peg orders on perp markets.

This PR has significant non-backwards compatible changes, for example all
order trees are now in a single account instead of separate.
2022-11-08 15:27:56 +01:00
microwavedcola1 ccc1d43a55 Port new fields on accounts from program to ts client
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-11-02 12:13:29 +00:00
microwavedcola1 a66177a77e
ts: match client class definitions 1-1 to program state struct definitions (#268)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-10-11 09:34:02 +02: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
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
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
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
Conj0iner a8ae59f0fe IDL and client changes 2022-09-23 01:03:45 +08:00
Christian Kamm 96218fb7ba Update IDL and merge issue fixups 2022-09-21 10:19:23 +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 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 1b3a2b07db Update idl 2022-09-15 09:24:35 +02:00
Christian Kamm 3fbc3ca32d TokenEdit: remove bank_num arg 2022-09-02 13:55:00 +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 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
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 38b349a401 Rename PerpOpenOrders -> PerpOpenOrder, since it's a single one 2022-08-24 15:22:55 +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
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
microwavedcola1 9b2f4e7b18 upgradel idl
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-18 17:19:12 +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 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 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