@mysten/deepbook-v3 2.6.4 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +153 -0
- package/PREDICT.md +389 -61
- package/dist/contracts/account/account.d.mts +23 -23
- package/dist/contracts/account/account.d.mts.map +1 -1
- package/dist/contracts/account/account_registry.d.mts +13 -13
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook_predict/admin.d.mts +4 -4
- package/dist/contracts/deepbook_predict/builder_code.d.mts +11 -11
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts +10 -10
- package/dist/contracts/deepbook_predict/config_events.d.mts +93 -68
- package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/config_events.mjs +45 -1
- package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook_predict/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.d.mts +652 -235
- package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.mjs +652 -186
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/lp_book.mjs +1 -1
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/market_manager.d.mts +27 -27
- package/dist/contracts/deepbook_predict/order_events.d.mts +50 -50
- package/dist/contracts/deepbook_predict/order_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.mjs +3 -1
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pause_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/plp.d.mts +184 -82
- package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/plp.mjs +126 -7
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +1 -1
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/predict_account.d.mts +14 -14
- package/dist/contracts/deepbook_predict/pricing.d.mts +91 -58
- package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.mjs +30 -3
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing_config.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/protocol_config.d.mts +400 -92
- package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/protocol_config.mjs +451 -61
- package/dist/contracts/deepbook_predict/protocol_config.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/range_codec.d.mts +2 -2
- package/dist/contracts/deepbook_predict/registry.d.mts +28 -28
- package/dist/contracts/deepbook_predict/strike_exposure.mjs +1 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +17 -12
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.d.mts +154 -106
- package/dist/contracts/deepbook_predict/vault_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs +57 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict_math/config-arguments.d.mts +10 -0
- package/dist/contracts/deepbook_predict_math/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.d.mts +106 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.mjs +125 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_math/math.d.mts +284 -0
- package/dist/contracts/deepbook_predict_math/math.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/math.mjs +364 -0
- package/dist/contracts/deepbook_predict_math/math.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts +13 -0
- package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts +215 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs +215 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs +87 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs +52 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs +25 -0
- package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs +39 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/desk.d.mts +187 -0
- package/dist/contracts/deepbook_predict_orders/desk.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/desk.mjs +261 -0
- package/dist/contracts/deepbook_predict_orders/desk.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.d.mts +1042 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.mjs +849 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue.d.mts +683 -0
- package/dist/contracts/deepbook_predict_orders/queue.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue.mjs +912 -0
- package/dist/contracts/deepbook_predict_orders/queue.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.d.mts +195 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.mjs +187 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
- package/dist/contracts/deepbook_sessions/sessions.d.mts +163 -28
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/contracts/deepbook_sessions/sessions.mjs +234 -5
- package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -1
- package/dist/deployments/mainnet.mjs +7 -4
- package/dist/deployments/mainnet.mjs.map +1 -1
- package/dist/deployments/testnet.mjs +7 -4
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/predict/bindings/expiry-market.d.mts +77 -0
- package/dist/predict/bindings/expiry-market.d.mts.map +1 -0
- package/dist/predict/bindings/expiry-market.mjs +139 -0
- package/dist/predict/bindings/expiry-market.mjs.map +1 -0
- package/dist/predict/bindings/protocol-config.d.mts +39 -0
- package/dist/predict/bindings/protocol-config.d.mts.map +1 -0
- package/dist/predict/bindings/protocol-config.mjs +90 -0
- package/dist/predict/bindings/protocol-config.mjs.map +1 -0
- package/dist/predict/bindings/rename.mjs +9 -0
- package/dist/predict/bindings/rename.mjs.map +1 -0
- package/dist/predict/client.d.mts +595 -16
- package/dist/predict/client.d.mts.map +1 -1
- package/dist/predict/client.mjs +986 -10
- package/dist/predict/client.mjs.map +1 -1
- package/dist/predict/config/generated.d.mts +22 -1
- package/dist/predict/config/generated.d.mts.map +1 -1
- package/dist/predict/config/generated.mjs +30 -1
- package/dist/predict/config/generated.mjs.map +1 -1
- package/dist/predict/config/mainnet.mjs +11 -3
- package/dist/predict/config/mainnet.mjs.map +1 -1
- package/dist/predict/config/testnet.mjs +11 -3
- package/dist/predict/config/testnet.mjs.map +1 -1
- package/dist/predict/config/types.d.mts +50 -1
- package/dist/predict/config/types.d.mts.map +1 -1
- package/dist/predict/cost.d.mts +38 -11
- package/dist/predict/cost.d.mts.map +1 -1
- package/dist/predict/cost.mjs +37 -11
- package/dist/predict/cost.mjs.map +1 -1
- package/dist/predict/decode.d.mts +251 -1
- package/dist/predict/decode.d.mts.map +1 -1
- package/dist/predict/decode.mjs +342 -4
- package/dist/predict/decode.mjs.map +1 -1
- package/dist/predict/errors.d.mts +69 -6
- package/dist/predict/errors.d.mts.map +1 -1
- package/dist/predict/errors.mjs +277 -4
- package/dist/predict/errors.mjs.map +1 -1
- package/dist/predict/index.d.mts +21 -10
- package/dist/predict/index.mjs +24 -12
- package/dist/predict/queue-id.d.mts +13 -0
- package/dist/predict/queue-id.d.mts.map +1 -0
- package/dist/predict/queue-id.mjs +19 -0
- package/dist/predict/queue-id.mjs.map +1 -0
- package/dist/predict/queue.d.mts +505 -0
- package/dist/predict/queue.d.mts.map +1 -0
- package/dist/predict/queue.mjs +774 -0
- package/dist/predict/queue.mjs.map +1 -0
- package/dist/predict/reads/balances.mjs +1 -1
- package/dist/predict/reads/markets.mjs +46 -5
- package/dist/predict/reads/markets.mjs.map +1 -1
- package/dist/predict/reads/pool.mjs +1 -1
- package/dist/predict/reads/pricing.d.mts +1 -1
- package/dist/predict/reads/queue.d.mts +105 -0
- package/dist/predict/reads/queue.d.mts.map +1 -0
- package/dist/predict/reads/queue.mjs +445 -0
- package/dist/predict/reads/queue.mjs.map +1 -0
- package/dist/predict/ticks.d.mts +9 -1
- package/dist/predict/ticks.d.mts.map +1 -1
- package/dist/predict/ticks.mjs +18 -1
- package/dist/predict/ticks.mjs.map +1 -1
- package/dist/predict/tx/authed.mjs +1 -1
- package/dist/predict/tx/common.d.mts.map +1 -1
- package/dist/predict/tx/common.mjs +12 -1
- package/dist/predict/tx/common.mjs.map +1 -1
- package/dist/predict/tx/queue.d.mts +220 -0
- package/dist/predict/tx/queue.d.mts.map +1 -0
- package/dist/predict/tx/queue.mjs +399 -0
- package/dist/predict/tx/queue.mjs.map +1 -0
- package/dist/predict/tx/trade.d.mts.map +1 -1
- package/dist/predict/tx/trade.mjs +61 -43
- package/dist/predict/tx/trade.mjs.map +1 -1
- package/dist/sessions.d.mts +90 -2
- package/dist/sessions.d.mts.map +1 -1
- package/dist/sessions.mjs +107 -2
- package/dist/sessions.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/package.json +4 -4
- package/src/contracts/deepbook_predict/config_events.ts +39 -0
- package/src/contracts/deepbook_predict/deps/std/type_name.ts +24 -0
- package/src/contracts/deepbook_predict/expiry_market.ts +960 -169
- package/src/contracts/deepbook_predict/order_events.ts +3 -1
- package/src/contracts/deepbook_predict/plp.ts +150 -9
- package/src/contracts/deepbook_predict/pricing.ts +46 -7
- package/src/contracts/deepbook_predict/pricing_config.ts +3 -1
- package/src/contracts/deepbook_predict/protocol_config.ts +648 -33
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +25 -21
- package/src/contracts/deepbook_predict/vault_events.ts +65 -0
- package/src/contracts/deepbook_predict_math/config-arguments.ts +6 -0
- package/src/contracts/deepbook_predict_math/lazer_price.ts +196 -0
- package/src/contracts/deepbook_predict_math/math.ts +553 -0
- package/src/contracts/deepbook_predict_orders/config-arguments.ts +11 -0
- package/src/contracts/deepbook_predict_orders/delayed_execution_config.ts +430 -0
- package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.ts +108 -0
- package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.ts +58 -0
- package/src/contracts/deepbook_predict_orders/deps/fixed_math/i64.ts +21 -0
- package/src/contracts/deepbook_predict_orders/deps/sui/balance.ts +19 -0
- package/src/contracts/deepbook_predict_orders/deps/sui/table.ts +37 -0
- package/src/contracts/deepbook_predict_orders/desk.ts +419 -0
- package/src/contracts/deepbook_predict_orders/order_flow.ts +19 -0
- package/src/contracts/deepbook_predict_orders/order_queue.ts +1670 -0
- package/src/contracts/deepbook_predict_orders/queue.ts +1394 -0
- package/src/contracts/deepbook_predict_orders/queue_events.ts +189 -0
- package/src/contracts/deepbook_sessions/sessions.ts +355 -4
- package/src/deployments/mainnet.ts +7 -2
- package/src/deployments/testnet.ts +7 -2
- package/src/deployments/types.ts +14 -1
- package/src/predict/bindings/expiry-market.ts +127 -0
- package/src/predict/bindings/protocol-config.ts +59 -0
- package/src/predict/bindings/rename.ts +14 -0
- package/src/predict/client.ts +2076 -13
- package/src/predict/config/generated.ts +50 -0
- package/src/predict/config/mainnet.ts +16 -2
- package/src/predict/config/testnet.ts +16 -2
- package/src/predict/config/types.ts +51 -1
- package/src/predict/cost.ts +62 -14
- package/src/predict/decode.ts +691 -2
- package/src/predict/errors.ts +391 -14
- package/src/predict/index.ts +87 -6
- package/src/predict/queue-id.ts +22 -0
- package/src/predict/queue.ts +1231 -0
- package/src/predict/reads/markets.ts +30 -0
- package/src/predict/reads/queue.ts +606 -0
- package/src/predict/ticks.ts +35 -0
- package/src/predict/tx/common.ts +25 -1
- package/src/predict/tx/queue.ts +525 -0
- package/src/predict/tx/trade.ts +80 -49
- package/src/sessions.ts +206 -1
package/src/predict/tx/trade.ts
CHANGED
|
@@ -3,16 +3,13 @@
|
|
|
3
3
|
import type { Transaction, TransactionResult } from '@mysten/sui/transactions';
|
|
4
4
|
import type { GeneratedConfig } from '../config/generated.js';
|
|
5
5
|
import { U64_MAX } from '../units.js';
|
|
6
|
+
import { accountMoveCalls as account } from '../../account.js';
|
|
6
7
|
import * as expiryMarket from '../../contracts/deepbook_predict/expiry_market.js';
|
|
7
8
|
import { withAuth } from './common.js';
|
|
8
9
|
|
|
9
10
|
// The trade calls with their `auth` argument already supplied (see `withAuth`): each
|
|
10
11
|
// takes its generated options minus that slot and expands to auth → call.
|
|
11
12
|
const authed = {
|
|
12
|
-
mintExactQuantity: withAuth(expiryMarket.mintExactQuantity),
|
|
13
|
-
mintExactAmount: withAuth(expiryMarket.mintExactAmount),
|
|
14
|
-
mintExactCost: withAuth(expiryMarket.mintExactCost),
|
|
15
|
-
redeemLive: withAuth(expiryMarket.redeemLive),
|
|
16
13
|
redeemSettled: withAuth(expiryMarket.redeemSettled),
|
|
17
14
|
};
|
|
18
15
|
|
|
@@ -26,8 +23,9 @@ export interface MarketFeeds {
|
|
|
26
23
|
}
|
|
27
24
|
|
|
28
25
|
// Load a fresh `Pricer` from the live oracle feeds. Every live-flow trade call
|
|
29
|
-
// (`mint_*`, `redeem_live`)
|
|
30
|
-
// PTB.
|
|
26
|
+
// (`mint_*`, `redeem_live`) and every live quote (`quote_mint*`, the queue's `quote_redeem_open`) borrows
|
|
27
|
+
// this `&Pricer` and it must be loaded first in the PTB. Queued orders (`enqueue_*`) don't take
|
|
28
|
+
// one: they read the oracle objects directly. Deployed sig `load_live_pricer` (expiry_market.move): market, config,
|
|
31
29
|
// propbook_registry (&OracleRegistry), pyth, bs_values, bs_svi, clock (auto-injected).
|
|
32
30
|
// `config` and `propbook_registry` are supplied by the config slice, not named here.
|
|
33
31
|
export function loadLivePricer(
|
|
@@ -49,16 +47,24 @@ export function loadLivePricer(
|
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
// The three commands every live-flow trade is: load a fresh market-bound `Pricer`, mint
|
|
52
|
-
// owner auth, then the one `expiry_market::*` call that consumes both.
|
|
53
|
-
//
|
|
50
|
+
// owner auth, then the one `expiry_market::*` call that consumes both.
|
|
51
|
+
//
|
|
52
|
+
// The live trades are retired: Predict v4 keeps their published signatures but names every
|
|
53
|
+
// parameter with a leading underscore, which codegen renders as a capitalized key (`_market` →
|
|
54
|
+
// `Market`). So the auth is minted here and passed as `Auth`, rather than through `withAuth`.
|
|
55
|
+
// The emitted commands are unchanged, and still reach a pre-v4 package.
|
|
54
56
|
function liveTrade(
|
|
55
57
|
config: GeneratedConfig,
|
|
56
58
|
args: { expiryMarketId: string } & MarketFeeds,
|
|
57
|
-
build: (
|
|
59
|
+
build: (
|
|
60
|
+
pricer: TransactionResult,
|
|
61
|
+
auth: TransactionResult,
|
|
62
|
+
) => (tx: Transaction) => TransactionResult,
|
|
58
63
|
): (tx: Transaction) => TransactionResult {
|
|
59
64
|
return (tx) => {
|
|
60
65
|
const pricer = tx.add(loadLivePricer(config, args));
|
|
61
|
-
|
|
66
|
+
const auth = tx.add(account.generateAuth({ config }));
|
|
67
|
+
return tx.add(build(pricer, auth));
|
|
62
68
|
};
|
|
63
69
|
}
|
|
64
70
|
|
|
@@ -66,6 +72,11 @@ function liveTrade(
|
|
|
66
72
|
// returning the new order id (u256). Command order is pricer → auth → mint (auth is a
|
|
67
73
|
// hot potato consumed by this call). `maxCostRaw`/`maxProbabilityRaw` default to
|
|
68
74
|
// `U64_MAX` (no slippage cap). Deployed sig `mint_exact_quantity`.
|
|
75
|
+
/**
|
|
76
|
+
* @deprecated Retired by delayed execution (DBU-885): Predict v4's `mint_exact_quantity` always
|
|
77
|
+
* aborts `EDelayedExecutionRequired`, so this works only while the config's call target is a
|
|
78
|
+
* pre-v4 package. Use `enqueueExactQuantity` from `tx/queue.ts`.
|
|
79
|
+
*/
|
|
69
80
|
export function mintExactQuantity(
|
|
70
81
|
config: GeneratedConfig,
|
|
71
82
|
args: {
|
|
@@ -78,18 +89,19 @@ export function mintExactQuantity(
|
|
|
78
89
|
maxProbabilityRaw?: bigint;
|
|
79
90
|
} & MarketFeeds,
|
|
80
91
|
): (tx: Transaction) => TransactionResult {
|
|
81
|
-
return liveTrade(config, args, (pricer) =>
|
|
82
|
-
|
|
92
|
+
return liveTrade(config, args, (pricer, auth) =>
|
|
93
|
+
expiryMarket.mintExactQuantity({
|
|
83
94
|
config,
|
|
84
95
|
arguments: {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
96
|
+
Market: args.expiryMarketId,
|
|
97
|
+
Wrapper: args.wrapperId,
|
|
98
|
+
Auth: auth,
|
|
99
|
+
Pricer: pricer,
|
|
100
|
+
LowerTick: args.lowerTick,
|
|
101
|
+
HigherTick: args.higherTick,
|
|
102
|
+
Quantity: args.quantityRaw,
|
|
103
|
+
MaxCost: args.maxCostRaw ?? U64_MAX,
|
|
104
|
+
MaxProbability: args.maxProbabilityRaw ?? U64_MAX,
|
|
93
105
|
},
|
|
94
106
|
}),
|
|
95
107
|
);
|
|
@@ -99,6 +111,10 @@ export function mintExactQuantity(
|
|
|
99
111
|
// floor on the position received and a `maxCostRaw` all-in ceiling, returning the new
|
|
100
112
|
// order id (u256). Command order is pricer → auth → mint. Deployed sig
|
|
101
113
|
// `mint_exact_amount`: …, max_premium, min_quantity, max_cost, root.
|
|
114
|
+
/**
|
|
115
|
+
* @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it
|
|
116
|
+
* (`EDelayedExecutionRequired`). Use `enqueueExactAmount`.
|
|
117
|
+
*/
|
|
102
118
|
export function mintExactAmount(
|
|
103
119
|
config: GeneratedConfig,
|
|
104
120
|
args: {
|
|
@@ -111,24 +127,29 @@ export function mintExactAmount(
|
|
|
111
127
|
maxCostRaw?: bigint;
|
|
112
128
|
} & MarketFeeds,
|
|
113
129
|
): (tx: Transaction) => TransactionResult {
|
|
114
|
-
return liveTrade(config, args, (pricer) =>
|
|
115
|
-
|
|
130
|
+
return liveTrade(config, args, (pricer, auth) =>
|
|
131
|
+
expiryMarket.mintExactAmount({
|
|
116
132
|
config,
|
|
117
133
|
arguments: {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
134
|
+
Market: args.expiryMarketId,
|
|
135
|
+
Wrapper: args.wrapperId,
|
|
136
|
+
Auth: auth,
|
|
137
|
+
Pricer: pricer,
|
|
138
|
+
LowerTick: args.lowerTick,
|
|
139
|
+
HigherTick: args.higherTick,
|
|
140
|
+
MaxPremium: args.maxPremiumRaw,
|
|
141
|
+
MinQuantity: args.minQuantityRaw,
|
|
142
|
+
MaxCost: args.maxCostRaw ?? U64_MAX,
|
|
126
143
|
},
|
|
127
144
|
}),
|
|
128
145
|
);
|
|
129
146
|
}
|
|
130
147
|
|
|
131
|
-
/**
|
|
148
|
+
/**
|
|
149
|
+
* Mint within an all-in budget, including fees, using the v2 entrypoint.
|
|
150
|
+
* @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it
|
|
151
|
+
* (`EDelayedExecutionRequired`). Use `enqueueExactCost`.
|
|
152
|
+
*/
|
|
132
153
|
export function mintExactCost(
|
|
133
154
|
config: GeneratedConfig,
|
|
134
155
|
args: {
|
|
@@ -140,17 +161,18 @@ export function mintExactCost(
|
|
|
140
161
|
minQuantityRaw: bigint;
|
|
141
162
|
} & MarketFeeds,
|
|
142
163
|
): (tx: Transaction) => TransactionResult {
|
|
143
|
-
return liveTrade(config, args, (pricer) =>
|
|
144
|
-
|
|
164
|
+
return liveTrade(config, args, (pricer, auth) =>
|
|
165
|
+
expiryMarket.mintExactCost({
|
|
145
166
|
config,
|
|
146
167
|
arguments: {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
168
|
+
Market: args.expiryMarketId,
|
|
169
|
+
Wrapper: args.wrapperId,
|
|
170
|
+
Auth: auth,
|
|
171
|
+
Pricer: pricer,
|
|
172
|
+
LowerTick: args.lowerTick,
|
|
173
|
+
HigherTick: args.higherTick,
|
|
174
|
+
MaxCost: args.maxCostRaw,
|
|
175
|
+
MinQuantity: args.minQuantityRaw,
|
|
154
176
|
},
|
|
155
177
|
}),
|
|
156
178
|
);
|
|
@@ -161,6 +183,11 @@ export function mintExactCost(
|
|
|
161
183
|
// (`minProbabilityRaw`/`minProceedsRaw`, default 0 = uncapped). Returns `Option<u256>`:
|
|
162
184
|
// the replacement order id when a partial close leaves quantity open, else none. Command
|
|
163
185
|
// order is pricer → auth → redeem. Deployed sig `redeem_live`.
|
|
186
|
+
/**
|
|
187
|
+
* @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it
|
|
188
|
+
* (`EDelayedExecutionRequired`). Account positions then have no early exit; queued fills are Open
|
|
189
|
+
* records sold with `enqueueRedeemOpen`.
|
|
190
|
+
*/
|
|
164
191
|
export function redeemLive(
|
|
165
192
|
config: GeneratedConfig,
|
|
166
193
|
args: {
|
|
@@ -172,22 +199,26 @@ export function redeemLive(
|
|
|
172
199
|
minProceedsRaw?: bigint;
|
|
173
200
|
} & MarketFeeds,
|
|
174
201
|
): (tx: Transaction) => TransactionResult {
|
|
175
|
-
return liveTrade(config, args, (pricer) =>
|
|
176
|
-
|
|
202
|
+
return liveTrade(config, args, (pricer, auth) =>
|
|
203
|
+
expiryMarket.redeemLive({
|
|
177
204
|
config,
|
|
178
205
|
arguments: {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
206
|
+
Market: args.expiryMarketId,
|
|
207
|
+
Wrapper: args.wrapperId,
|
|
208
|
+
Auth: auth,
|
|
209
|
+
Pricer: pricer,
|
|
210
|
+
OrderId: args.orderId,
|
|
211
|
+
CloseQuantity: args.closeQuantityRaw,
|
|
212
|
+
MinProbability: args.minProbabilityRaw ?? 0n,
|
|
213
|
+
MinProceeds: args.minProceedsRaw ?? 0n,
|
|
186
214
|
},
|
|
187
215
|
}),
|
|
188
216
|
);
|
|
189
217
|
}
|
|
190
218
|
|
|
219
|
+
// Unchanged by delayed execution: still pays settled positions held in the account. It doesn't
|
|
220
|
+
// pay Open queue records, which the queue's `settle_step` pays at settlement.
|
|
221
|
+
//
|
|
191
222
|
// Owner-authorized redeem of a settled position: closes `orderId` IN FULL against the
|
|
192
223
|
// recorded settlement price (the deployed entrypoint takes no quantity — a settled claim
|
|
193
224
|
// is all-or-nothing). No live pricer (settlement price is fixed); auth is consumed by the
|
package/src/sessions.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { getDeployment, getUnits, TESTNET_DEPLOYMENT, TESTNET_UNITS } from './de
|
|
|
14
14
|
export type { DeployedNetwork, NetworkArg } from './deployments/index.js';
|
|
15
15
|
|
|
16
16
|
import { AccountContract } from './account.js';
|
|
17
|
+
import { deriveQueueId } from './predict/queue-id.js';
|
|
17
18
|
import type { DeepbookSessionsConfig } from './contracts/deepbook_sessions/config-arguments.js';
|
|
18
19
|
import * as sessions from './contracts/deepbook_sessions/sessions.js';
|
|
19
20
|
import { SessionsData } from './contracts/deepbook_sessions/sessions.js';
|
|
@@ -81,6 +82,49 @@ export function getSessionsConfig(
|
|
|
81
82
|
);
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
/** The market, queue, account and oracle objects every queued Predict session wrapper names. */
|
|
86
|
+
export interface SessionsQueuedOrderTarget {
|
|
87
|
+
expiryMarketId: string;
|
|
88
|
+
wrapperId: string;
|
|
89
|
+
/**
|
|
90
|
+
* The order-flow companion's shared `OrderDesk` (`deepbook_predict_orders`). Predict's
|
|
91
|
+
* `PredictConfig.objects.orderDesk`.
|
|
92
|
+
*/
|
|
93
|
+
orderDesk: string;
|
|
94
|
+
/**
|
|
95
|
+
* The order-flow companion's shared `QueueRegistry`, which every market's queue ID derives
|
|
96
|
+
* from. Predict's `PredictConfig.objects.queueRegistry`.
|
|
97
|
+
*/
|
|
98
|
+
queueRegistry: string;
|
|
99
|
+
/**
|
|
100
|
+
* The market's `MarketQueue`. Defaults to the ID derived from `queueRegistry` and the market
|
|
101
|
+
* (`deriveQueueId`), which is where `queue::create_and_share` puts it.
|
|
102
|
+
*/
|
|
103
|
+
queueId?: string;
|
|
104
|
+
/** Predict's `ProtocolConfig`. */
|
|
105
|
+
protocolConfig: string;
|
|
106
|
+
/** Predict's `OracleRegistry` (the propbook registry). */
|
|
107
|
+
oracleRegistry: string;
|
|
108
|
+
/** The market's `PythFeed`. */
|
|
109
|
+
pythFeed: string;
|
|
110
|
+
/** The market's `BlockScholesValueStore`. */
|
|
111
|
+
blockScholesValueStore: string;
|
|
112
|
+
/** The market's `BlockScholesSVIStore`. */
|
|
113
|
+
blockScholesSviStore: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const U64_MAX = (1n << 64n) - 1n;
|
|
117
|
+
|
|
118
|
+
// The chain refuses a zero or "unlimited" cap on every queued mint (`EMintCostCapRequired`).
|
|
119
|
+
function assertQueuedMaxCost(maxCost: number | bigint): void {
|
|
120
|
+
const value = BigInt(maxCost);
|
|
121
|
+
if (value <= 0n || value >= U64_MAX) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
`maxCost must be above 0 and below u64::MAX on a queued mint (EMintCostCapRequired), got ${value}`,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
84
128
|
/** The maximum session duration the contract accepts: 30 days, in milliseconds. */
|
|
85
129
|
export const MAX_SESSION_DURATION_MS = 30 * 24 * 60 * 60 * 1000;
|
|
86
130
|
|
|
@@ -276,6 +320,8 @@ export class SessionsContract {
|
|
|
276
320
|
* effectively unbounded — the chain asserts `value <= cap`, so the max value can never
|
|
277
321
|
* trip. Both are required; there is no default.
|
|
278
322
|
* @returns A function that takes a Transaction object and returns the new order id (u256)
|
|
323
|
+
* @deprecated Retired by delayed execution (DBU-885): always aborts through Predict v4
|
|
324
|
+
* (`EDelayedExecutionRequired`). Use {@link SessionsContract.enqueueExactQuantity}.
|
|
279
325
|
*/
|
|
280
326
|
mintExactQuantity(params: {
|
|
281
327
|
expiryMarketId: string;
|
|
@@ -312,6 +358,8 @@ export class SessionsContract {
|
|
|
312
358
|
* @description Mint by spending up to a premium budget, flooring the quantity received.
|
|
313
359
|
* The chain requires `maxCost > 0`.
|
|
314
360
|
* @returns A function that takes a Transaction object and returns the new order id (u256)
|
|
361
|
+
* @deprecated Retired by delayed execution (DBU-885): always aborts through Predict v4.
|
|
362
|
+
* Use {@link SessionsContract.enqueueExactAmount}.
|
|
315
363
|
*/
|
|
316
364
|
mintExactAmount(params: {
|
|
317
365
|
expiryMarketId: string;
|
|
@@ -346,7 +394,9 @@ export class SessionsContract {
|
|
|
346
394
|
|
|
347
395
|
/**
|
|
348
396
|
* Mint within an all-in budget as a session. Amounts are raw Move units.
|
|
349
|
-
* Requires Sessions/Predict v2
|
|
397
|
+
* Requires Sessions/Predict v2 or later.
|
|
398
|
+
* @deprecated Retired by delayed execution (DBU-885): always aborts through Predict v4.
|
|
399
|
+
* Use {@link SessionsContract.enqueueExactCost}.
|
|
350
400
|
*/
|
|
351
401
|
mintExactCost(params: {
|
|
352
402
|
expiryMarketId: string;
|
|
@@ -385,6 +435,9 @@ export class SessionsContract {
|
|
|
385
435
|
* unless you mean to accept whatever the mark gives you.
|
|
386
436
|
* @returns A function that takes a Transaction object and returns `Option<u256>` — the
|
|
387
437
|
* replacement order id when a partial close leaves quantity open
|
|
438
|
+
* @deprecated Retired by delayed execution (DBU-885): always aborts through Predict v4.
|
|
439
|
+
* Account positions then have no early exit; queued fills are Open records sold with
|
|
440
|
+
* {@link SessionsContract.enqueueRedeemOpen}.
|
|
388
441
|
*/
|
|
389
442
|
redeemLive(params: {
|
|
390
443
|
expiryMarketId: string;
|
|
@@ -442,6 +495,158 @@ export class SessionsContract {
|
|
|
442
495
|
};
|
|
443
496
|
}
|
|
444
497
|
|
|
498
|
+
// === Queued Predict wrappers (delayed execution, DBU-885) ===
|
|
499
|
+
//
|
|
500
|
+
// The session form of the order-flow companion's `queue::enqueue_*`, in Sessions v3. Each
|
|
501
|
+
// wrapper names the market's `MarketQueue` and the companion's `OrderDesk` next to the market.
|
|
502
|
+
// Placement takes no pricer: it reads the oracle objects directly, so each wrapper takes the
|
|
503
|
+
// market's three feed ids plus Predict's `OracleRegistry` (the propbook registry). Amounts are
|
|
504
|
+
// raw Move units. Each returns the new queue record ID (u64). The queue and Predict perform
|
|
505
|
+
// every check; the caps below are only the ones a session key should never send by accident.
|
|
506
|
+
//
|
|
507
|
+
// They need a config whose `sessionsPackageId` is a Sessions v3 publication, which both
|
|
508
|
+
// network records are. Sessions v1 and v2 have none of them.
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* @description Queue a mint of an exact payout quantity, as `session`. `maxCost` (all-in cap)
|
|
512
|
+
* and `maxProbability` (at most 1e9) are required, and the chain refuses an "unlimited"
|
|
513
|
+
* `maxCost`.
|
|
514
|
+
* @returns A function that takes a Transaction object and returns the record id (u64)
|
|
515
|
+
*/
|
|
516
|
+
enqueueExactQuantity(
|
|
517
|
+
params: SessionsQueuedOrderTarget & {
|
|
518
|
+
lowerTick: number | bigint;
|
|
519
|
+
higherTick: number | bigint;
|
|
520
|
+
quantity: number | bigint;
|
|
521
|
+
maxCost: number | bigint;
|
|
522
|
+
maxProbability: number | bigint;
|
|
523
|
+
},
|
|
524
|
+
) {
|
|
525
|
+
assertQueuedMaxCost(params.maxCost);
|
|
526
|
+
return (tx: Transaction): TransactionResult =>
|
|
527
|
+
tx.add(
|
|
528
|
+
sessions.enqueueExactQuantity({
|
|
529
|
+
config: this.#generatedConfig,
|
|
530
|
+
arguments: {
|
|
531
|
+
...this.#queuedTarget(params),
|
|
532
|
+
lowerTick: params.lowerTick,
|
|
533
|
+
higherTick: params.higherTick,
|
|
534
|
+
quantity: params.quantity,
|
|
535
|
+
maxCost: params.maxCost,
|
|
536
|
+
maxProbability: params.maxProbability,
|
|
537
|
+
},
|
|
538
|
+
}),
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* @description Queue a premium-budget mint, as `session`: sized at τ under `maxPremium`, at
|
|
544
|
+
* least `minQuantity`, with the all-in debit capped by the required `maxCost`.
|
|
545
|
+
* @returns A function that takes a Transaction object and returns the record id (u64)
|
|
546
|
+
*/
|
|
547
|
+
enqueueExactAmount(
|
|
548
|
+
params: SessionsQueuedOrderTarget & {
|
|
549
|
+
lowerTick: number | bigint;
|
|
550
|
+
higherTick: number | bigint;
|
|
551
|
+
maxPremium: number | bigint;
|
|
552
|
+
minQuantity: number | bigint;
|
|
553
|
+
maxCost: number | bigint;
|
|
554
|
+
},
|
|
555
|
+
) {
|
|
556
|
+
assertQueuedMaxCost(params.maxCost);
|
|
557
|
+
return (tx: Transaction): TransactionResult =>
|
|
558
|
+
tx.add(
|
|
559
|
+
sessions.enqueueExactAmount({
|
|
560
|
+
config: this.#generatedConfig,
|
|
561
|
+
arguments: {
|
|
562
|
+
...this.#queuedTarget(params),
|
|
563
|
+
lowerTick: params.lowerTick,
|
|
564
|
+
higherTick: params.higherTick,
|
|
565
|
+
maxPremium: params.maxPremium,
|
|
566
|
+
minQuantity: params.minQuantity,
|
|
567
|
+
maxCost: params.maxCost,
|
|
568
|
+
},
|
|
569
|
+
}),
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
/**
|
|
574
|
+
* @description Queue an all-in-budget mint, as `session`: sized at τ so the all-in cost fits
|
|
575
|
+
* `maxCost`, at least `minQuantity`.
|
|
576
|
+
* @returns A function that takes a Transaction object and returns the record id (u64)
|
|
577
|
+
*/
|
|
578
|
+
enqueueExactCost(
|
|
579
|
+
params: SessionsQueuedOrderTarget & {
|
|
580
|
+
lowerTick: number | bigint;
|
|
581
|
+
higherTick: number | bigint;
|
|
582
|
+
maxCost: number | bigint;
|
|
583
|
+
minQuantity: number | bigint;
|
|
584
|
+
},
|
|
585
|
+
) {
|
|
586
|
+
assertQueuedMaxCost(params.maxCost);
|
|
587
|
+
return (tx: Transaction): TransactionResult =>
|
|
588
|
+
tx.add(
|
|
589
|
+
sessions.enqueueExactCost({
|
|
590
|
+
config: this.#generatedConfig,
|
|
591
|
+
arguments: {
|
|
592
|
+
...this.#queuedTarget(params),
|
|
593
|
+
lowerTick: params.lowerTick,
|
|
594
|
+
higherTick: params.higherTick,
|
|
595
|
+
maxCost: params.maxCost,
|
|
596
|
+
minQuantity: params.minQuantity,
|
|
597
|
+
},
|
|
598
|
+
}),
|
|
599
|
+
);
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* @description Queue an early sell of the Open record `recordId` (its queue record ID, not
|
|
604
|
+
* the position's order ID), as `session`. `minProbability` and `minProceeds` are the close
|
|
605
|
+
* floors at τ and are required: on a delegated key, `0` closes at any price, so pass it only
|
|
606
|
+
* on purpose.
|
|
607
|
+
* @returns A function that takes a Transaction object and returns the new record id (u64)
|
|
608
|
+
*/
|
|
609
|
+
enqueueRedeemOpen(
|
|
610
|
+
params: SessionsQueuedOrderTarget & {
|
|
611
|
+
recordId: number | bigint;
|
|
612
|
+
closeQuantity: number | bigint;
|
|
613
|
+
minProbability: number | bigint;
|
|
614
|
+
minProceeds: number | bigint;
|
|
615
|
+
},
|
|
616
|
+
) {
|
|
617
|
+
return (tx: Transaction): TransactionResult =>
|
|
618
|
+
tx.add(
|
|
619
|
+
sessions.enqueueRedeemOpen({
|
|
620
|
+
config: this.#generatedConfig,
|
|
621
|
+
arguments: {
|
|
622
|
+
...this.#queuedTarget(params),
|
|
623
|
+
recordId: params.recordId,
|
|
624
|
+
closeQuantity: params.closeQuantity,
|
|
625
|
+
minProbability: params.minProbability,
|
|
626
|
+
minProceeds: params.minProceeds,
|
|
627
|
+
},
|
|
628
|
+
}),
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
// The leading arguments every queued wrapper shares, in the Move order: `(queue, market,
|
|
633
|
+
// account_registry, wrapper, sessions_config, desk, config, propbook_registry, pyth, bs_values,
|
|
634
|
+
// bs_svi, …)`. `sessions_config` comes from the generated config.
|
|
635
|
+
#queuedTarget(params: SessionsQueuedOrderTarget) {
|
|
636
|
+
return {
|
|
637
|
+
queue: params.queueId ?? deriveQueueId(params.queueRegistry, params.expiryMarketId),
|
|
638
|
+
market: params.expiryMarketId,
|
|
639
|
+
accountRegistry: this.#config.accountRegistry,
|
|
640
|
+
wrapper: params.wrapperId,
|
|
641
|
+
desk: params.orderDesk,
|
|
642
|
+
config: params.protocolConfig,
|
|
643
|
+
propbookRegistry: params.oracleRegistry,
|
|
644
|
+
pyth: params.pythFeed,
|
|
645
|
+
bsValues: params.blockScholesValueStore,
|
|
646
|
+
bsSvi: params.blockScholesSviStore,
|
|
647
|
+
};
|
|
648
|
+
}
|
|
649
|
+
|
|
445
650
|
/**
|
|
446
651
|
* @description Decode an Account's stored grants from the raw BCS content of its
|
|
447
652
|
* `DataKey<SessionsApp>` dynamic FIELD object — the whole
|