@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
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { normalizeMoveArguments } from "../utils/index.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/contracts/deepbook_predict_math/math.ts
|
|
5
|
+
var math_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
builderFee: () => builderFee,
|
|
7
|
+
digital: () => digital,
|
|
8
|
+
inputsOk: () => inputsOk,
|
|
9
|
+
legFee: () => legFee,
|
|
10
|
+
maxQty: () => maxQty,
|
|
11
|
+
needBudget: () => needBudget,
|
|
12
|
+
needQty: () => needQty,
|
|
13
|
+
needSell: () => needSell,
|
|
14
|
+
orderTerms: () => orderTerms,
|
|
15
|
+
potential: () => potential,
|
|
16
|
+
rawVarOk: () => rawVarOk,
|
|
17
|
+
rollDown: () => rollDown,
|
|
18
|
+
varPositive: () => varPositive
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Scale one 1e9-scaled SVI magnitude down by the fraction of anchored time
|
|
22
|
+
* remaining, returning it at 1e18.
|
|
23
|
+
*
|
|
24
|
+
* The roll-down result is kept at 1e18 because the fraction is applied to values
|
|
25
|
+
* that are themselves tiny on short-dated surfaces: a 1e9 floor here costs up to a
|
|
26
|
+
* whole raw unit of `a`, and a short-dated `a` is only about ten raw units, so the
|
|
27
|
+
* truncation alone moves the digital by percent-scale amounts. At 1e18 the same
|
|
28
|
+
* floor is a billionth of that.
|
|
29
|
+
*
|
|
30
|
+
* The `u256` intermediate keeps the product exact for any `expiry_ms` rather than
|
|
31
|
+
* relying on a bound on the anchored horizon. The result is at most
|
|
32
|
+
* `value * 1e9 < 2^64 * 1e9`, so narrowing to `u128` never truncates.
|
|
33
|
+
*/
|
|
34
|
+
function rollDown(options) {
|
|
35
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
36
|
+
const argumentsTypes = [
|
|
37
|
+
"u64",
|
|
38
|
+
"u64",
|
|
39
|
+
"u64"
|
|
40
|
+
];
|
|
41
|
+
const parameterNames = [
|
|
42
|
+
"value",
|
|
43
|
+
"remainingMs",
|
|
44
|
+
"anchorTteMs"
|
|
45
|
+
];
|
|
46
|
+
return (tx) => tx.moveCall({
|
|
47
|
+
package: packageAddress,
|
|
48
|
+
module: "math",
|
|
49
|
+
function: "roll_down",
|
|
50
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The adjusted UP digital for `strike` on a rolled SVI surface (`a` and `b` at
|
|
55
|
+
* 1e18, `rho`, `m`, and `sigma` at 1e9) and `forward`:
|
|
56
|
+
*
|
|
57
|
+
* - k = ln(strike / forward)
|
|
58
|
+
* - w(k) = a + b * (rho * (k - m) + sqrt((k - m)^2 + sigma^2))
|
|
59
|
+
* - d2 = -((k + w(k) / 2) / sqrt(w(k)))
|
|
60
|
+
* - price = N(d2) - phi(d2) * w'(k) / (2 * sqrt(w(k)))
|
|
61
|
+
*
|
|
62
|
+
* Returns the price and `0`, or `none` and the code Predict aborts with where the
|
|
63
|
+
* formula is undefined: a zero forward, a negative inner term, or a non-positive
|
|
64
|
+
* variance.
|
|
65
|
+
*/
|
|
66
|
+
function digital(options) {
|
|
67
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
68
|
+
const argumentsTypes = [
|
|
69
|
+
"u128",
|
|
70
|
+
"bool",
|
|
71
|
+
"u128",
|
|
72
|
+
null,
|
|
73
|
+
null,
|
|
74
|
+
"u64",
|
|
75
|
+
"u64",
|
|
76
|
+
"u64"
|
|
77
|
+
];
|
|
78
|
+
const parameterNames = [
|
|
79
|
+
"aMagnitude",
|
|
80
|
+
"aIsNegative",
|
|
81
|
+
"b",
|
|
82
|
+
"rho",
|
|
83
|
+
"m",
|
|
84
|
+
"sigma",
|
|
85
|
+
"forward",
|
|
86
|
+
"strike"
|
|
87
|
+
];
|
|
88
|
+
return (tx) => tx.moveCall({
|
|
89
|
+
package: packageAddress,
|
|
90
|
+
module: "math",
|
|
91
|
+
function: "digital",
|
|
92
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether a rolled surface's minimum total variance over all strikes is positive,
|
|
97
|
+
* at the 1e18 the rolled `a` and `b` are carried in.
|
|
98
|
+
*/
|
|
99
|
+
function varPositive(options) {
|
|
100
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
101
|
+
const argumentsTypes = [
|
|
102
|
+
"u128",
|
|
103
|
+
"bool",
|
|
104
|
+
"u128",
|
|
105
|
+
null,
|
|
106
|
+
"u64"
|
|
107
|
+
];
|
|
108
|
+
const parameterNames = [
|
|
109
|
+
"aMagnitude",
|
|
110
|
+
"aIsNegative",
|
|
111
|
+
"b",
|
|
112
|
+
"rho",
|
|
113
|
+
"sigma"
|
|
114
|
+
];
|
|
115
|
+
return (tx) => tx.moveCall({
|
|
116
|
+
package: packageAddress,
|
|
117
|
+
module: "math",
|
|
118
|
+
function: "var_positive",
|
|
119
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Whether raw Block Scholes inputs fit Predict's pricing-safe envelope: a positive
|
|
124
|
+
* spot and forward, `forward <= max_spot` and `forward <= 100 * spot`, and SVI
|
|
125
|
+
* `b`, `|rho|`, `|m|`, and `sigma` within their bounds. `a` carries no bound of
|
|
126
|
+
* its own: only total variance has to be positive (`raw_var_ok`), and every
|
|
127
|
+
* downstream use of `a` fits its provider width.
|
|
128
|
+
*/
|
|
129
|
+
function inputsOk(options) {
|
|
130
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
131
|
+
const argumentsTypes = [
|
|
132
|
+
"u64",
|
|
133
|
+
"u64",
|
|
134
|
+
"u64",
|
|
135
|
+
null,
|
|
136
|
+
null,
|
|
137
|
+
"u64"
|
|
138
|
+
];
|
|
139
|
+
const parameterNames = [
|
|
140
|
+
"spot",
|
|
141
|
+
"forward",
|
|
142
|
+
"b",
|
|
143
|
+
"rho",
|
|
144
|
+
"m",
|
|
145
|
+
"sigma"
|
|
146
|
+
];
|
|
147
|
+
return (tx) => tx.moveCall({
|
|
148
|
+
package: packageAddress,
|
|
149
|
+
module: "math",
|
|
150
|
+
function: "inputs_ok",
|
|
151
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Whether a raw SVI tuple's minimum total variance
|
|
156
|
+
* `a + b * sigma * sqrt(1 - rho^2)` is positive, compared rather than summed: `a`
|
|
157
|
+
* reaches `u64::MAX`, where the sum would leave `u64`.
|
|
158
|
+
*/
|
|
159
|
+
function rawVarOk(options) {
|
|
160
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
161
|
+
const argumentsTypes = [
|
|
162
|
+
null,
|
|
163
|
+
"u64",
|
|
164
|
+
null,
|
|
165
|
+
"u64"
|
|
166
|
+
];
|
|
167
|
+
const parameterNames = [
|
|
168
|
+
"a",
|
|
169
|
+
"b",
|
|
170
|
+
"rho",
|
|
171
|
+
"sigma"
|
|
172
|
+
];
|
|
173
|
+
return (tx) => tx.moveCall({
|
|
174
|
+
package: packageAddress,
|
|
175
|
+
module: "math",
|
|
176
|
+
function: "raw_var_ok",
|
|
177
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* One finite leg's trading fee: `max(bernoulli(p), min_fee) * ramp * quantity`,
|
|
182
|
+
* each product rounded down. `bernoulli(p) = base_fee * sqrt(p * (1 - p))`, zero
|
|
183
|
+
* at `p = 0` or `1`; the caller checks `p <= 1`. The ramp is 1 at or beyond
|
|
184
|
+
* `window_ms` to expiry and rises linearly to `max_multiplier` at expiry, rounded
|
|
185
|
+
* down so the trader keeps the ramp dust.
|
|
186
|
+
*/
|
|
187
|
+
function legFee(options) {
|
|
188
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
189
|
+
const argumentsTypes = [
|
|
190
|
+
"u64",
|
|
191
|
+
"u64",
|
|
192
|
+
"u64",
|
|
193
|
+
"u64",
|
|
194
|
+
"u64",
|
|
195
|
+
"u64",
|
|
196
|
+
"u64"
|
|
197
|
+
];
|
|
198
|
+
const parameterNames = [
|
|
199
|
+
"baseFee",
|
|
200
|
+
"minFee",
|
|
201
|
+
"windowMs",
|
|
202
|
+
"maxMultiplier",
|
|
203
|
+
"probability",
|
|
204
|
+
"quantity",
|
|
205
|
+
"timeToExpiryMs"
|
|
206
|
+
];
|
|
207
|
+
return (tx) => tx.moveCall({
|
|
208
|
+
package: packageAddress,
|
|
209
|
+
module: "math",
|
|
210
|
+
function: "leg_fee",
|
|
211
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The inventory-impact potential of `liability`: the marginal rate rises linearly
|
|
216
|
+
* from zero to `max_rate` over `scale`, then stays capped:
|
|
217
|
+
*
|
|
218
|
+
* `phi(L) = r_max * L^2 / (2B)` for `L <= B` `phi(L) = phi(B) + r_max * (L - B)`
|
|
219
|
+
* for `L > B`.
|
|
220
|
+
*
|
|
221
|
+
* Defined by this exact sequence of rounded integer operations, so charges and
|
|
222
|
+
* rebates, which always subtract two evaluations, telescope exactly.
|
|
223
|
+
*/
|
|
224
|
+
function potential(options) {
|
|
225
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
226
|
+
const argumentsTypes = [
|
|
227
|
+
"u64",
|
|
228
|
+
"u64",
|
|
229
|
+
"u64"
|
|
230
|
+
];
|
|
231
|
+
const parameterNames = [
|
|
232
|
+
"maxRate",
|
|
233
|
+
"scale",
|
|
234
|
+
"liability"
|
|
235
|
+
];
|
|
236
|
+
return (tx) => tx.moveCall({
|
|
237
|
+
package: packageAddress,
|
|
238
|
+
module: "math",
|
|
239
|
+
function: "potential",
|
|
240
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* The largest whole number of `lot`s, at most `max_lots`, whose premium
|
|
245
|
+
* `mul_down(probability, quantity)` fits `max_premium`, as a quantity. The probe
|
|
246
|
+
* is the premium mint admission charges, so the result is exact, and an oversized
|
|
247
|
+
* budget saturates at `max_lots` instead of aborting.
|
|
248
|
+
*/
|
|
249
|
+
function maxQty(options) {
|
|
250
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
251
|
+
const argumentsTypes = [
|
|
252
|
+
"u64",
|
|
253
|
+
"u64",
|
|
254
|
+
"u64",
|
|
255
|
+
"u64"
|
|
256
|
+
];
|
|
257
|
+
const parameterNames = [
|
|
258
|
+
"probability",
|
|
259
|
+
"maxPremium",
|
|
260
|
+
"lot",
|
|
261
|
+
"maxLots"
|
|
262
|
+
];
|
|
263
|
+
return (tx) => tx.moveCall({
|
|
264
|
+
package: packageAddress,
|
|
265
|
+
module: "math",
|
|
266
|
+
function: "max_qty",
|
|
267
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* The builder fee on a trade with a builder code: `fee_amount * multiplier`,
|
|
272
|
+
* capped at `quantity * max_rate`, each rounded down.
|
|
273
|
+
*/
|
|
274
|
+
function builderFee(options) {
|
|
275
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
276
|
+
const argumentsTypes = [
|
|
277
|
+
"u64",
|
|
278
|
+
"u64",
|
|
279
|
+
"u64",
|
|
280
|
+
"u64"
|
|
281
|
+
];
|
|
282
|
+
const parameterNames = [
|
|
283
|
+
"feeAmount",
|
|
284
|
+
"quantity",
|
|
285
|
+
"multiplier",
|
|
286
|
+
"maxRate"
|
|
287
|
+
];
|
|
288
|
+
return (tx) => tx.moveCall({
|
|
289
|
+
package: packageAddress,
|
|
290
|
+
module: "math",
|
|
291
|
+
function: "builder_fee",
|
|
292
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Exact-quantity mint cash need: `ceil(quantity * (1 - p)) + 1`, where `p` is the
|
|
297
|
+
* market's minimum entry probability: a fill pays at least `p` per contract into
|
|
298
|
+
* market cash.
|
|
299
|
+
*/
|
|
300
|
+
function needQty(options) {
|
|
301
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
302
|
+
const argumentsTypes = ["u64", "u64"];
|
|
303
|
+
const parameterNames = ["quantity", "p"];
|
|
304
|
+
return (tx) => tx.moveCall({
|
|
305
|
+
package: packageAddress,
|
|
306
|
+
module: "math",
|
|
307
|
+
function: "need_qty",
|
|
308
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Budget mint cash need: `ceil((budget + 1) * (1 / p - 1)) + 1`. The `budget + 1`
|
|
313
|
+
* covers premiums rounding down, which lets a fill buy up to `1 / p` raw units
|
|
314
|
+
* more than `budget / p`.
|
|
315
|
+
*/
|
|
316
|
+
function needBudget(options) {
|
|
317
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
318
|
+
const argumentsTypes = ["u64", "u64"];
|
|
319
|
+
const parameterNames = ["budget", "p"];
|
|
320
|
+
return (tx) => tx.moveCall({
|
|
321
|
+
package: packageAddress,
|
|
322
|
+
module: "math",
|
|
323
|
+
function: "need_budget",
|
|
324
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Sell cash need: `ceil(close_quantity * (1 - lambda)) + 1`. A close lowers payout
|
|
329
|
+
* liability by at least `lambda * close_quantity` and pays at most
|
|
330
|
+
* `close_quantity`.
|
|
331
|
+
*/
|
|
332
|
+
function needSell(options) {
|
|
333
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
334
|
+
const argumentsTypes = ["u64", "u64"];
|
|
335
|
+
const parameterNames = ["closeQuantity", "lambda"];
|
|
336
|
+
return (tx) => tx.moveCall({
|
|
337
|
+
package: packageAddress,
|
|
338
|
+
module: "math",
|
|
339
|
+
function: "need_sell",
|
|
340
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Decode a packed Predict order ID into `(lower_tick, higher_tick, quantity)`,
|
|
345
|
+
* with the quantity in USDC base units. For the order-flow companion's sell sizing
|
|
346
|
+
* and remainder checks over order IDs Predict issued: it validates nothing. The
|
|
347
|
+
* layout is Predict's frozen order-ID encoding: 30-bit ticks at bits 70 and 40,
|
|
348
|
+
* and a 32-bit count of 10_000-unit lots at bit 100.
|
|
349
|
+
*/
|
|
350
|
+
function orderTerms(options) {
|
|
351
|
+
const packageAddress = options.package ?? options.config?.predictMathPackageId ?? "@local-pkg/deepbook_predict_math";
|
|
352
|
+
const argumentsTypes = ["u256"];
|
|
353
|
+
const parameterNames = ["orderId"];
|
|
354
|
+
return (tx) => tx.moveCall({
|
|
355
|
+
package: packageAddress,
|
|
356
|
+
module: "math",
|
|
357
|
+
function: "order_terms",
|
|
358
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames)
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
//#endregion
|
|
363
|
+
export { math_exports };
|
|
364
|
+
//# sourceMappingURL=math.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"math.mjs","names":[],"sources":["../../../src/contracts/deepbook_predict_math/math.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\n\n/**\n * Pure pricing math for Predict, moved out of `deepbook_predict` so the package\n * stays under Sui's object-size limit.\n *\n * Every function takes and returns primitives (and `fixed_math` values) and reads\n * no state, so it cannot move value or see an object. Each body is Predict's own\n * code, moved unchanged: SVI evaluation and the roll-down, the pricing-safe input\n * bounds and minimum-variance checks as booleans, the Bernoulli trading-fee curve\n * with its expiry ramp, the inventory-impact potential, premium sizing, the\n * builder fee, and the order-flow cash-need formulas. Predict keeps every abort:\n * where a check here fails, it returns a boolean or `none`, and Predict asserts\n * with its own error code.\n */\n\nimport { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';\nimport { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';\nexport interface RollDownArguments {\n\tvalue: RawTransactionArgument<number | bigint>;\n\tremainingMs: RawTransactionArgument<number | bigint>;\n\tanchorTteMs: RawTransactionArgument<number | bigint>;\n}\nexport interface RollDownOptions {\n\tpackage?: string;\n\targuments:\n\t\t| RollDownArguments\n\t\t| [\n\t\t\t\tvalue: RawTransactionArgument<number | bigint>,\n\t\t\t\tremainingMs: RawTransactionArgument<number | bigint>,\n\t\t\t\tanchorTteMs: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * Scale one 1e9-scaled SVI magnitude down by the fraction of anchored time\n * remaining, returning it at 1e18.\n *\n * The roll-down result is kept at 1e18 because the fraction is applied to values\n * that are themselves tiny on short-dated surfaces: a 1e9 floor here costs up to a\n * whole raw unit of `a`, and a short-dated `a` is only about ten raw units, so the\n * truncation alone moves the digital by percent-scale amounts. At 1e18 the same\n * floor is a billionth of that.\n *\n * The `u256` intermediate keeps the product exact for any `expiry_ms` rather than\n * relying on a bound on the anchored horizon. The result is at most\n * `value * 1e9 < 2^64 * 1e9`, so narrowing to `u128` never truncates.\n */\nexport function rollDown(options: RollDownOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u64', 'u64', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['value', 'remainingMs', 'anchorTteMs'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'roll_down',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface DigitalArguments {\n\taMagnitude: RawTransactionArgument<number | bigint>;\n\taIsNegative: RawTransactionArgument<boolean>;\n\tb: RawTransactionArgument<number | bigint>;\n\trho: TransactionArgument;\n\tm: TransactionArgument;\n\tsigma: RawTransactionArgument<number | bigint>;\n\tforward: RawTransactionArgument<number | bigint>;\n\tstrike: RawTransactionArgument<number | bigint>;\n}\nexport interface DigitalOptions {\n\tpackage?: string;\n\targuments:\n\t\t| DigitalArguments\n\t\t| [\n\t\t\t\taMagnitude: RawTransactionArgument<number | bigint>,\n\t\t\t\taIsNegative: RawTransactionArgument<boolean>,\n\t\t\t\tb: RawTransactionArgument<number | bigint>,\n\t\t\t\trho: TransactionArgument,\n\t\t\t\tm: TransactionArgument,\n\t\t\t\tsigma: RawTransactionArgument<number | bigint>,\n\t\t\t\tforward: RawTransactionArgument<number | bigint>,\n\t\t\t\tstrike: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * The adjusted UP digital for `strike` on a rolled SVI surface (`a` and `b` at\n * 1e18, `rho`, `m`, and `sigma` at 1e9) and `forward`:\n *\n * - k = ln(strike / forward)\n * - w(k) = a + b * (rho * (k - m) + sqrt((k - m)^2 + sigma^2))\n * - d2 = -((k + w(k) / 2) / sqrt(w(k)))\n * - price = N(d2) - phi(d2) * w'(k) / (2 * sqrt(w(k)))\n *\n * Returns the price and `0`, or `none` and the code Predict aborts with where the\n * formula is undefined: a zero forward, a negative inner term, or a non-positive\n * variance.\n */\nexport function digital(options: DigitalOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u128', 'bool', 'u128', null, null, 'u64', 'u64', 'u64'] satisfies (\n\t\tstring | null\n\t)[];\n\tconst parameterNames = [\n\t\t'aMagnitude',\n\t\t'aIsNegative',\n\t\t'b',\n\t\t'rho',\n\t\t'm',\n\t\t'sigma',\n\t\t'forward',\n\t\t'strike',\n\t];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'digital',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface VarPositiveArguments {\n\taMagnitude: RawTransactionArgument<number | bigint>;\n\taIsNegative: RawTransactionArgument<boolean>;\n\tb: RawTransactionArgument<number | bigint>;\n\trho: TransactionArgument;\n\tsigma: RawTransactionArgument<number | bigint>;\n}\nexport interface VarPositiveOptions {\n\tpackage?: string;\n\targuments:\n\t\t| VarPositiveArguments\n\t\t| [\n\t\t\t\taMagnitude: RawTransactionArgument<number | bigint>,\n\t\t\t\taIsNegative: RawTransactionArgument<boolean>,\n\t\t\t\tb: RawTransactionArgument<number | bigint>,\n\t\t\t\trho: TransactionArgument,\n\t\t\t\tsigma: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * Whether a rolled surface's minimum total variance over all strikes is positive,\n * at the 1e18 the rolled `a` and `b` are carried in.\n */\nexport function varPositive(options: VarPositiveOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u128', 'bool', 'u128', null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['aMagnitude', 'aIsNegative', 'b', 'rho', 'sigma'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'var_positive',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface InputsOkArguments {\n\tspot: RawTransactionArgument<number | bigint>;\n\tforward: RawTransactionArgument<number | bigint>;\n\tb: RawTransactionArgument<number | bigint>;\n\trho: TransactionArgument;\n\tm: TransactionArgument;\n\tsigma: RawTransactionArgument<number | bigint>;\n}\nexport interface InputsOkOptions {\n\tpackage?: string;\n\targuments:\n\t\t| InputsOkArguments\n\t\t| [\n\t\t\t\tspot: RawTransactionArgument<number | bigint>,\n\t\t\t\tforward: RawTransactionArgument<number | bigint>,\n\t\t\t\tb: RawTransactionArgument<number | bigint>,\n\t\t\t\trho: TransactionArgument,\n\t\t\t\tm: TransactionArgument,\n\t\t\t\tsigma: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * Whether raw Block Scholes inputs fit Predict's pricing-safe envelope: a positive\n * spot and forward, `forward <= max_spot` and `forward <= 100 * spot`, and SVI\n * `b`, `|rho|`, `|m|`, and `sigma` within their bounds. `a` carries no bound of\n * its own: only total variance has to be positive (`raw_var_ok`), and every\n * downstream use of `a` fits its provider width.\n */\nexport function inputsOk(options: InputsOkOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u64', 'u64', 'u64', null, null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['spot', 'forward', 'b', 'rho', 'm', 'sigma'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'inputs_ok',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface RawVarOkArguments {\n\ta: TransactionArgument;\n\tb: RawTransactionArgument<number | bigint>;\n\trho: TransactionArgument;\n\tsigma: RawTransactionArgument<number | bigint>;\n}\nexport interface RawVarOkOptions {\n\tpackage?: string;\n\targuments:\n\t\t| RawVarOkArguments\n\t\t| [\n\t\t\t\ta: TransactionArgument,\n\t\t\t\tb: RawTransactionArgument<number | bigint>,\n\t\t\t\trho: TransactionArgument,\n\t\t\t\tsigma: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * Whether a raw SVI tuple's minimum total variance\n * `a + b * sigma * sqrt(1 - rho^2)` is positive, compared rather than summed: `a`\n * reaches `u64::MAX`, where the sum would leave `u64`.\n */\nexport function rawVarOk(options: RawVarOkOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = [null, 'u64', null, 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['a', 'b', 'rho', 'sigma'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'raw_var_ok',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface LegFeeArguments {\n\tbaseFee: RawTransactionArgument<number | bigint>;\n\tminFee: RawTransactionArgument<number | bigint>;\n\twindowMs: RawTransactionArgument<number | bigint>;\n\tmaxMultiplier: RawTransactionArgument<number | bigint>;\n\tprobability: RawTransactionArgument<number | bigint>;\n\tquantity: RawTransactionArgument<number | bigint>;\n\ttimeToExpiryMs: RawTransactionArgument<number | bigint>;\n}\nexport interface LegFeeOptions {\n\tpackage?: string;\n\targuments:\n\t\t| LegFeeArguments\n\t\t| [\n\t\t\t\tbaseFee: RawTransactionArgument<number | bigint>,\n\t\t\t\tminFee: RawTransactionArgument<number | bigint>,\n\t\t\t\twindowMs: RawTransactionArgument<number | bigint>,\n\t\t\t\tmaxMultiplier: RawTransactionArgument<number | bigint>,\n\t\t\t\tprobability: RawTransactionArgument<number | bigint>,\n\t\t\t\tquantity: RawTransactionArgument<number | bigint>,\n\t\t\t\ttimeToExpiryMs: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * One finite leg's trading fee: `max(bernoulli(p), min_fee) * ramp * quantity`,\n * each product rounded down. `bernoulli(p) = base_fee * sqrt(p * (1 - p))`, zero\n * at `p = 0` or `1`; the caller checks `p <= 1`. The ramp is 1 at or beyond\n * `window_ms` to expiry and rises linearly to `max_multiplier` at expiry, rounded\n * down so the trader keeps the ramp dust.\n */\nexport function legFee(options: LegFeeOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u64', 'u64', 'u64', 'u64', 'u64', 'u64', 'u64'] satisfies (\n\t\tstring | null\n\t)[];\n\tconst parameterNames = [\n\t\t'baseFee',\n\t\t'minFee',\n\t\t'windowMs',\n\t\t'maxMultiplier',\n\t\t'probability',\n\t\t'quantity',\n\t\t'timeToExpiryMs',\n\t];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'leg_fee',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface PotentialArguments {\n\tmaxRate: RawTransactionArgument<number | bigint>;\n\tscale: RawTransactionArgument<number | bigint>;\n\tliability: RawTransactionArgument<number | bigint>;\n}\nexport interface PotentialOptions {\n\tpackage?: string;\n\targuments:\n\t\t| PotentialArguments\n\t\t| [\n\t\t\t\tmaxRate: RawTransactionArgument<number | bigint>,\n\t\t\t\tscale: RawTransactionArgument<number | bigint>,\n\t\t\t\tliability: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * The inventory-impact potential of `liability`: the marginal rate rises linearly\n * from zero to `max_rate` over `scale`, then stays capped:\n *\n * `phi(L) = r_max * L^2 / (2B)` for `L <= B` `phi(L) = phi(B) + r_max * (L - B)`\n * for `L > B`.\n *\n * Defined by this exact sequence of rounded integer operations, so charges and\n * rebates, which always subtract two evaluations, telescope exactly.\n */\nexport function potential(options: PotentialOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u64', 'u64', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['maxRate', 'scale', 'liability'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'potential',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface MaxQtyArguments {\n\tprobability: RawTransactionArgument<number | bigint>;\n\tmaxPremium: RawTransactionArgument<number | bigint>;\n\tlot: RawTransactionArgument<number | bigint>;\n\tmaxLots: RawTransactionArgument<number | bigint>;\n}\nexport interface MaxQtyOptions {\n\tpackage?: string;\n\targuments:\n\t\t| MaxQtyArguments\n\t\t| [\n\t\t\t\tprobability: RawTransactionArgument<number | bigint>,\n\t\t\t\tmaxPremium: RawTransactionArgument<number | bigint>,\n\t\t\t\tlot: RawTransactionArgument<number | bigint>,\n\t\t\t\tmaxLots: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * The largest whole number of `lot`s, at most `max_lots`, whose premium\n * `mul_down(probability, quantity)` fits `max_premium`, as a quantity. The probe\n * is the premium mint admission charges, so the result is exact, and an oversized\n * budget saturates at `max_lots` instead of aborting.\n */\nexport function maxQty(options: MaxQtyOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u64', 'u64', 'u64', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['probability', 'maxPremium', 'lot', 'maxLots'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'max_qty',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface BuilderFeeArguments {\n\tfeeAmount: RawTransactionArgument<number | bigint>;\n\tquantity: RawTransactionArgument<number | bigint>;\n\tmultiplier: RawTransactionArgument<number | bigint>;\n\tmaxRate: RawTransactionArgument<number | bigint>;\n}\nexport interface BuilderFeeOptions {\n\tpackage?: string;\n\targuments:\n\t\t| BuilderFeeArguments\n\t\t| [\n\t\t\t\tfeeAmount: RawTransactionArgument<number | bigint>,\n\t\t\t\tquantity: RawTransactionArgument<number | bigint>,\n\t\t\t\tmultiplier: RawTransactionArgument<number | bigint>,\n\t\t\t\tmaxRate: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * The builder fee on a trade with a builder code: `fee_amount * multiplier`,\n * capped at `quantity * max_rate`, each rounded down.\n */\nexport function builderFee(options: BuilderFeeOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u64', 'u64', 'u64', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['feeAmount', 'quantity', 'multiplier', 'maxRate'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'builder_fee',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NeedQtyArguments {\n\tquantity: RawTransactionArgument<number | bigint>;\n\tp: RawTransactionArgument<number | bigint>;\n}\nexport interface NeedQtyOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NeedQtyArguments\n\t\t| [\n\t\t\t\tquantity: RawTransactionArgument<number | bigint>,\n\t\t\t\tp: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * Exact-quantity mint cash need: `ceil(quantity * (1 - p)) + 1`, where `p` is the\n * market's minimum entry probability: a fill pays at least `p` per contract into\n * market cash.\n */\nexport function needQty(options: NeedQtyOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u64', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['quantity', 'p'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'need_qty',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NeedBudgetArguments {\n\tbudget: RawTransactionArgument<number | bigint>;\n\tp: RawTransactionArgument<number | bigint>;\n}\nexport interface NeedBudgetOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NeedBudgetArguments\n\t\t| [budget: RawTransactionArgument<number | bigint>, p: RawTransactionArgument<number | bigint>];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * Budget mint cash need: `ceil((budget + 1) * (1 / p - 1)) + 1`. The `budget + 1`\n * covers premiums rounding down, which lets a fill buy up to `1 / p` raw units\n * more than `budget / p`.\n */\nexport function needBudget(options: NeedBudgetOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u64', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['budget', 'p'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'need_budget',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface NeedSellArguments {\n\tcloseQuantity: RawTransactionArgument<number | bigint>;\n\tlambda: RawTransactionArgument<number | bigint>;\n}\nexport interface NeedSellOptions {\n\tpackage?: string;\n\targuments:\n\t\t| NeedSellArguments\n\t\t| [\n\t\t\t\tcloseQuantity: RawTransactionArgument<number | bigint>,\n\t\t\t\tlambda: RawTransactionArgument<number | bigint>,\n\t\t ];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * Sell cash need: `ceil(close_quantity * (1 - lambda)) + 1`. A close lowers payout\n * liability by at least `lambda * close_quantity` and pays at most\n * `close_quantity`.\n */\nexport function needSell(options: NeedSellOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u64', 'u64'] satisfies (string | null)[];\n\tconst parameterNames = ['closeQuantity', 'lambda'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'need_sell',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\nexport interface OrderTermsArguments {\n\torderId: RawTransactionArgument<number | bigint>;\n}\nexport interface OrderTermsOptions {\n\tpackage?: string;\n\targuments: OrderTermsArguments | [orderId: RawTransactionArgument<number | bigint>];\n\tconfig?: {\n\t\tpredictMathPackageId?: string;\n\t};\n}\n/**\n * Decode a packed Predict order ID into `(lower_tick, higher_tick, quantity)`,\n * with the quantity in USDC base units. For the order-flow companion's sell sizing\n * and remainder checks over order IDs Predict issued: it validates nothing. The\n * layout is Predict's frozen order-ID encoding: 30-bit ticks at bits 70 and 40,\n * and a 32-bit count of 10_000-unit lots at bit 100.\n */\nexport function orderTerms(options: OrderTermsOptions) {\n\tconst packageAddress =\n\t\toptions.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';\n\tconst argumentsTypes = ['u256'] satisfies (string | null)[];\n\tconst parameterNames = ['orderId'];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'math',\n\t\t\tfunction: 'order_terms',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),\n\t\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,SAAgB,SAAS,SAA0B;CAClD,MAAM,iBACL,QAAQ,WAAW,QAAQ,QAAQ,wBAAwB;CAC5D,MAAM,iBAAiB;EAAC;EAAO;EAAO;EAAM;CAC5C,MAAM,iBAAiB;EAAC;EAAS;EAAe;EAAc;AAC9D,SAA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,QAAQ,WAAW,QAAQ,QAAQ,wBAAwB;CAC5D,MAAM,iBAAiB,CAAC,OAAO;CAC/B,MAAM,iBAAiB,CAAC,UAAU;AAClC,SAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,gBAAgB,eAAe;EACpF,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ConfigValue } from "../utils/index.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/contracts/deepbook_predict_orders/config-arguments.d.ts
|
|
4
|
+
interface DeepbookPredictOrdersConfig {
|
|
5
|
+
predictOrdersPackageId?: string;
|
|
6
|
+
orderDesk: ConfigValue;
|
|
7
|
+
queueRegistry: ConfigValue;
|
|
8
|
+
protocolConfig: ConfigValue;
|
|
9
|
+
oracleRegistry: ConfigValue;
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { DeepbookPredictOrdersConfig };
|
|
13
|
+
//# sourceMappingURL=config-arguments.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-arguments.d.mts","names":[],"sources":["../../../src/contracts/deepbook_predict_orders/config-arguments.ts"],"mappings":";;;UAIiB,2BAAA;EAChB,sBAAA;EACA,SAAA,EAAW,WAAA;EACX,aAAA,EAAe,WAAA;EACf,cAAA,EAAgB,WAAA;EAChB,cAAA,EAAgB,WAAA;AAAA"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
+
import * as _mysten_sui_bcs476 from "@mysten/sui/bcs";
|
|
3
|
+
import * as _mysten_sui_transactions261 from "@mysten/sui/transactions";
|
|
4
|
+
import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
|
|
5
|
+
|
|
6
|
+
//#region src/contracts/deepbook_predict_orders/delayed_execution_config.d.ts
|
|
7
|
+
declare namespace delayed_execution_config_d_exports {
|
|
8
|
+
export { DelayMsArguments, DelayMsOptions, DelayedExecutionPolicy, GapWaitMsArguments, GapWaitMsOptions, MinSellQuantityArguments, MinSellQuantityOptions, MintCapacityArguments, MintCapacityOptions, OrderFeeArguments, OrderFeeOptions, PerAccountCapArguments, PerAccountCapOptions, PythChannelArguments, PythChannelOptions, PythPriceBufferMsArguments, PythPriceBufferMsOptions, SellCapacityArguments, SellCapacityOptions, SettlePayoutBatchArguments, SettlePayoutBatchOptions, SettleRefundBatchArguments, SettleRefundBatchOptions, StallTimeoutMsArguments, StallTimeoutMsOptions, StuckThresholdMsArguments, StuckThresholdMsOptions, SviMaxAgeMsArguments, SviMaxAgeMsOptions, delayMs, gapWaitMs, minSellQuantity, mintCapacity, orderFee, perAccountCap, pythChannel, pythPriceBufferMs, sellCapacity, settlePayoutBatch, settleRefundBatch, stallTimeoutMs, stuckThresholdMs, sviMaxAgeMs };
|
|
9
|
+
}
|
|
10
|
+
declare const DelayedExecutionPolicy: MoveStruct<{
|
|
11
|
+
/**
|
|
12
|
+
* Latest τ may fall after placement. τ rounds down to the policy channel's tick at
|
|
13
|
+
* or before `t₀ + delay_ms`.
|
|
14
|
+
*/
|
|
15
|
+
delay_ms: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">;
|
|
16
|
+
/**
|
|
17
|
+
* Sets each order's deadline:
|
|
18
|
+
* `max(min(τ + stall_timeout_ms, expiry), last deadline)`. At or past it the
|
|
19
|
+
* order is refunded, never filled.
|
|
20
|
+
*/
|
|
21
|
+
stall_timeout_ms: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">;
|
|
22
|
+
/**
|
|
23
|
+
* Placement refuses new orders while an uncommitted cohort is this far past its τ
|
|
24
|
+
* with nothing newer committed, or while two or more uncommitted cohorts are each
|
|
25
|
+
* this far past their τ.
|
|
26
|
+
*/
|
|
27
|
+
stuck_threshold_ms: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">; /** Commit accepts a backup tick for a cohort only once now is this far past its τ. */
|
|
28
|
+
gap_wait_ms: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">;
|
|
29
|
+
/**
|
|
30
|
+
* Switches the backup tick on or off. `0` accepts only the update stamped exactly
|
|
31
|
+
* τ. Above `0`, once now is `gap_wait_ms` past τ, a cohort also accepts its single
|
|
32
|
+
* backup: the update stamped one tick of its own stored channel after τ. The value
|
|
33
|
+
* is not a window: the setter keeps it at `0` or one tick of the policy channel.
|
|
34
|
+
*/
|
|
35
|
+
pyth_price_buffer_ms: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">;
|
|
36
|
+
/**
|
|
37
|
+
* Pyth Lazer channel new orders are priced on: `2` (`fixed_rate@50ms`) or `3`
|
|
38
|
+
* (`fixed_rate@200ms`). Its tick period is τ's grid. Each order stores the channel
|
|
39
|
+
* it was placed under.
|
|
40
|
+
*/
|
|
41
|
+
pyth_channel: _mysten_sui_bcs476.BcsType<number, number, "u8">;
|
|
42
|
+
/**
|
|
43
|
+
* Oldest Block Scholes SVI a placement accepts into an order's volatility
|
|
44
|
+
* snapshot.
|
|
45
|
+
*/
|
|
46
|
+
svi_max_age_ms: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">; /** Most unfinished queued mints per market. */
|
|
47
|
+
mint_capacity: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">; /** Most unfinished queued sells per market. */
|
|
48
|
+
sell_capacity: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">; /** Most unfinished queued orders per account per market. */
|
|
49
|
+
per_account_cap: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">;
|
|
50
|
+
/**
|
|
51
|
+
* Flat fee charged at placement. Kept on a fill and on limit or admission refunds;
|
|
52
|
+
* returned on every other refund.
|
|
53
|
+
*/
|
|
54
|
+
order_fee: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">; /** Smallest early-sell close quantity. */
|
|
55
|
+
min_sell_quantity: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">; /** Most records one `settle_step` call visits while refunding leftover orders. */
|
|
56
|
+
settle_refund_batch: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">; /** Most records one `settle_step` call visits while paying Open records. */
|
|
57
|
+
settle_payout_batch: _mysten_sui_bcs476.BcsType<bigint, string | number | bigint, "u64">;
|
|
58
|
+
}, "@local-pkg/deepbook_predict_orders::delayed_execution_config::DelayedExecutionPolicy">;
|
|
59
|
+
interface DelayMsArguments {
|
|
60
|
+
policy: TransactionArgument;
|
|
61
|
+
}
|
|
62
|
+
interface DelayMsOptions {
|
|
63
|
+
package?: string;
|
|
64
|
+
arguments: DelayMsArguments | [policy: TransactionArgument];
|
|
65
|
+
config?: {
|
|
66
|
+
predictOrdersPackageId?: string;
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
declare function delayMs(options: DelayMsOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
70
|
+
interface StallTimeoutMsArguments {
|
|
71
|
+
policy: TransactionArgument;
|
|
72
|
+
}
|
|
73
|
+
interface StallTimeoutMsOptions {
|
|
74
|
+
package?: string;
|
|
75
|
+
arguments: StallTimeoutMsArguments | [policy: TransactionArgument];
|
|
76
|
+
config?: {
|
|
77
|
+
predictOrdersPackageId?: string;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
declare function stallTimeoutMs(options: StallTimeoutMsOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
81
|
+
interface StuckThresholdMsArguments {
|
|
82
|
+
policy: TransactionArgument;
|
|
83
|
+
}
|
|
84
|
+
interface StuckThresholdMsOptions {
|
|
85
|
+
package?: string;
|
|
86
|
+
arguments: StuckThresholdMsArguments | [policy: TransactionArgument];
|
|
87
|
+
config?: {
|
|
88
|
+
predictOrdersPackageId?: string;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
declare function stuckThresholdMs(options: StuckThresholdMsOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
92
|
+
interface GapWaitMsArguments {
|
|
93
|
+
policy: TransactionArgument;
|
|
94
|
+
}
|
|
95
|
+
interface GapWaitMsOptions {
|
|
96
|
+
package?: string;
|
|
97
|
+
arguments: GapWaitMsArguments | [policy: TransactionArgument];
|
|
98
|
+
config?: {
|
|
99
|
+
predictOrdersPackageId?: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
declare function gapWaitMs(options: GapWaitMsOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
103
|
+
interface PythPriceBufferMsArguments {
|
|
104
|
+
policy: TransactionArgument;
|
|
105
|
+
}
|
|
106
|
+
interface PythPriceBufferMsOptions {
|
|
107
|
+
package?: string;
|
|
108
|
+
arguments: PythPriceBufferMsArguments | [policy: TransactionArgument];
|
|
109
|
+
config?: {
|
|
110
|
+
predictOrdersPackageId?: string;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
declare function pythPriceBufferMs(options: PythPriceBufferMsOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
114
|
+
interface PythChannelArguments {
|
|
115
|
+
policy: TransactionArgument;
|
|
116
|
+
}
|
|
117
|
+
interface PythChannelOptions {
|
|
118
|
+
package?: string;
|
|
119
|
+
arguments: PythChannelArguments | [policy: TransactionArgument];
|
|
120
|
+
config?: {
|
|
121
|
+
predictOrdersPackageId?: string;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
declare function pythChannel(options: PythChannelOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
125
|
+
interface SviMaxAgeMsArguments {
|
|
126
|
+
policy: TransactionArgument;
|
|
127
|
+
}
|
|
128
|
+
interface SviMaxAgeMsOptions {
|
|
129
|
+
package?: string;
|
|
130
|
+
arguments: SviMaxAgeMsArguments | [policy: TransactionArgument];
|
|
131
|
+
config?: {
|
|
132
|
+
predictOrdersPackageId?: string;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
declare function sviMaxAgeMs(options: SviMaxAgeMsOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
136
|
+
interface MintCapacityArguments {
|
|
137
|
+
policy: TransactionArgument;
|
|
138
|
+
}
|
|
139
|
+
interface MintCapacityOptions {
|
|
140
|
+
package?: string;
|
|
141
|
+
arguments: MintCapacityArguments | [policy: TransactionArgument];
|
|
142
|
+
config?: {
|
|
143
|
+
predictOrdersPackageId?: string;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
declare function mintCapacity(options: MintCapacityOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
147
|
+
interface SellCapacityArguments {
|
|
148
|
+
policy: TransactionArgument;
|
|
149
|
+
}
|
|
150
|
+
interface SellCapacityOptions {
|
|
151
|
+
package?: string;
|
|
152
|
+
arguments: SellCapacityArguments | [policy: TransactionArgument];
|
|
153
|
+
config?: {
|
|
154
|
+
predictOrdersPackageId?: string;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
declare function sellCapacity(options: SellCapacityOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
158
|
+
interface PerAccountCapArguments {
|
|
159
|
+
policy: TransactionArgument;
|
|
160
|
+
}
|
|
161
|
+
interface PerAccountCapOptions {
|
|
162
|
+
package?: string;
|
|
163
|
+
arguments: PerAccountCapArguments | [policy: TransactionArgument];
|
|
164
|
+
config?: {
|
|
165
|
+
predictOrdersPackageId?: string;
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
declare function perAccountCap(options: PerAccountCapOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
169
|
+
interface OrderFeeArguments {
|
|
170
|
+
policy: TransactionArgument;
|
|
171
|
+
}
|
|
172
|
+
interface OrderFeeOptions {
|
|
173
|
+
package?: string;
|
|
174
|
+
arguments: OrderFeeArguments | [policy: TransactionArgument];
|
|
175
|
+
config?: {
|
|
176
|
+
predictOrdersPackageId?: string;
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
declare function orderFee(options: OrderFeeOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
180
|
+
interface MinSellQuantityArguments {
|
|
181
|
+
policy: TransactionArgument;
|
|
182
|
+
}
|
|
183
|
+
interface MinSellQuantityOptions {
|
|
184
|
+
package?: string;
|
|
185
|
+
arguments: MinSellQuantityArguments | [policy: TransactionArgument];
|
|
186
|
+
config?: {
|
|
187
|
+
predictOrdersPackageId?: string;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
declare function minSellQuantity(options: MinSellQuantityOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
191
|
+
interface SettleRefundBatchArguments {
|
|
192
|
+
policy: TransactionArgument;
|
|
193
|
+
}
|
|
194
|
+
interface SettleRefundBatchOptions {
|
|
195
|
+
package?: string;
|
|
196
|
+
arguments: SettleRefundBatchArguments | [policy: TransactionArgument];
|
|
197
|
+
config?: {
|
|
198
|
+
predictOrdersPackageId?: string;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
declare function settleRefundBatch(options: SettleRefundBatchOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
202
|
+
interface SettlePayoutBatchArguments {
|
|
203
|
+
policy: TransactionArgument;
|
|
204
|
+
}
|
|
205
|
+
interface SettlePayoutBatchOptions {
|
|
206
|
+
package?: string;
|
|
207
|
+
arguments: SettlePayoutBatchArguments | [policy: TransactionArgument];
|
|
208
|
+
config?: {
|
|
209
|
+
predictOrdersPackageId?: string;
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
declare function settlePayoutBatch(options: SettlePayoutBatchOptions): (tx: Transaction) => _mysten_sui_transactions261.TransactionResult;
|
|
213
|
+
//#endregion
|
|
214
|
+
export { DelayedExecutionPolicy, delayed_execution_config_d_exports };
|
|
215
|
+
//# sourceMappingURL=delayed_execution_config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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