Commit Graph

608 Commits

Author SHA1 Message Date
Christian Kamm b25f6d5f4f Insurance fund 2022-07-06 09:07:50 +02:00
Christian Kamm 35ca4d31b3 liq_token_bankruptcy instruction for socialized loss 2022-07-06 09:07:49 +02:00
tjs 1b04f924e3 make jup-ag/core a devdependency 2022-07-05 23:38:53 -04:00
tjs 1451ebc2a1 Merge branch 'ts/deps' into dev 2022-07-05 21:36:45 -04:00
Nicholas Clarke 30fc7def77
Add oracle price to update_index logging. (#89)
* Add oracle price to update_index logging.

* Update IDL with changes to update_index instruction and logging.
2022-07-05 11:59:44 -07:00
microwavedcola1 d74cc78a84
edit tokens, perp markets, mango accounts, allow delegate to perform certain operations (#94)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-05 19:31:47 +02:00
tjs f3b0c883d6 export banks 2022-07-04 19:23:00 -04:00
microwavedcola1 dc4aee885b add doc
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-04 15:52:32 +02:00
microwavedcola1 301b00a452 add exampole
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-04 15:34:16 +02:00
microwavedcola1 dff3f7cd8c client functions via program simulation
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-04 14:11:38 +02:00
microwavedcola1 39284c5705
Flash loan 3 minimal example (#90)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-04 12:09:33 +02:00
tjs d7f84f6a8e use price or previousPrice 2022-07-03 21:47:02 -04:00
tjs 9789ec00d6 export utils 2022-07-03 20:30:38 -04:00
microwavedcola1 6a99eb893b Fix types
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-01 14:31:47 +02:00
Christian Kamm 30a221047c Bank: rename indexed total deposits and schedule for removal 2022-07-01 14:08:28 +02:00
microwavedcola1 e8cb27610e
close mango account without checks when testing flag is set on the group, workaround weird issues when all dust cant be withdraw (#92)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-07-01 13:38:50 +02:00
tjs 18a9877e5a remove jup from client 2022-06-30 15:53:29 -04:00
tjs 97d45896b9 add yarn prepare 2022-06-30 13:32:55 -04:00
tjs 91b2e770e6 add esm tsconfig 2022-06-30 13:17:10 -04:00
Christian Kamm 6d05306859 Improve FlashLoan3 docs 2022-06-30 18:45:17 +02:00
Nicholas Clarke f8da1f6a40
Clarkeni/logging (#81)
* Add logging

* Added new_fixed_order_account_retriever to allow us to more easily access oracle prices outside of health calculations for logging purposes

* Add token balances logging to token and token liquidation and add logging to margin trade

* rust format

* fix clippy errors

* Address PR requested changes

* fix flash_loan

* Recalculate raw_token_index in token withdraw to account for position becoming inactive

* Fix retrieving oracle for logging

in get_mut_or_create(), return the raw index into the account's token
positions as well as the index into active positions only. The latter
index is useful for indexing into banks in the health account list.

* Add logging flash_loan2 and flash_loan3

* Refactoring flash loan logging

Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-06-30 14:35:05 +02:00
tjs ecbffe499f wip: add flash loan 3 2022-06-29 23:36:57 -04:00
tjs 273b8dd597 add deposits and borrows fn to mangoAccount 2022-06-29 15:55:42 -04:00
microwavedcola1 1c02ccd21d
Transfer dust from bank vaults to a dust account, without this we wont be able to close bank vaults (#88) 2022-06-29 09:11:14 +02:00
microwavedcola1 cce3836b09 update idl
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-28 16:55:00 +02:00
Christian Kamm 86d635f5d0 FlashLoan3: Variant that transfers directly
FlashLoan2 requires the user to set up transfers to and from the Mango
vault accounts. This version directly provides the loaned funds into a
target token account and repays everything that exceeds the initial
token account balance at the end.
2022-06-28 15:32:26 +02:00
Christian Kamm d786a672f1 FlashLoan2: API with Begin and End instructions
For FlashLoan users had to pass the target cpi programs, accounts and
data to the FlashLoan instruction itself.

The new API allows existing instructions to be used unchanged, they
just need to be bracketed by FlashLoan2Begin and FlashLoan2End.
2022-06-28 15:30:13 +02:00
Christian Kamm 3eedba67b1 Fix serum3_cancel_order
accidental removal of mut in 20fc9d557a
2022-06-27 11:38:55 +02:00
microwavedcola1 9fc8a5a56a
multiple banks (#82)
* multiple banks

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

* Fixes from review

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

* test for closing multiple banks for a registered token

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

* fix deregister_token

* update idl

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

* Fixes from review

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

Co-authored-by: Christian Kamm <mail@ckamm.de>
2022-06-27 11:27:17 +02:00
tjs 0758125db8 fix vaultIndex and transfer the minOutAmount back to vault 2022-06-24 19:01:57 +02:00
tjs 86deab72c5 Merge branch 'ts/token-transfer' into dev 2022-06-24 16:43:32 +02:00
tjs 997c610ec9 use jupiter swap and remove orca integration code 2022-06-24 16:41:04 +02:00
Christian Kamm 20fc9d557a Satisfy anchor's lint by adding CHECK: comments 2022-06-24 12:36:35 +02:00
microwavedcola1 7a28a3bfb0 improvements to flash loan
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-23 16:41:24 +02:00
tjs 719b944f89 update type names; fix flashLoan client fn 2022-06-23 16:02:35 +02:00
microwavedcola1 a151dea893 Merge branch 'dev' into ts/token-transfer 2022-06-23 15:36:33 +02:00
microwavedcola1 1177213bb3 Fix type
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-23 15:36:08 +02:00
microwavedcola1 8c024f438e Merge branch 'dev' into ts/token-transfer 2022-06-23 15:25:38 +02:00
microwavedcola1 84b89d4a1d fix
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-23 15:24:48 +02:00
microwavedcola1 c1dea82a55
mainnet scripts (#80)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-23 15:22:59 +02:00
tjs 997d363195 wip margin trade with spl token transfers 2022-06-23 15:20:32 +02:00
microwavedcola1 54c0306ae7 Fix flash loan
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2022-06-23 13:10:15 +02:00
Christian Kamm 0bd5b8fdf3 Rename margin_trade.rs -> flash_loan.rs 2022-06-23 10:23:52 +02:00
Christian Kamm c8ebc1f611 Rename MarginTrade -> FlashLoan 2022-06-23 10:23:52 +02:00
Christian Kamm d8a6a29e70 Renames: propagate to idl and ts 2022-06-23 10:04:54 +02:00
Christian Kamm 648b462352 Rename MangoAccount components 2022-06-23 10:04:54 +02:00
tjs 743f650494 fix orca import path 2022-06-22 17:09:18 +02:00
Christian Kamm 1143b38d3c Health review comments 2022-06-22 16:52:11 +02:00
Christian Kamm ba79995c01 Health: order-independent serum3 health
Now all the reserved funds in serum3 open orders accounts are added into
each possible token at the same time. Then the worse case from applying
the reserved funds to either quote or base is selected.

This is reasonably cheap to compute, leads to unchanged results when no
markets share (non USDC) base or quote tokens, but can underestimate
the "true" health value when markets do.

An additional advantage is that HealthCache is now indepenent of serum
open orders and can compute the init and maint health when the user has
active OpenOrders accounts.
2022-06-22 16:52:11 +02:00
Christian Kamm d4cec8dfa4 Bank: Fix bug when when depositing to exactly 0 2022-06-22 16:51:16 +02:00