Commit Graph

119 Commits

Author SHA1 Message Date
tjs 56313b6eac Merge branch 'dev' into main 2022-10-04 14:54:42 -04:00
microwavedcola1 4b52d9a072
ts: simplify getOrCreateMangoAccount (#256)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-30 12:16:24 +02:00
microwavedcola1 c22302a1da
ts client improvement (#254)
* Perps: Support trusted markets

* ts: health on client side

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

* ts: change perp lookup

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

* ts: reword error messages, refactor common uses of lookups

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

* ts: reformat

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

* ts: improve typing

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

* ts: fix some todos

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

* ts: fix some todos

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

* ts: fixes from review

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

* ts: type aliasing

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

* ts: remove '| undefined' where not required as return type

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

* ts: use trusted market flag for perp health

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-09-29 15:51:09 +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
Christian Kamm 12864e15a6
Merge pull request #245 from blockworks-foundation/ckamm/perp-settle
Liquidator: Settle pnl on perp accounts
2022-09-29 07:35:37 +02:00
microwavedcola1 dd83aeb156 ts: ALTs integration
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-28 17:09:59 +02:00
Christian Kamm 15d0a98c94 liquidator: settle pnl on liquidatable accounts 2022-09-28 10:48:41 +02:00
Christian Kamm 9cbc352197 liquidator: force-cancel perp orders, liq perp base positions 2022-09-28 10:47:05 +02:00
tjs 1380481781 script to view unowned mango account 2022-09-27 11:40:22 -04:00
tjs 3b1ea91903 consistent naming to get serum markets 2022-09-25 21:11:38 -04:00
microwavedcola1 bb6790e678
ts: use price factor in maxSourceForSwap + max perp bid and ask + tests (#237)
* ts: use price factor in maxSourceForSwap
ts: max perp bid and ask
ts: mocha test for max swap

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

* ts: comemnt

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-23 11:43:26 +02:00
microwavedcola1 f96b9ded0d ts: fix event queue rawevents
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-20 19:50:21 +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 ef5552c1c0 Liqtest: Build serum test case 2022-09-02 12:24:18 +02:00
Christian Kamm d566db7db0 Liqtest: Settle-and-close settles and closes open serum orders 2022-09-02 12:24:04 +02:00
Christian Kamm 3b3258769f ts: TokenEdit takes optional arguments 2022-09-02 12:24:04 +02:00
Christian Kamm 22dc07df1d Liquidation test: Fix scripts 2022-09-02 10:22:35 +02:00
microwavedcola1 0222ca8954
ts fixes (#207)
* ts: use gpa path if rest services has not caught up yet

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

* ts: convert wrapped sol to sol when withdrawing

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 11:25:58 +02:00
microwavedcola1 149e0eb0c7 Fix client and remove excessive logging in scripts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 10:48:50 +02:00
microwavedcola1 2479107d9a
Prepare serum3 release (#206) 2022-09-01 10:18:47 +02:00
microwavedcola1 a889e6c206 Fix scripts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-09-01 09:56:17 +02:00
microwavedcola1 c66dd882b6
ts: Additional serum3 support (#196)
* get bids and asks for a user on a serum3 market
* get orderbook for a market
* get max bid or ask that a user can place for a market
* simulate health if a bid or ask were to be placed

misc:
* fix remaining accounts list for health when placing perp bids

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

format

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

format

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

remove testing code

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>

script adjustment

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

comments

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-31 11:36:44 +02:00
microwavedcola1 aae3c32c78
mc/switchboard ts support (#182)
* switchboard oracle v2 parsing

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

* fix

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-24 10:16:43 +02:00
tjs 82ec90f9a0 update close all script 2022-08-18 17:54:41 -04:00
Nicholas Clarke 808f0abde9
Clarkeni/ids from api (#177)
* Fetch ids from api. Use mint public key in client args instead of token name.

Fix tests

Add getFirstBankByMint and getFirstBankByTokenIndex

* prettier

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

* yarn fix

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

* fix usage of service

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

* cleanup

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

* clean up testing scripts

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

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-18 08:48:45 +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 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 82864e5f6f Liquidator: disable allow-borrow, now that fixed program is deployed 2022-08-16 12:13:54 +02:00
microwavedcola1 24524d7cd5 update scripts
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-15 15:53:51 +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
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
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
Christian Kamm 2f3c5e281c ts: prettier 2022-08-10 16:25:06 +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 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
Christian Kamm 79e3b2db98 ts: disable loan fees in liq tests 2022-08-10 16:22:58 +02:00
Christian Kamm 68c52dbdc8 ts: Settle and close in script, including borrows 2022-08-10 16:22:58 +02:00
Christian Kamm 3257017770 ts: client and script fixes 2022-08-10 16:22:56 +02:00
Christian Kamm 55e891417e ts: also close accounts after withdraws 2022-08-10 16:20:25 +02:00
Christian Kamm 45327e7dd1 ts: script to withdraw everything, to lose fewer funds on close 2022-08-10 16:20:25 +02:00
Christian Kamm b2056c82e0 ts: script to add funds to liqtest group 2022-08-10 16:20:25 +02:00
Christian Kamm aff011c774 ts: script to create liqtest group with stub oracles 2022-08-10 16:20:25 +02:00
Christian Kamm 29c7d5b45a ts: mb-admin-close script closes all groups for the key 2022-08-10 16:20:23 +02:00
microwavedcola1 68de248c5b fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-10 09:31:58 +02:00
microwavedcola1 476241e8b8 fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-10 09:29:08 +02:00
microwavedcola1 2728aaeb2d revamp script
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-08-10 09:26:16 +02:00