Commit Graph

199 Commits

Author SHA1 Message Date
microwavedcola1 fb6311e842 Merge branch 'main' into deploy 2024-04-18 15:15:44 +02:00
Adrian Brzeziński f0264d666e last collateral fee charge field 2024-04-09 21:09:30 +02: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 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
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
Christian Kamm 27ecc14000 Merge tag 'program-v0.22.0' into deploy 2024-03-04 11:32:42 +01:00
Christian Kamm 834f15923d Merge remote-tracking branch 'origin/deploy' into dev 2024-03-04 11:09:07 +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
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 7a1be5a188 Merge remote-tracking branch 'origin/deploy' into dev 2024-02-14 10:24:12 +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 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 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
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
Christian Kamm 27b1ceebe8 Accounts: Expect only the v3 MangoAccounts now (#783) 2023-12-19 10:08:46 +01:00
Christian Kamm 0e8fc5e10e Merge branch 'deploy-v0.21.0' into dev 2023-12-08 11:39:01 +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 af314d01a5 format
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-11-14 17:05:55 +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 35bdf46c05
update getCumulativeFundingUi comment 2023-11-05 23:51:49 +01:00
Lou-Kamades b39412d3a2
add getCumulativeFundingUi 2023-11-05 15:13:23 +01:00
Nicholas Clarke a4fa1b801b
Add getCumulativeFunding to client. (#602)
* Add getCumulativeFunding to client.
2023-11-05 14:27:46 +01:00
microwavedcola1 e0b4bd1236
ts: upgrade anchor (#735)
* ts: upgrade anchor

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-10-06 10:05:56 +02:00
microwavedcola1 549c4704d1
ts: helpers for withdrawing tokens from bad oracles (#726)
* ts: helpers for withdrawing tokens from bad oracles

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>

* Fixes from review

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

* rename

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

* rename

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

* Fix usage of field

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-09-20 10:48:11 +02:00
microwavedcola1 d51c3ee85d
release 19.1 -> deploy + serum3 open orders estimation ts patch (#719)
* 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.

(cherry picked from commit 2adc0339dc)

* Changelog, version bump for program v0.19.1

* ts: ts patch for the PR

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

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
Co-authored-by: Christian Kamm <mail@ckamm.de>
2023-09-16 11:04:38 +02:00
microwavedcola1 cda47a18d1 v0.19.25 2023-09-08 12:15:50 +02:00
microwavedcola1 b46e275a2c
Mc/tcs improvements (#706)
* ts: additional tcs helpers

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

* Fixes from review

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

* Revert "Fixes from review"

This reverts commit 1def10353511802c030a100fd23b2c2f4f198eaa.

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-09-08 08:49:38 +02:00
Christian Kamm d60bea7436 Merge remote-tracking branch 'origin/main' into deploy 2023-09-07 12:59:50 +02:00
microwavedcola1 447e7cb151 ts: update tcs helpers
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-08-20 21:30:12 +02:00
microwavedcola1 aa1a9f36e9 ts: add tcs helper for current pair price
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-08-13 12:01:20 +02:00
microwavedcola1 c1be446aab
Mc/slot to tx (#676)
* v0.18.17

* ts: return confirmed slot when executing a tx

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-11 19:12:13 +02:00
microwavedcola1 c7cc7c248c ts: fix threshold price computation in token conditional swaps
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-08-10 16:16:05 +02:00
Christian Kamm b2e578bc61 Merge remote-tracking branch 'origin/deploy' into dev 2023-08-10 13:32:06 +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
microwavedcola1 5755480248 threshold price ui helper for tcs in ts client
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-08-08 14:59:43 +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
microwavedcola1 4c083a9a56
ts client: fix getMaxWithdrawWithBorrowForToken (#664)
* fix max withdraw amount, wasnt taking into account scaled weights

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-07 13:12:37 +02:00
microwavedcola1 776545fcdd
token conditional swaps, fixes from review (#653)
* tcs fixes from review, and easy to use helper functions

* 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>

* Fixes from review

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

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-08-07 13:09:19 +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
microwavedcola1 5f7d704911 improve tcs further
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-07-28 15:57:25 +02:00
microwavedcola1 ef2df16f83 cleanup tcs
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-07-28 15:32:50 +02:00
microwavedcola1 5008d3253c Fixes for tcs
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-07-28 15:13:01 +02:00
microwavedcola1 c24e77d3a4
wip: extend tcs helpers (#649)
* extend tcs helpers

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

* comment

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

* add slippage helper

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

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
2023-07-28 08:26:34 +02:00
Christian Kamm fef5fd97da Merge remote-tracking branch 'origin/release/program-v0.18' into deploy 2023-07-17 16:28:59 +02:00