Commit Graph

1033 Commits

Author SHA1 Message Date
microwavedcola1 f4c6a086c1 small updates to token withdraw script
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-04-24 11:29:46 +02:00
microwavedcola1 fb6311e842 Merge branch 'main' into deploy 2024-04-18 15:15:44 +02:00
Serge Farny 0dc9d9ab80 program; fix health check ix gate (#940)
(cherry picked from commit fe86295d3c)
2024-04-11 07:22:51 +02:00
Adrian Brzeziński f0264d666e last collateral fee charge field 2024-04-09 21:09:30 +02:00
Lou-Kamades 27ce516703
Lou/ts fallback fetching (#917)
* ts: add CLMM oracle parsing

* ts: add functions for deriving fallback oracles

* ts: add fallbacks to buildHealthRemainingAccounts

* ts: lint

* ts: fallback contexts are keyed on string for reliable equality checks

* ts: lint
2024-03-27 10:52:33 -05:00
riordanp d03efb7260
Fix getCumulativeFundingUi (#920)
* sum long and short funding
2024-03-21 12:16:23 +00:00
Christian Kamm 6f85dfa42d Merge remote-tracking branch 'origin/deploy' into dev 2024-03-14 11:26:33 +01:00
Serge Farny b3b4cc8223
program: add a min health check (#913)
add a min health check
2024-03-12 08:27:40 +01:00
Serge Farny 0728bb566f
program: sequence check as u8 (#909)
* program: sequence check as u8 (reuse existing padding)
2024-03-11 10:45:53 +01:00
microwavedcola1 d9068758d2 ts: fix lint
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-03-10 14:27:31 +01:00
microwavedcola1 f2442428b6 Merge branch 'main' into deploy 2024-03-10 14:26:29 +01:00
Christian Kamm 077199ed39
ts: rework getMaxWithdrawWithBorrowForToken (#900)
* ts: rework getMaxWithdrawWithBorrowForToken

* binary seach for maxWithdraw

* tests

* warnings

* revert later, change for debugging

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

* fix looking deeper than 0.5 tokens

* no borrows on no-borrow-tokens

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2024-03-10 14:11:30 +01:00
Serge Farny 494835631b
program: add a sequence check IX (#908)
Add a sequence check IX

This new IX `SequenceCheck` can be used to avoid having multiple concurrent TX in flight causing unexpected result (multiple borrow for example)
2024-03-07 14:59:05 +01:00
Adrian Brzeziński 1a6a544ecd
max accounts error margin fcn (#905)
* add error for max accounts limit

* fix
2024-03-05 16:56:35 +01:00
microwavedcola1 8aff0fb8c5 ts: add missing fields
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-03-04 14:28:49 +01:00
Christian Kamm 27ecc14000 Merge tag 'program-v0.22.0' into deploy 2024-03-04 11:32:42 +01:00
Christian Kamm a30c5a9e06 Bump program version to v0.23.0, update idl 2024-03-04 11:22:08 +01:00
Serge Farny bc166ea54b ts client: fix imports (#898)
(cherry picked from commit 53517f876b)
2024-03-04 11:21:54 +01:00
Christian Kamm e7f5cd7498 Bump program version to v0.24.0, update idl 2024-03-04 11:15:23 +01:00
Christian Kamm 834f15923d Merge remote-tracking branch 'origin/deploy' into dev 2024-03-04 11:09:07 +01:00
Serge Farny 53517f876b
ts client: fix imports (#898) 2024-03-01 11:21:58 +01:00
microwavedcola1 cacf668999
ts: account for max swap fee rate, when swapping (#892)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-02-23 09:23:30 +01:00
Christian Kamm e107b281f9 Idl update 2024-02-21 15:06:34 +01:00
Adrian Brzeziński 6aabbb4ded
fix multi cancel (#888)
* fix multi cancel

* fix

* fix
2024-02-20 12:45:06 +01:00
Christian Kamm 46c6e86206
Add force_withdraw state and instruction (#884)
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2024-02-19 15:06:51 +01:00
microwavedcola1 f216b7b696
Mc/tcs premium auction (#870)
* tcs: move to premium auctions by default

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

* tcs: error out if premium cant be computed

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

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-02-19 09:32:39 +01:00
Christian Kamm 8a3a3bf70b
flash loan: Add a "swap without fees" option (#882) 2024-02-19 09:00:30 +01:00
Adrian Brzeziński 5bbed4a519
adjust loanoriginafeerate for untrusted (#885) 2024-02-16 11:26:12 +01:00
Christian Kamm 7a1be5a188 Merge remote-tracking branch 'origin/deploy' into dev 2024-02-14 10:24:12 +01:00
Christian Kamm e57dcdc2a9
Add collateral fees (#868)
- New permissionless instruction to regularly charge collateral fees
- Bank and group configuration to set rate and interval
- Keeper addition to call the instruction
2024-02-13 12:39:28 +01:00
Adrian Brzeziński 6c29adddae fix conversion for sourceamount (tokens with a lot of decimals) 2024-02-07 17:42:21 +04:00
Christian Kamm d9a9c7d664
liquidation: Add flag to disable asset liquidation (#867)
This can be used to remove the oracle dependency for tokens with zero maint asset
weight that are not borrowable.
2024-02-07 12:52:01 +01:00
Christian Kamm 1392f726ba fix perp settle limit materialization (#865)
Previously, we tried to keep track of "other" and "trade" realized pnl.
An issue occured when a perp base position went to zero: the way we
computed the trade pnl included potential non-trade unsettled pnl.

That caused follow-up trouble because the value could change sign and
reset the settle limit for trade pnl.

This change aims to simplify in some ways:
- explicitly talk about oneshot-settleable pnl (fees, funding,
  liquidation) and recurring-settleable pnl (materialization of settle
  limit derived from the stable value of the base position when reducing
  the base position)
- instead of directly tracking realized settleable amounts (which
  doesn't really work), just decrease the recurring settleable amount
  when it exceeds the remaining unsettled pnl
- get rid of the directionality to avoid bugs of that kind
- stop tracking unsettled-realized trade pnl (it was wrong before, and
  no client uses it) - we already track position-lifetime realized trade
  pnl

(cherry picked from commit ae5907ba3a)
2024-02-01 11:24:39 +01:00
Christian Kamm ae5907ba3a
fix perp settle limit materialization (#865)
Previously, we tried to keep track of "other" and "trade" realized pnl.
An issue occured when a perp base position went to zero: the way we
computed the trade pnl included potential non-trade unsettled pnl.

That caused follow-up trouble because the value could change sign and
reset the settle limit for trade pnl.

This change aims to simplify in some ways:
- explicitly talk about oneshot-settleable pnl (fees, funding,
  liquidation) and recurring-settleable pnl (materialization of settle
  limit derived from the stable value of the base position when reducing
  the base position)
- instead of directly tracking realized settleable amounts (which
  doesn't really work), just decrease the recurring settleable amount
  when it exceeds the remaining unsettled pnl
- get rid of the directionality to avoid bugs of that kind
- stop tracking unsettled-realized trade pnl (it was wrong before, and
  no client uses it) - we already track position-lifetime realized trade
  pnl
2024-02-01 11:23:45 +01:00
Adrian Brzeziński ea7eeb92dc
fix decoding of broken oracle (#864)
* fix

* fix

* fix

* fix
2024-01-31 15:52:06 +01:00
microwavedcola1 e16a7db8dd Merge branch 'main' into deploy 2024-01-30 12:19:45 +01:00
GoodDaisy 2f10a710c9
chore: fix typos (#854) 2024-01-29 13:39:33 +01:00
Christian Kamm 5519f77d8e ts: fallback oracles in bank and token_edit 2024-01-29 13:37:44 +01:00
Adrian Brzeziński 80cad71af5 add set to deepclone 2024-01-28 14:34:04 +01:00
Christian Kamm 5fc5646aff
ts: Fix registering tokens and stub oracles (#859) 2024-01-26 21:10:33 +01:00
Christian Kamm 39c5d029d0 Program version bump, changelog and idl update 2024-01-26 12:39:31 +01:00
Christian Kamm 8f593e00b8 perp: Add platform liquidation fee for base (#858)
(cherry picked from commit fcc8c85f6e)
2024-01-26 10:25:35 +01:00
Christian Kamm a4e5cf9b02 Add a token-token platform liquidation fee (#849)
The liqor liquidation fee and platform liquidation fee for the asset and
liab token are both payed by the liqee.

The platform liquidation fee is added to the Bank's
collected_fees_native and tracked in collected_liquidation_fees.

(cherry picked from commit 8383109f0d)
2024-01-26 10:25:27 +01:00
Christian Kamm 5f97f60719 Configurable interest rate for 0% utilization (#848)
(cherry picked from commit 18729cf04c)
2024-01-26 10:25:13 +01:00
Christian Kamm fcc8c85f6e
perp: Add platform liquidation fee for base (#858) 2024-01-26 10:24:20 +01:00
microwavedcola1 e079f199c2
ts: use potential serum tokens in deposit limits (#857)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-24 14:26:33 +01:00
Adrian Brzeziński e69214f408
max borrow fix (#855)
* fix

* ts: compute correct init scaled asset weight

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

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-22 18:56:50 +01:00
Christian Kamm 8383109f0d
Add a token-token platform liquidation fee (#849)
The liqor liquidation fee and platform liquidation fee for the asset and
liab token are both payed by the liqee.

The platform liquidation fee is added to the Bank's
collected_fees_native and tracked in collected_liquidation_fees.
2024-01-19 16:34:55 +01:00
Adrian Brzeziński bff4828bbf
use deposit limits (#852)
* edit max source token

* deposit limits adjustments

* fix comment

* pr fixes

* fix

* fix
2024-01-18 17:47:57 +01:00
microwavedcola1 5d677b858d ts: fix import
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-16 14:55:23 +01:00
Adrian Brzeziński dfccdaf1fb
Feature/confirm txes fix (#847)
* connections

* merge

* use new mangolana

* v0.21.21

* fix

* fix

* fix error parsing

* fix

* fix

* fix

* v0.21.24

* fix version

* fix

* fix
2024-01-16 10:59:18 +01:00
microwavedcola1 5d186421bb ts: take liquidation batches to a script
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-16 10:47:52 +01:00
microwavedcola1 fce4e18735 Merge branch 'mc/deposit-limits' into deploy 2024-01-16 10:22:04 +01:00
microwavedcola1 6e3c284220 ts: deposit limits 2024-01-16 10:21:15 +01:00
Christian Kamm 18729cf04c
Configurable interest rate for 0% utilization (#848) 2024-01-15 12:45:00 +01:00
microwavedcola1 f7dcb99c5f ts: fix node fetch
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-12 13:12:19 +01:00
Christian Kamm 637b43fec4 Idl update 2024-01-12 10:56:24 +01:00
Adrian Brzeziński 6e72188bd4 Revert "Improve tx confirmation (#846)"
This reverts commit 19a0f7d59d.
2024-01-12 02:03:46 +01:00
Adrian Brzeziński 19a0f7d59d
Improve tx confirmation (#846)
* improve tx confirmation with mangolana

* dedupe

* support multiple connections

* fix
2024-01-11 21:14:05 +01:00
Adrian Brzeziński 68e119e726
use fast clone (#843)
* use fast clone

* fix

* add health check copy tests

* fix

* fix

* add more test
2024-01-11 21:13:41 +01:00
Lou-Kamades c9531f4bc4
Add TxCallbackOptions (#844)
* ts: include slot when fetching LatestBlockHash

* ts: add txSignatureBlockHash to postTxConfirmationCallback

* v0.21.9

* v0.21.11

* v0.21.12

* v0.21.13 - add TxCallbackOptions
2024-01-10 14:12:04 -06:00
Lou-Kamades 0971557047
Expand usage of postTxConfirmationCallback (#842)
* ts: include slot when fetching LatestBlockHash

* ts: add txSignatureBlockHash to postTxConfirmationCallback

* v0.21.9
2024-01-09 14:38:57 -06:00
Christian Kamm ce0713070a Merge remote-tracking branch 'origin/deploy' into dev 2024-01-09 12:31:20 +01:00
Adrian Brzeziński bc8bdaed89
small type fixes + post tx approve fcn (#830)
* background confirmations

* fixes

* background confirmation callback

* fix

* fix
2024-01-07 20:14:26 +01:00
Christian Kamm 40f2842c10
ts client: Support deposit-into-existing (#837)
And add a script for using it.
2024-01-04 20:21:09 +01:00
microwavedcola1 55d22e07c5 risk: use know mm's endpoint + add fallback to known mms pubkeys
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2024-01-03 08:43:48 +01:00
Christian Kamm f10fc01388
Fix idl generation, update it (#834) 2024-01-03 08:36:19 +01:00
Christian Kamm 943f578bc5 Program v0.21.1 version bump, changelog draft, idl update 2023-12-31 11:45:09 +01:00
microwavedcola1 a57ec4018d
Mc/no usdc health cache (#831)
* ts: sim usdc pos for max perp trades even if no usdc token position exists

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-12-29 14:21:01 +01:00
Lou-Kamades 48993ed130
ts: improve sending txns using muiltiple connections (#826) 2023-12-28 21:48:59 -06:00
microwavedcola1 ce3a243749 ts: export class
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-12-26 11:35:11 +01:00
Christian Kamm 27b1ceebe8 Accounts: Expect only the v3 MangoAccounts now (#783) 2023-12-19 10:08:46 +01:00
Christian Kamm 06da4768f3 Gov instruction creation helpers
- Add one to make a proposal for all serum markets
- Switch created proposals to be drafts
- Add PROPOSAL_LINK env arg
- Add serum3EditMarketIx()
2023-12-14 11:34:17 +01:00
microwavedcola1 66bb74c2fd ts: add prop to serum3 markets
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-12-14 05:59:44 +01:00
microwavedcola1 e75d279b15 Merge branch 'deploy-v0.21.0' into deploy 2023-12-13 09:04:44 +01:00
microwavedcola1 95442b993f ts: fix getMaxSerum3OrderForHealthRatio where scaled weights werent used
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-12-08 15:59:01 +01:00
Christian Kamm 0e8fc5e10e Merge branch 'deploy-v0.21.0' into dev 2023-12-08 11:39:01 +01:00
Christian Kamm f2bde7ba9f Merge tag 'program-v0.21.0' into deploy-v0.21.0 2023-12-08 11:30:44 +01:00
Christian Kamm cb9848252d
update idl and client tokenEdit() (#814) 2023-12-08 11:09:57 +01:00
Lou-Kamades a1966dc0bc
TS: allow for multiple providers when sending transactions (#808)
* allow for multiple providers in the client

* v0.20.9
2023-12-07 15:19:25 -06:00
Christian Kamm db4e486643 Bump program version to v0.21.0 and update idl 2023-12-05 15:57:42 +01:00
Christian Kamm e7bfa4e03e Deposit limits (#806)
- limit deposits (via deposit, flash loan, tcs)
- limit potential deposits via openbook settle
  by restricting placable orders via potential_serum_tokens
- introduce Serum3PlaceOrderV2 for this purpose
- account for new limits in liquidator, max_swap

(cherry picked from commit 42e31ae859)
2023-12-05 15:57:26 +01:00
Christian Kamm f533d65a58 Openbook token tracking and price bands (#805)
- track min bid, max ask
- track maximal token outflow from oo
- add serum3_place_order_v2 with mutable receiver bank
- placing openbook orders is restricted to a certain distance from the
  oracle

(cherry picked from commit 81501837a9)
2023-12-05 15:48:57 +01:00
Christian Kamm 42e31ae859
Deposit limits (#806)
- limit deposits (via deposit, flash loan, tcs)
- limit potential deposits via openbook settle
  by restricting placable orders via potential_serum_tokens
- introduce Serum3PlaceOrderV2 for this purpose
- account for new limits in liquidator, max_swap
2023-12-05 15:43:38 +01:00
Christian Kamm 81501837a9
Openbook token tracking and price bands (#805)
- track min bid, max ask
- track maximal token outflow from oo
- add serum3_place_order_v2 with mutable receiver bank
- placing openbook orders is restricted to a certain distance from the
  oracle
2023-12-05 15:39:24 +01:00
Britt Cyr 68944747e0
Add serum3 cancel by client order id instruction (#798) 2023-12-01 13:36:29 +01:00
Christian Kamm 6d80568022
Accounts: Expect only the v3 MangoAccounts now (#783) 2023-11-27 09:30:37 +01:00
Christian Kamm feeb63dab2
ts: tcs hasData was renamed to isConfigured (#796) 2023-11-24 11:06:44 +01:00
Christian Kamm 2829bef48e ts: tcs hasData was renamed to isConfigured 2023-11-24 11:05:20 +01:00
microwavedcola1 5429ac1962
ts: scripts for testing account shrink (#733)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-11-23 08:58:47 +01:00
microwavedcola1 048983ffe5 ts: extend errors
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-11-22 08:02:32 +01:00
tjs 97a2a7a194 return slot after sending a transaction 2023-11-21 17:17:01 -05:00
Christian Kamm a96fb0f614 Revert "Bank: store interest curve scale and target util separately (#755)"
This reverts commit 3b28856692.

It should not have been in deploy since it changes instruction ABI and
has not been released in v0.20.0
2023-11-17 07:58:41 +01:00
microwavedcola1 21b8c0dbfa risk: disable for now
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-11-16 08:42:18 +01:00
Christian Kamm 2d1bf023c6
TokenRegister: Add arg for group insurance fund flag (#782) 2023-11-16 08:16:18 +01:00
microwavedcola1 af314d01a5 format
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-11-14 17:05:55 +01:00
Christian Kamm 93d85c3f71
Bank: allow maint weights to change over time (#780)
- token_edit can set it up to gradually scale to new target values
- security admin can abort an ongoing change via token_edit
- all health computations are now time dependent and get the weight
  based on it
- when the change is done, the keeper "cleans up" and moves the new
  values into the default fields
2023-11-14 14:52:04 +01:00
microwavedcola1 25fd722743 ts: update some typings, commented ones will be improved after next release
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-11-14 10:29:58 +01:00
Lou-Kamades 3ccf2317fe ts: use release 20 idl 2023-11-13 18:48:46 -06:00
Lou-Kamades 56480f2268 ts: don't alter user margin trade Ixs 2023-11-13 15:04:25 -06:00