@mysten/deepbook-v3 2.4.2 → 2.5.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 +21 -0
- package/dist/contracts/account/account_events.d.mts +20 -20
- package/dist/contracts/account/account_events.d.mts.map +1 -1
- package/dist/contracts/account/account_registry.d.mts +6 -6
- 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/admin.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/builder_code.d.mts +11 -11
- package/dist/contracts/deepbook_predict/builder_code.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts +10 -10
- package/dist/contracts/deepbook_predict/config_events.d.mts +67 -67
- package/dist/contracts/deepbook_predict/expiry_market.d.mts +46 -46
- package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +3 -3
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/market_manager.d.mts +27 -27
- package/dist/contracts/deepbook_predict/market_manager.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.d.mts +50 -50
- package/dist/contracts/deepbook_predict/pause_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/pause_cap.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/plp.d.mts +72 -72
- package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/plp.mjs +1 -1
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/predict_account.d.mts +14 -14
- package/dist/contracts/deepbook_predict/predict_account.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.d.mts +92 -51
- package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.mjs +57 -7
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/protocol_config.d.mts +64 -64
- package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/range_codec.d.mts +2 -2
- package/dist/contracts/deepbook_predict/range_codec.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/registry.d.mts +28 -28
- package/dist/contracts/deepbook_predict/strike_exposure.mjs +3 -2
- package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.d.mts +105 -105
- package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
- package/dist/contracts/deepbook_sessions/sessions.d.mts +22 -22
- package/dist/deployments/mainnet.mjs +21 -21
- package/dist/deployments/mainnet.mjs.map +1 -1
- package/dist/deployments/testnet.mjs +21 -21
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/predict/index.mjs +1 -1
- package/dist/predict/reads/markets.mjs +11 -3
- package/dist/predict/reads/markets.mjs.map +1 -1
- package/dist/predict/reads/pricing.d.mts +0 -1
- package/dist/predict/reads/pricing.d.mts.map +1 -1
- package/dist/predict/reads/pricing.mjs +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/marginPool.d.mts.map +1 -1
- 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 +1 -1
- package/src/contracts/deepbook_predict/pricing.ts +88 -6
- package/src/contracts/deepbook_predict/strike_exposure.ts +3 -2
- package/src/contracts/propbook/block_scholes_store.ts +34 -0
- package/src/contracts/propbook/pyth_feed.ts +3 -1
- package/src/deployments/mainnet.ts +22 -22
- package/src/deployments/testnet.ts +22 -22
- package/src/predict/reads/markets.ts +16 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"marginTPSL.d.mts","names":[],"sources":["../../src/transactions/marginTPSL.ts"],"mappings":";;;;;;;;;cAoBa,kBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAiDO;;;;;;;EA3B3B,YAAA,GACE,OAAA,UAAiB,iBAAA,WAA4B,YAAA,uBAC7C,EAAA,EAAI,WAAA,KAAW,
|
|
1
|
+
{"version":3,"file":"marginTPSL.d.mts","names":[],"sources":["../../src/transactions/marginTPSL.ts"],"mappings":";;;;;;;;;cAoBa,kBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAiDO;;;;;;;EA3B3B,YAAA,GACE,OAAA,UAAiB,iBAAA,WAA4B,YAAA,uBAC7C,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAyI+C;;;;;;EAjHhE,oBAAA,GACE,OAAA,UAAiB,MAAA,EAAQ,uBAAA,MAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAyOa;;;;;;EAlMpF,qBAAA,GACE,OAAA,UAAiB,MAAA,EAAQ,wBAAA,MAA8B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA8PiB;;;;;EA9NzF,mBAAA,GAAuB,MAAA,EAAQ,yBAAA,MAA+B,EAAA,EAAI,WAAA;EAnGlE;;;;;EA2IA,0BAAA,GAA8B,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAzI/C;;;;;;EA6JjB,sBAAA,GACE,gBAAA,UAA0B,kBAAA,cAAgC,EAAA,EAAI,WAAA;EArIO;;;;;;;;;;;EA8JvE,wBAAA,GACE,cAAA,UAAwB,OAAA,UAAiB,kBAAA,cAAgC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAvF5B;;;;;;;;;;;;;;;;;EAgI9D,0BAAA,GACE,cAAA,UAAwB,OAAA,UAAiB,kBAAA,cAAgC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAAxF;;;;;;EAgCF,mBAAA,GAAuB,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAA7D;;;;;;;EAoBvB,gBAAA,GACE,OAAA,UAAiB,eAAA,UAAyB,kBAAA,cAAgC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAA/C;;;;;;;EAoB5C,uBAAA,GAA2B,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAAf;;;;;;;EAoBzE,wBAAA,GAA4B,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;AAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarginProposalParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions90 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/poolProxy.d.ts
|
|
@@ -20,7 +20,7 @@ declare class PoolProxyContract {
|
|
|
20
20
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a limit order
|
|
21
21
|
* @returns A function that takes a Transaction object
|
|
22
22
|
*/
|
|
23
|
-
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
23
|
+
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
24
24
|
/**
|
|
25
25
|
* @description Place a market order. Enforces a post-trade `risk_ratio >=
|
|
26
26
|
* min_borrow_risk_ratio` invariant on the manager (skipped when the manager
|
|
@@ -28,7 +28,7 @@ declare class PoolProxyContract {
|
|
|
28
28
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
29
29
|
* @returns A function that takes a Transaction object
|
|
30
30
|
*/
|
|
31
|
-
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
31
|
+
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
32
32
|
/**
|
|
33
33
|
* @description Place a reduce only limit order. Requires the manager to have
|
|
34
34
|
* debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -37,7 +37,7 @@ declare class PoolProxyContract {
|
|
|
37
37
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
38
38
|
* @returns A function that takes a Transaction object
|
|
39
39
|
*/
|
|
40
|
-
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
40
|
+
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
41
41
|
/**
|
|
42
42
|
* @description Place a reduce only market order. Requires the manager to
|
|
43
43
|
* have debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -46,7 +46,7 @@ declare class PoolProxyContract {
|
|
|
46
46
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
47
47
|
* @returns A function that takes a Transaction object
|
|
48
48
|
*/
|
|
49
|
-
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
49
|
+
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
50
50
|
/**
|
|
51
51
|
* @description Place a market order and repay the loan from the fill proceeds.
|
|
52
52
|
* The taker fill settles into the manager's balance, so the proceeds (plus any
|
|
@@ -58,7 +58,7 @@ declare class PoolProxyContract {
|
|
|
58
58
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
59
59
|
* @returns A function that takes a Transaction object
|
|
60
60
|
*/
|
|
61
|
-
placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
61
|
+
placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
62
62
|
/**
|
|
63
63
|
* @description Place a reduce only limit order and repay the loan from the
|
|
64
64
|
* fill proceeds. Requires debt on the relevant side (a bid needs base debt; an
|
|
@@ -68,7 +68,7 @@ declare class PoolProxyContract {
|
|
|
68
68
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
69
69
|
* @returns A function that takes a Transaction object
|
|
70
70
|
*/
|
|
71
|
-
placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
71
|
+
placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
72
72
|
/**
|
|
73
73
|
* @description Place a reduce only market order and repay the loan from the
|
|
74
74
|
* fill proceeds. Same reduce-only direction guard as
|
|
@@ -78,7 +78,7 @@ declare class PoolProxyContract {
|
|
|
78
78
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
79
79
|
* @returns A function that takes a Transaction object
|
|
80
80
|
*/
|
|
81
|
-
placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
81
|
+
placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions90.TransactionResult;
|
|
82
82
|
/**
|
|
83
83
|
* @description Modify an existing order
|
|
84
84
|
* @param {string} marginManagerKey The key to identify the MarginManager
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/transactions/poolProxy.ts"],"mappings":";;;;;;;;;cAmBa,iBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAoBuD;;;;;;;EAA3E,eAAA,GAAmB,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,
|
|
1
|
+
{"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/transactions/poolProxy.ts"],"mappings":";;;;;;;;;cAmBa,iBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAoBuD;;;;;;;EAA3E,eAAA,GAAmB,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA0JC;;;;;;;EArG5E,gBAAA,GAAoB,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAgQnE;;;;;;;;EAjNV,yBAAA,GAA6B,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAsZxC;;;;;;;;EAhW7C,0BAAA,GAA8B,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;;;;;;;;;;;;EAkDvF,4BAAA,GAAgC,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAvJrE;;;;;;;;;EAuMpB,qCAAA,GACE,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAnG1D;;;;;;;;;EA0JA,sCAAA,GACE,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAzGe;;;;;;;EAuJ1E,WAAA,GACE,gBAAA,UAA0B,OAAA,UAAiB,WAAA,cAAyB,EAAA,EAAI,WAAA;EAhD1E;;;;;;EA4EA,WAAA,GAAe,gBAAA,UAA0B,OAAA,cAAqB,EAAA,EAAI,WAAA;EA5BhE;;;;;;EAqDF,YAAA,GAAgB,gBAAA,UAA0B,QAAA,gBAAwB,EAAA,EAAI,WAAA;EAzB7B;;;;;EAiDzC,eAAA,GAAmB,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAxBiB;;;;;EA+CtE,sBAAA,GAA0B,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAA5D;;;;;;EAwBA,KAAA,GAAS,gBAAA,UAA0B,WAAA,cAAyB,EAAA,EAAI,WAAA;EAAA;;;;;EA0BhE,OAAA,GAAW,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAwB7C;;;;;;EAAA,cAAA,GACE,gBAAA,UAA0B,MAAA,EAAQ,oBAAA,MAA0B,EAAA,EAAI,WAAA;EA+B1D;;;;;;EAAR,IAAA,GAAQ,gBAAA,UAA0B,UAAA,cAAwB,EAAA,EAAI,WAAA;EAwBjB;;;;;EAA7C,WAAA,GAAe,gBAAA,cAA8B,EAAA,EAAI,WAAA;EA+CjD;;;;;;EAvBA,4BAAA,GACE,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA;;;;;;EAsBpD,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This module reads canonical Propbook Pyth and Block Scholes feeds and computes
|
|
9
9
|
* SVI-adjusted digital probabilities. Live reads require fresh, pricing-safe Block
|
|
10
|
-
* Scholes spot, forward, and SVI observations. The
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* Scholes spot, forward, and SVI observations. The latest forward is paired with
|
|
11
|
+
* an exact source-timestamp spot from Propbook's bounded recent history. The live
|
|
12
|
+
* forward comes from one of two admin-selected sources
|
|
13
|
+
* (`PricingConfig.use_pyth_spot_for_forward`): a fresh positive Pyth spot carrying
|
|
14
|
+
* the Block Scholes basis, or the Block Scholes forward directly. Exact-history
|
|
15
|
+
* reads do not apply live freshness policy.
|
|
14
16
|
*/
|
|
15
17
|
|
|
16
18
|
import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
|
|
@@ -65,6 +67,13 @@ export const Pricer = new MoveStruct({
|
|
|
65
67
|
block_scholes_svi_source_timestamp_ms: U64,
|
|
66
68
|
},
|
|
67
69
|
});
|
|
70
|
+
export const RangePrice = new MoveStruct({
|
|
71
|
+
name: `${$moduleName}::RangePrice`,
|
|
72
|
+
fields: {
|
|
73
|
+
lower_up: bcs.option(U64),
|
|
74
|
+
higher_up: bcs.option(U64),
|
|
75
|
+
},
|
|
76
|
+
});
|
|
68
77
|
export const RawSVI = new MoveStruct({
|
|
69
78
|
name: `${$moduleName}::RawSVI`,
|
|
70
79
|
fields: {
|
|
@@ -118,8 +127,8 @@ export interface RangePriceOptions {
|
|
|
118
127
|
};
|
|
119
128
|
}
|
|
120
129
|
/**
|
|
121
|
-
* Return
|
|
122
|
-
*
|
|
130
|
+
* Return both boundary probabilities for `(lower, higher]`. Use `probability()`
|
|
131
|
+
* for the combined range probability; absent boundaries are infinite sentinels.
|
|
123
132
|
*/
|
|
124
133
|
export function rangePrice(options: RangePriceOptions) {
|
|
125
134
|
const packageAddress =
|
|
@@ -134,3 +143,76 @@ export function rangePrice(options: RangePriceOptions) {
|
|
|
134
143
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
135
144
|
});
|
|
136
145
|
}
|
|
146
|
+
export interface LowerUpArguments {
|
|
147
|
+
price: TransactionArgument;
|
|
148
|
+
}
|
|
149
|
+
export interface LowerUpOptions {
|
|
150
|
+
package?: string;
|
|
151
|
+
arguments: LowerUpArguments | [price: TransactionArgument];
|
|
152
|
+
config?: {
|
|
153
|
+
predictPackageId?: string;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export function lowerUp(options: LowerUpOptions) {
|
|
157
|
+
const packageAddress =
|
|
158
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
159
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
160
|
+
const parameterNames = ['price'];
|
|
161
|
+
return (tx: Transaction) =>
|
|
162
|
+
tx.moveCall({
|
|
163
|
+
package: packageAddress,
|
|
164
|
+
module: 'pricing',
|
|
165
|
+
function: 'lower_up',
|
|
166
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
export interface HigherUpArguments {
|
|
170
|
+
price: TransactionArgument;
|
|
171
|
+
}
|
|
172
|
+
export interface HigherUpOptions {
|
|
173
|
+
package?: string;
|
|
174
|
+
arguments: HigherUpArguments | [price: TransactionArgument];
|
|
175
|
+
config?: {
|
|
176
|
+
predictPackageId?: string;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
export function higherUp(options: HigherUpOptions) {
|
|
180
|
+
const packageAddress =
|
|
181
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
182
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
183
|
+
const parameterNames = ['price'];
|
|
184
|
+
return (tx: Transaction) =>
|
|
185
|
+
tx.moveCall({
|
|
186
|
+
package: packageAddress,
|
|
187
|
+
module: 'pricing',
|
|
188
|
+
function: 'higher_up',
|
|
189
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
export interface ProbabilityArguments {
|
|
193
|
+
price: TransactionArgument;
|
|
194
|
+
}
|
|
195
|
+
export interface ProbabilityOptions {
|
|
196
|
+
package?: string;
|
|
197
|
+
arguments: ProbabilityArguments | [price: TransactionArgument];
|
|
198
|
+
config?: {
|
|
199
|
+
predictPackageId?: string;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Return the combined probability, floored at zero if approximated boundary prices
|
|
204
|
+
* invert.
|
|
205
|
+
*/
|
|
206
|
+
export function probability(options: ProbabilityOptions) {
|
|
207
|
+
const packageAddress =
|
|
208
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
209
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
210
|
+
const parameterNames = ['price'];
|
|
211
|
+
return (tx: Transaction) =>
|
|
212
|
+
tx.moveCall({
|
|
213
|
+
package: packageAddress,
|
|
214
|
+
module: 'pricing',
|
|
215
|
+
function: 'probability',
|
|
216
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
217
|
+
});
|
|
218
|
+
}
|
|
@@ -18,6 +18,7 @@ import { bcs } from '@mysten/sui/bcs';
|
|
|
18
18
|
import { U64 } from '../../bcs/integers.js';
|
|
19
19
|
import * as strike_exposure_config from './strike_exposure_config.js';
|
|
20
20
|
import * as strike_payout_tree from './strike_payout_tree.js';
|
|
21
|
+
import * as pricing from './pricing.js';
|
|
21
22
|
import * as order from './order.js';
|
|
22
23
|
const $moduleName = '@local-pkg/deepbook_predict::strike_exposure';
|
|
23
24
|
export const StrikeExposure = new MoveStruct({
|
|
@@ -57,7 +58,7 @@ export const MintTerms = new MoveStruct({
|
|
|
57
58
|
lower_tick: U64,
|
|
58
59
|
higher_tick: U64,
|
|
59
60
|
quantity: U64,
|
|
60
|
-
|
|
61
|
+
price: pricing.RangePrice,
|
|
61
62
|
premium: U64,
|
|
62
63
|
/** Separate inventory-impact charge, sampled against the pre-mint book. */
|
|
63
64
|
inventory_impact_charge: U64,
|
|
@@ -70,7 +71,7 @@ export const LiveCloseTerms = new MoveStruct({
|
|
|
70
71
|
order: order.Order,
|
|
71
72
|
close_quantity: U64,
|
|
72
73
|
redeem_amount: U64,
|
|
73
|
-
|
|
74
|
+
price: pricing.RangePrice,
|
|
74
75
|
/** Separate inventory-impact rebate, sampled against the pre-close book. */
|
|
75
76
|
inventory_impact_rebate: U64,
|
|
76
77
|
},
|
|
@@ -67,6 +67,10 @@ export const BlockScholesValueStore = new MoveStruct({
|
|
|
67
67
|
* advances it forward-only after a package upgrade.
|
|
68
68
|
*/
|
|
69
69
|
version: U64,
|
|
70
|
+
spot_reads: bcs.vector(BsRead(U128)),
|
|
71
|
+
/** Next slot to overwrite; also the next append position until the buffer fills. */
|
|
72
|
+
next_spot_write: U64,
|
|
73
|
+
/** Latest forward by canonical SID; spot observations live only in `spot_reads`. */
|
|
70
74
|
values: table.Table,
|
|
71
75
|
/** First positive `u64`-representable canonical spot at each exact minute boundary. */
|
|
72
76
|
exact_spot_reads: table.Table,
|
|
@@ -339,6 +343,36 @@ export function spot(options: SpotOptions) {
|
|
|
339
343
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
340
344
|
});
|
|
341
345
|
}
|
|
346
|
+
export interface RecentSpotAtArguments {
|
|
347
|
+
store: RawTransactionArgument<string>;
|
|
348
|
+
sourceTimestampMs: RawTransactionArgument<number | bigint>;
|
|
349
|
+
}
|
|
350
|
+
export interface RecentSpotAtOptions {
|
|
351
|
+
package?: string;
|
|
352
|
+
arguments:
|
|
353
|
+
| RecentSpotAtArguments
|
|
354
|
+
| [
|
|
355
|
+
store: RawTransactionArgument<string>,
|
|
356
|
+
sourceTimestampMs: RawTransactionArgument<number | bigint>,
|
|
357
|
+
];
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Returns an exact source-time match from the ten recent spot observations for
|
|
361
|
+
* live pricing. This bounded buffer is independent of the permanent
|
|
362
|
+
* minute-boundary settlement history.
|
|
363
|
+
*/
|
|
364
|
+
export function recentSpotAt(options: RecentSpotAtOptions) {
|
|
365
|
+
const packageAddress = options.package ?? '@local-pkg/propbook';
|
|
366
|
+
const argumentsTypes = [null, 'u64'] satisfies (string | null)[];
|
|
367
|
+
const parameterNames = ['store', 'sourceTimestampMs'];
|
|
368
|
+
return (tx: Transaction) =>
|
|
369
|
+
tx.moveCall({
|
|
370
|
+
package: packageAddress,
|
|
371
|
+
module: 'block_scholes_store',
|
|
372
|
+
function: 'recent_spot_at',
|
|
373
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
374
|
+
});
|
|
375
|
+
}
|
|
342
376
|
export interface SpotAtArguments {
|
|
343
377
|
store: RawTransactionArgument<string>;
|
|
344
378
|
sourceTimestampMs: RawTransactionArgument<number | bigint>;
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
* time so a carried price ages by its true age, while the exact-history key stays
|
|
16
16
|
* on the envelope so a settlement tick resolves to the canonical price as of that
|
|
17
17
|
* tick. This module normalizes positive prices to 1e9 scale but leaves freshness
|
|
18
|
-
* and market-use policy to consumers.
|
|
18
|
+
* and market-use policy to consumers. Both deployed Pyth lineages support this
|
|
19
|
+
* Update type. The legacy Testnet package has no update_v2, so retain the common
|
|
20
|
+
* ABI when linking Mainnet v2.
|
|
19
21
|
*/
|
|
20
22
|
|
|
21
23
|
import { MoveStruct, normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// checkout out to the new anchor and re-run the script.
|
|
9
9
|
//
|
|
10
10
|
// Deployment: deepbook-predict-mainnet
|
|
11
|
-
// sourceCommit:
|
|
11
|
+
// sourceCommit: 7b169bde2c2a25fee3ac9aa4686e346309bfe570
|
|
12
12
|
//
|
|
13
13
|
// Runtime-dependency-free — every subpath reads a slice of this, so a value import here
|
|
14
14
|
// would pull that module into all of their graphs. The type import below is erased.
|
|
@@ -29,13 +29,13 @@ export const MAINNET_DEPLOYMENT: DeploymentInfo = Object.freeze({
|
|
|
29
29
|
deployment: 'deepbook-predict-mainnet',
|
|
30
30
|
network: 'mainnet',
|
|
31
31
|
chainId: '35834a8a',
|
|
32
|
-
sourceCommit: '
|
|
32
|
+
sourceCommit: '7b169bde2c2a25fee3ac9aa4686e346309bfe570',
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
/** Ids for the shared `account` primitive — the `/account` subpath's slice. */
|
|
36
36
|
export const MAINNET_ACCOUNT: AccountIds = Object.freeze({
|
|
37
|
-
accountPackageId: '
|
|
38
|
-
accountRegistry: '
|
|
37
|
+
accountPackageId: '0x4e1dd01465713c9d832313fed5f45c222a4d5c62a533d6da96764c8b2a245d58',
|
|
38
|
+
accountRegistry: '0x8c52c6f5b2374e33f4a726d9c32337b1aee3a71410d41c18faa91d938d66e4bc',
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -46,15 +46,15 @@ export const MAINNET_ACCOUNT: AccountIds = Object.freeze({
|
|
|
46
46
|
* the package root for one id.
|
|
47
47
|
*/
|
|
48
48
|
export const MAINNET_SESSIONS: SessionsIds = Object.freeze({
|
|
49
|
-
sessionsPackageId: '
|
|
50
|
-
sessionsConfig: '
|
|
51
|
-
accountPackageId: '
|
|
52
|
-
accountRegistry: '
|
|
49
|
+
sessionsPackageId: '0x9a068beffa019ae756f4a6d2611e9899d3c6dd888812dd9eca87535d2ac55e2a',
|
|
50
|
+
sessionsConfig: '0xb2fba483748aac7508676020d4e691d68239b66f8bf7c5e7634dd1a76a329317',
|
|
51
|
+
accountPackageId: '0x4e1dd01465713c9d832313fed5f45c222a4d5c62a533d6da96764c8b2a245d58',
|
|
52
|
+
accountRegistry: '0x8c52c6f5b2374e33f4a726d9c32337b1aee3a71410d41c18faa91d938d66e4bc',
|
|
53
53
|
deepbookRegistry: '0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d',
|
|
54
54
|
deepbookCoreAccountPackageId:
|
|
55
|
-
'
|
|
55
|
+
'0xd71b5a341dc8dc7e187517849edf61e54670b60fe496e07186c09a65fa7afdb7',
|
|
56
56
|
/** Required by every Predict session wrapper — they all take `config: &ProtocolConfig`. */
|
|
57
|
-
protocolConfig: '
|
|
57
|
+
protocolConfig: '0x5fa6efbe7691809565a660adde23f0c184ca1d19cefafa4e1c88d655fe279580',
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -73,16 +73,16 @@ export const MAINNET_UNITS: DeploymentUnits = Object.freeze({
|
|
|
73
73
|
export const MAINNET_PREDICT: PredictIds = Object.freeze({
|
|
74
74
|
network: 'mainnet',
|
|
75
75
|
packages: Object.freeze({
|
|
76
|
-
predict: '
|
|
77
|
-
account: '
|
|
78
|
-
propbook: '
|
|
76
|
+
predict: '0x89aea622e7bb3bdd598bde87dde40ee31c9eed4971b9546e23ec83de3c48bbba',
|
|
77
|
+
account: '0x4e1dd01465713c9d832313fed5f45c222a4d5c62a533d6da96764c8b2a245d58',
|
|
78
|
+
propbook: '0xa6c8f32015b5b41d34ee09995a2e9d7a21cdecf0e1910a50b264fd252cd33831',
|
|
79
79
|
}),
|
|
80
80
|
objects: Object.freeze({
|
|
81
|
-
registry: '
|
|
82
|
-
protocolConfig: '
|
|
83
|
-
poolVault: '
|
|
84
|
-
oracleRegistry: '
|
|
85
|
-
accountRegistry: '
|
|
81
|
+
registry: '0x94327dbc256a2cfabd164c2bf4b3fe033bfaa4771f7a6f716954e07cb1b4beba',
|
|
82
|
+
protocolConfig: '0x5fa6efbe7691809565a660adde23f0c184ca1d19cefafa4e1c88d655fe279580',
|
|
83
|
+
poolVault: '0x4d227a1baf8cfcaf6e652a9182d0e63f85f9ce82cd542fdf3356bb3581be3b99',
|
|
84
|
+
oracleRegistry: '0x5d62c0d9be43efa769a708ade53fbe5bea98c15c865b64ca7c498c87b045a698',
|
|
85
|
+
accountRegistry: '0x8c52c6f5b2374e33f4a726d9c32337b1aee3a71410d41c18faa91d938d66e4bc',
|
|
86
86
|
}),
|
|
87
87
|
quoteCoinType: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',
|
|
88
88
|
/**
|
|
@@ -91,7 +91,7 @@ export const MAINNET_PREDICT: PredictIds = Object.freeze({
|
|
|
91
91
|
* moves to the latest. They agree only while predict is at v1.
|
|
92
92
|
*/
|
|
93
93
|
coinTypes: Object.freeze({
|
|
94
|
-
plp: '
|
|
94
|
+
plp: '0x89aea622e7bb3bdd598bde87dde40ee31c9eed4971b9546e23ec83de3c48bbba::plp::PLP',
|
|
95
95
|
deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP',
|
|
96
96
|
}),
|
|
97
97
|
units: MAINNET_UNITS,
|
|
@@ -99,9 +99,9 @@ export const MAINNET_PREDICT: PredictIds = Object.freeze({
|
|
|
99
99
|
BTC: Object.freeze({
|
|
100
100
|
symbol: 'BTC',
|
|
101
101
|
propbookUnderlyingId: 1,
|
|
102
|
-
pythFeed: '
|
|
103
|
-
blockScholesValueStore: '
|
|
104
|
-
blockScholesSviStore: '
|
|
102
|
+
pythFeed: '0x4c5d2b4c8238f04b7687c3a8df915b69c50d5f4d291fc49aea44bdb6b52e1a20',
|
|
103
|
+
blockScholesValueStore: '0xe83f843b15ae63045b2cea445fb8ea7ad85c5fc2a05f66db122a511e1f2c67bc',
|
|
104
|
+
blockScholesSviStore: '0xfdd447be39d847747caf18ecf3355031bb33979c472581f1a5481375d3748bfb',
|
|
105
105
|
}),
|
|
106
106
|
}),
|
|
107
107
|
});
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// checkout out to the new anchor and re-run the script.
|
|
9
9
|
//
|
|
10
10
|
// Deployment: deepbook-predict-testnet
|
|
11
|
-
// sourceCommit:
|
|
11
|
+
// sourceCommit: 4d752fb82d909a821c85bcc5d3963725efb546f4
|
|
12
12
|
//
|
|
13
13
|
// Runtime-dependency-free — every subpath reads a slice of this, so a value import here
|
|
14
14
|
// would pull that module into all of their graphs. The type import below is erased.
|
|
@@ -29,13 +29,13 @@ export const TESTNET_DEPLOYMENT: DeploymentInfo = Object.freeze({
|
|
|
29
29
|
deployment: 'deepbook-predict-testnet',
|
|
30
30
|
network: 'testnet',
|
|
31
31
|
chainId: '4c78adac',
|
|
32
|
-
sourceCommit: '
|
|
32
|
+
sourceCommit: '4d752fb82d909a821c85bcc5d3963725efb546f4',
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
/** Ids for the shared `account` primitive — the `/account` subpath's slice. */
|
|
36
36
|
export const TESTNET_ACCOUNT: AccountIds = Object.freeze({
|
|
37
|
-
accountPackageId: '
|
|
38
|
-
accountRegistry: '
|
|
37
|
+
accountPackageId: '0x1e57d6554b99e4ca68330322c3e5c409ba1b681642726b603bf1be92c1840ca9',
|
|
38
|
+
accountRegistry: '0x511e11f7f5d5c1043d795180657603d59e06e90fbfcafd3f90c67ff0836bbd0c',
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -46,15 +46,15 @@ export const TESTNET_ACCOUNT: AccountIds = Object.freeze({
|
|
|
46
46
|
* the package root for one id.
|
|
47
47
|
*/
|
|
48
48
|
export const TESTNET_SESSIONS: SessionsIds = Object.freeze({
|
|
49
|
-
sessionsPackageId: '
|
|
50
|
-
sessionsConfig: '
|
|
51
|
-
accountPackageId: '
|
|
52
|
-
accountRegistry: '
|
|
49
|
+
sessionsPackageId: '0x1908eee49d7a08d74a537d7f23766b363a145517fe0d3e0d85635d1682831ffd',
|
|
50
|
+
sessionsConfig: '0xc096b97289821b27badfdf758d614bbbfa386f93d3faa409ecc1fcc6075d1186',
|
|
51
|
+
accountPackageId: '0x1e57d6554b99e4ca68330322c3e5c409ba1b681642726b603bf1be92c1840ca9',
|
|
52
|
+
accountRegistry: '0x511e11f7f5d5c1043d795180657603d59e06e90fbfcafd3f90c67ff0836bbd0c',
|
|
53
53
|
deepbookRegistry: '0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1',
|
|
54
54
|
deepbookCoreAccountPackageId:
|
|
55
|
-
'
|
|
55
|
+
'0x2a3a5f51e1c566e0a77c667596a8212d036b44aeac32790991c9eb97580fabb1',
|
|
56
56
|
/** Required by every Predict session wrapper — they all take `config: &ProtocolConfig`. */
|
|
57
|
-
protocolConfig: '
|
|
57
|
+
protocolConfig: '0x422a45c31128e69d0310ab3bed28bd14f730acf9f5681f70936d20c60d26bfb0',
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -73,16 +73,16 @@ export const TESTNET_UNITS: DeploymentUnits = Object.freeze({
|
|
|
73
73
|
export const TESTNET_PREDICT: PredictIds = Object.freeze({
|
|
74
74
|
network: 'testnet',
|
|
75
75
|
packages: Object.freeze({
|
|
76
|
-
predict: '
|
|
77
|
-
account: '
|
|
78
|
-
propbook: '
|
|
76
|
+
predict: '0x59d71119e990573a738dd3ff9c4c7d28d6893af69c87c1a7f3a2e90e280ce2f4',
|
|
77
|
+
account: '0x1e57d6554b99e4ca68330322c3e5c409ba1b681642726b603bf1be92c1840ca9',
|
|
78
|
+
propbook: '0xa83f9d7651de09672a40cea371c387bf954e0f3092947670d71428d4fbc9edd9',
|
|
79
79
|
}),
|
|
80
80
|
objects: Object.freeze({
|
|
81
|
-
registry: '
|
|
82
|
-
protocolConfig: '
|
|
83
|
-
poolVault: '
|
|
84
|
-
oracleRegistry: '
|
|
85
|
-
accountRegistry: '
|
|
81
|
+
registry: '0x85cfaa857f9dfca75f6ba624eead063c4a1bc9b701201b8f21e1f9c15833ccc4',
|
|
82
|
+
protocolConfig: '0x422a45c31128e69d0310ab3bed28bd14f730acf9f5681f70936d20c60d26bfb0',
|
|
83
|
+
poolVault: '0x6fd178a49848387d60ccfd3e53bf06969929970246a3a7983ae5bb2a5ed52ee3',
|
|
84
|
+
oracleRegistry: '0xf4ad65184b2e4e9d8e50d44b02a76c64e9607f63e3dbc362e110c99e20a17161',
|
|
85
|
+
accountRegistry: '0x511e11f7f5d5c1043d795180657603d59e06e90fbfcafd3f90c67ff0836bbd0c',
|
|
86
86
|
}),
|
|
87
87
|
quoteCoinType: '0xc028557a1ed49e42ed091e115aedefd70a442b184c18fbec5c48d5b6c0b8c184::usdc::USDC',
|
|
88
88
|
/**
|
|
@@ -91,7 +91,7 @@ export const TESTNET_PREDICT: PredictIds = Object.freeze({
|
|
|
91
91
|
* moves to the latest. They agree only while predict is at v1.
|
|
92
92
|
*/
|
|
93
93
|
coinTypes: Object.freeze({
|
|
94
|
-
plp: '
|
|
94
|
+
plp: '0x59d71119e990573a738dd3ff9c4c7d28d6893af69c87c1a7f3a2e90e280ce2f4::plp::PLP',
|
|
95
95
|
deep: '0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP',
|
|
96
96
|
}),
|
|
97
97
|
units: TESTNET_UNITS,
|
|
@@ -99,9 +99,9 @@ export const TESTNET_PREDICT: PredictIds = Object.freeze({
|
|
|
99
99
|
BTC: Object.freeze({
|
|
100
100
|
symbol: 'BTC',
|
|
101
101
|
propbookUnderlyingId: 1,
|
|
102
|
-
pythFeed: '
|
|
103
|
-
blockScholesValueStore: '
|
|
104
|
-
blockScholesSviStore: '
|
|
102
|
+
pythFeed: '0x8ef99c3d14e57612d09a67bcc9b5bff568a80992df6beca2bfcd922973192faa',
|
|
103
|
+
blockScholesValueStore: '0x1e5142471311505a7428b072230c9ffe8a747b3b9392720e39246af4aea08216',
|
|
104
|
+
blockScholesSviStore: '0x0f1cbefd1dd2ba08ae700a7067c32e0718edf926fa18cea80bd231c02d509ece',
|
|
105
105
|
}),
|
|
106
106
|
}),
|
|
107
107
|
});
|
|
@@ -123,6 +123,12 @@ export async function marketStates(
|
|
|
123
123
|
// POS_INF_TICK → +inf, and any finite tick → tick*tick_size. `range_price` is a
|
|
124
124
|
// public fun on the deployed package. Both sides read the SAME pricer in one PTB, so
|
|
125
125
|
// `down` is the chain's number, not 1 − up.
|
|
126
|
+
//
|
|
127
|
+
// `range_price` now returns a `RangePrice` carrying both boundary probabilities so the
|
|
128
|
+
// fee can charge each leg separately; `probability()` is the combined range number this
|
|
129
|
+
// function has always returned (`lower_up.saturating_sub(higher_up)`, unchanged). The
|
|
130
|
+
// extra call per side is what keeps the u64 parse below reading a u64 rather than the
|
|
131
|
+
// struct's BCS.
|
|
126
132
|
export async function rangePrices(
|
|
127
133
|
client: ReadClient,
|
|
128
134
|
config: GeneratedConfig,
|
|
@@ -141,9 +147,16 @@ export async function rangePrices(
|
|
|
141
147
|
const strike = mkStrike(strikeTick);
|
|
142
148
|
const posInf = mkStrike(POS_INF_TICK);
|
|
143
149
|
const negInf = mkStrike(0n);
|
|
144
|
-
// UP: (strike, +inf], then DOWN: (-inf, strike]
|
|
145
|
-
|
|
146
|
-
tx.add(
|
|
150
|
+
// UP: (strike, +inf], then DOWN: (-inf, strike]. The two `probability` reductions are
|
|
151
|
+
// the last two commands, which is what the tail-relative parse below indexes.
|
|
152
|
+
const up = tx.add(
|
|
153
|
+
pricing.rangePrice({ config, arguments: { pricer, lower: strike, higher: posInf } }),
|
|
154
|
+
);
|
|
155
|
+
const down = tx.add(
|
|
156
|
+
pricing.rangePrice({ config, arguments: { pricer, lower: negInf, higher: strike } }),
|
|
157
|
+
);
|
|
158
|
+
tx.add(pricing.probability({ config, arguments: { price: up } }));
|
|
159
|
+
tx.add(pricing.probability({ config, arguments: { price: down } }));
|
|
147
160
|
const cmds = await inspectReturns(client, tx);
|
|
148
161
|
return {
|
|
149
162
|
upRaw: parseU64LE(cmds[cmds.length - 2][0]),
|