@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,553 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Pure pricing math for Predict, moved out of `deepbook_predict` so the package
|
|
7
|
+
* stays under Sui's object-size limit.
|
|
8
|
+
*
|
|
9
|
+
* Every function takes and returns primitives (and `fixed_math` values) and reads
|
|
10
|
+
* no state, so it cannot move value or see an object. Each body is Predict's own
|
|
11
|
+
* code, moved unchanged: SVI evaluation and the roll-down, the pricing-safe input
|
|
12
|
+
* bounds and minimum-variance checks as booleans, the Bernoulli trading-fee curve
|
|
13
|
+
* with its expiry ramp, the inventory-impact potential, premium sizing, the
|
|
14
|
+
* builder fee, and the order-flow cash-need formulas. Predict keeps every abort:
|
|
15
|
+
* where a check here fails, it returns a boolean or `none`, and Predict asserts
|
|
16
|
+
* with its own error code.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
20
|
+
import { normalizeMoveArguments, type RawTransactionArgument } from '../utils/index.js';
|
|
21
|
+
export interface RollDownArguments {
|
|
22
|
+
value: RawTransactionArgument<number | bigint>;
|
|
23
|
+
remainingMs: RawTransactionArgument<number | bigint>;
|
|
24
|
+
anchorTteMs: RawTransactionArgument<number | bigint>;
|
|
25
|
+
}
|
|
26
|
+
export interface RollDownOptions {
|
|
27
|
+
package?: string;
|
|
28
|
+
arguments:
|
|
29
|
+
| RollDownArguments
|
|
30
|
+
| [
|
|
31
|
+
value: RawTransactionArgument<number | bigint>,
|
|
32
|
+
remainingMs: RawTransactionArgument<number | bigint>,
|
|
33
|
+
anchorTteMs: RawTransactionArgument<number | bigint>,
|
|
34
|
+
];
|
|
35
|
+
config?: {
|
|
36
|
+
predictMathPackageId?: string;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Scale one 1e9-scaled SVI magnitude down by the fraction of anchored time
|
|
41
|
+
* remaining, returning it at 1e18.
|
|
42
|
+
*
|
|
43
|
+
* The roll-down result is kept at 1e18 because the fraction is applied to values
|
|
44
|
+
* that are themselves tiny on short-dated surfaces: a 1e9 floor here costs up to a
|
|
45
|
+
* whole raw unit of `a`, and a short-dated `a` is only about ten raw units, so the
|
|
46
|
+
* truncation alone moves the digital by percent-scale amounts. At 1e18 the same
|
|
47
|
+
* floor is a billionth of that.
|
|
48
|
+
*
|
|
49
|
+
* The `u256` intermediate keeps the product exact for any `expiry_ms` rather than
|
|
50
|
+
* relying on a bound on the anchored horizon. The result is at most
|
|
51
|
+
* `value * 1e9 < 2^64 * 1e9`, so narrowing to `u128` never truncates.
|
|
52
|
+
*/
|
|
53
|
+
export function rollDown(options: RollDownOptions) {
|
|
54
|
+
const packageAddress =
|
|
55
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
56
|
+
const argumentsTypes = ['u64', 'u64', 'u64'] satisfies (string | null)[];
|
|
57
|
+
const parameterNames = ['value', 'remainingMs', 'anchorTteMs'];
|
|
58
|
+
return (tx: Transaction) =>
|
|
59
|
+
tx.moveCall({
|
|
60
|
+
package: packageAddress,
|
|
61
|
+
module: 'math',
|
|
62
|
+
function: 'roll_down',
|
|
63
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
export interface DigitalArguments {
|
|
67
|
+
aMagnitude: RawTransactionArgument<number | bigint>;
|
|
68
|
+
aIsNegative: RawTransactionArgument<boolean>;
|
|
69
|
+
b: RawTransactionArgument<number | bigint>;
|
|
70
|
+
rho: TransactionArgument;
|
|
71
|
+
m: TransactionArgument;
|
|
72
|
+
sigma: RawTransactionArgument<number | bigint>;
|
|
73
|
+
forward: RawTransactionArgument<number | bigint>;
|
|
74
|
+
strike: RawTransactionArgument<number | bigint>;
|
|
75
|
+
}
|
|
76
|
+
export interface DigitalOptions {
|
|
77
|
+
package?: string;
|
|
78
|
+
arguments:
|
|
79
|
+
| DigitalArguments
|
|
80
|
+
| [
|
|
81
|
+
aMagnitude: RawTransactionArgument<number | bigint>,
|
|
82
|
+
aIsNegative: RawTransactionArgument<boolean>,
|
|
83
|
+
b: RawTransactionArgument<number | bigint>,
|
|
84
|
+
rho: TransactionArgument,
|
|
85
|
+
m: TransactionArgument,
|
|
86
|
+
sigma: RawTransactionArgument<number | bigint>,
|
|
87
|
+
forward: RawTransactionArgument<number | bigint>,
|
|
88
|
+
strike: RawTransactionArgument<number | bigint>,
|
|
89
|
+
];
|
|
90
|
+
config?: {
|
|
91
|
+
predictMathPackageId?: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* The adjusted UP digital for `strike` on a rolled SVI surface (`a` and `b` at
|
|
96
|
+
* 1e18, `rho`, `m`, and `sigma` at 1e9) and `forward`:
|
|
97
|
+
*
|
|
98
|
+
* - k = ln(strike / forward)
|
|
99
|
+
* - w(k) = a + b * (rho * (k - m) + sqrt((k - m)^2 + sigma^2))
|
|
100
|
+
* - d2 = -((k + w(k) / 2) / sqrt(w(k)))
|
|
101
|
+
* - price = N(d2) - phi(d2) * w'(k) / (2 * sqrt(w(k)))
|
|
102
|
+
*
|
|
103
|
+
* Returns the price and `0`, or `none` and the code Predict aborts with where the
|
|
104
|
+
* formula is undefined: a zero forward, a negative inner term, or a non-positive
|
|
105
|
+
* variance.
|
|
106
|
+
*/
|
|
107
|
+
export function digital(options: DigitalOptions) {
|
|
108
|
+
const packageAddress =
|
|
109
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
110
|
+
const argumentsTypes = ['u128', 'bool', 'u128', null, null, 'u64', 'u64', 'u64'] satisfies (
|
|
111
|
+
string | null
|
|
112
|
+
)[];
|
|
113
|
+
const parameterNames = [
|
|
114
|
+
'aMagnitude',
|
|
115
|
+
'aIsNegative',
|
|
116
|
+
'b',
|
|
117
|
+
'rho',
|
|
118
|
+
'm',
|
|
119
|
+
'sigma',
|
|
120
|
+
'forward',
|
|
121
|
+
'strike',
|
|
122
|
+
];
|
|
123
|
+
return (tx: Transaction) =>
|
|
124
|
+
tx.moveCall({
|
|
125
|
+
package: packageAddress,
|
|
126
|
+
module: 'math',
|
|
127
|
+
function: 'digital',
|
|
128
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
export interface VarPositiveArguments {
|
|
132
|
+
aMagnitude: RawTransactionArgument<number | bigint>;
|
|
133
|
+
aIsNegative: RawTransactionArgument<boolean>;
|
|
134
|
+
b: RawTransactionArgument<number | bigint>;
|
|
135
|
+
rho: TransactionArgument;
|
|
136
|
+
sigma: RawTransactionArgument<number | bigint>;
|
|
137
|
+
}
|
|
138
|
+
export interface VarPositiveOptions {
|
|
139
|
+
package?: string;
|
|
140
|
+
arguments:
|
|
141
|
+
| VarPositiveArguments
|
|
142
|
+
| [
|
|
143
|
+
aMagnitude: RawTransactionArgument<number | bigint>,
|
|
144
|
+
aIsNegative: RawTransactionArgument<boolean>,
|
|
145
|
+
b: RawTransactionArgument<number | bigint>,
|
|
146
|
+
rho: TransactionArgument,
|
|
147
|
+
sigma: RawTransactionArgument<number | bigint>,
|
|
148
|
+
];
|
|
149
|
+
config?: {
|
|
150
|
+
predictMathPackageId?: string;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Whether a rolled surface's minimum total variance over all strikes is positive,
|
|
155
|
+
* at the 1e18 the rolled `a` and `b` are carried in.
|
|
156
|
+
*/
|
|
157
|
+
export function varPositive(options: VarPositiveOptions) {
|
|
158
|
+
const packageAddress =
|
|
159
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
160
|
+
const argumentsTypes = ['u128', 'bool', 'u128', null, 'u64'] satisfies (string | null)[];
|
|
161
|
+
const parameterNames = ['aMagnitude', 'aIsNegative', 'b', 'rho', 'sigma'];
|
|
162
|
+
return (tx: Transaction) =>
|
|
163
|
+
tx.moveCall({
|
|
164
|
+
package: packageAddress,
|
|
165
|
+
module: 'math',
|
|
166
|
+
function: 'var_positive',
|
|
167
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
export interface InputsOkArguments {
|
|
171
|
+
spot: RawTransactionArgument<number | bigint>;
|
|
172
|
+
forward: RawTransactionArgument<number | bigint>;
|
|
173
|
+
b: RawTransactionArgument<number | bigint>;
|
|
174
|
+
rho: TransactionArgument;
|
|
175
|
+
m: TransactionArgument;
|
|
176
|
+
sigma: RawTransactionArgument<number | bigint>;
|
|
177
|
+
}
|
|
178
|
+
export interface InputsOkOptions {
|
|
179
|
+
package?: string;
|
|
180
|
+
arguments:
|
|
181
|
+
| InputsOkArguments
|
|
182
|
+
| [
|
|
183
|
+
spot: RawTransactionArgument<number | bigint>,
|
|
184
|
+
forward: RawTransactionArgument<number | bigint>,
|
|
185
|
+
b: RawTransactionArgument<number | bigint>,
|
|
186
|
+
rho: TransactionArgument,
|
|
187
|
+
m: TransactionArgument,
|
|
188
|
+
sigma: RawTransactionArgument<number | bigint>,
|
|
189
|
+
];
|
|
190
|
+
config?: {
|
|
191
|
+
predictMathPackageId?: string;
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Whether raw Block Scholes inputs fit Predict's pricing-safe envelope: a positive
|
|
196
|
+
* spot and forward, `forward <= max_spot` and `forward <= 100 * spot`, and SVI
|
|
197
|
+
* `b`, `|rho|`, `|m|`, and `sigma` within their bounds. `a` carries no bound of
|
|
198
|
+
* its own: only total variance has to be positive (`raw_var_ok`), and every
|
|
199
|
+
* downstream use of `a` fits its provider width.
|
|
200
|
+
*/
|
|
201
|
+
export function inputsOk(options: InputsOkOptions) {
|
|
202
|
+
const packageAddress =
|
|
203
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
204
|
+
const argumentsTypes = ['u64', 'u64', 'u64', null, null, 'u64'] satisfies (string | null)[];
|
|
205
|
+
const parameterNames = ['spot', 'forward', 'b', 'rho', 'm', 'sigma'];
|
|
206
|
+
return (tx: Transaction) =>
|
|
207
|
+
tx.moveCall({
|
|
208
|
+
package: packageAddress,
|
|
209
|
+
module: 'math',
|
|
210
|
+
function: 'inputs_ok',
|
|
211
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
export interface RawVarOkArguments {
|
|
215
|
+
a: TransactionArgument;
|
|
216
|
+
b: RawTransactionArgument<number | bigint>;
|
|
217
|
+
rho: TransactionArgument;
|
|
218
|
+
sigma: RawTransactionArgument<number | bigint>;
|
|
219
|
+
}
|
|
220
|
+
export interface RawVarOkOptions {
|
|
221
|
+
package?: string;
|
|
222
|
+
arguments:
|
|
223
|
+
| RawVarOkArguments
|
|
224
|
+
| [
|
|
225
|
+
a: TransactionArgument,
|
|
226
|
+
b: RawTransactionArgument<number | bigint>,
|
|
227
|
+
rho: TransactionArgument,
|
|
228
|
+
sigma: RawTransactionArgument<number | bigint>,
|
|
229
|
+
];
|
|
230
|
+
config?: {
|
|
231
|
+
predictMathPackageId?: string;
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Whether a raw SVI tuple's minimum total variance
|
|
236
|
+
* `a + b * sigma * sqrt(1 - rho^2)` is positive, compared rather than summed: `a`
|
|
237
|
+
* reaches `u64::MAX`, where the sum would leave `u64`.
|
|
238
|
+
*/
|
|
239
|
+
export function rawVarOk(options: RawVarOkOptions) {
|
|
240
|
+
const packageAddress =
|
|
241
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
242
|
+
const argumentsTypes = [null, 'u64', null, 'u64'] satisfies (string | null)[];
|
|
243
|
+
const parameterNames = ['a', 'b', 'rho', 'sigma'];
|
|
244
|
+
return (tx: Transaction) =>
|
|
245
|
+
tx.moveCall({
|
|
246
|
+
package: packageAddress,
|
|
247
|
+
module: 'math',
|
|
248
|
+
function: 'raw_var_ok',
|
|
249
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
export interface LegFeeArguments {
|
|
253
|
+
baseFee: RawTransactionArgument<number | bigint>;
|
|
254
|
+
minFee: RawTransactionArgument<number | bigint>;
|
|
255
|
+
windowMs: RawTransactionArgument<number | bigint>;
|
|
256
|
+
maxMultiplier: RawTransactionArgument<number | bigint>;
|
|
257
|
+
probability: RawTransactionArgument<number | bigint>;
|
|
258
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
259
|
+
timeToExpiryMs: RawTransactionArgument<number | bigint>;
|
|
260
|
+
}
|
|
261
|
+
export interface LegFeeOptions {
|
|
262
|
+
package?: string;
|
|
263
|
+
arguments:
|
|
264
|
+
| LegFeeArguments
|
|
265
|
+
| [
|
|
266
|
+
baseFee: RawTransactionArgument<number | bigint>,
|
|
267
|
+
minFee: RawTransactionArgument<number | bigint>,
|
|
268
|
+
windowMs: RawTransactionArgument<number | bigint>,
|
|
269
|
+
maxMultiplier: RawTransactionArgument<number | bigint>,
|
|
270
|
+
probability: RawTransactionArgument<number | bigint>,
|
|
271
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
272
|
+
timeToExpiryMs: RawTransactionArgument<number | bigint>,
|
|
273
|
+
];
|
|
274
|
+
config?: {
|
|
275
|
+
predictMathPackageId?: string;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* One finite leg's trading fee: `max(bernoulli(p), min_fee) * ramp * quantity`,
|
|
280
|
+
* each product rounded down. `bernoulli(p) = base_fee * sqrt(p * (1 - p))`, zero
|
|
281
|
+
* at `p = 0` or `1`; the caller checks `p <= 1`. The ramp is 1 at or beyond
|
|
282
|
+
* `window_ms` to expiry and rises linearly to `max_multiplier` at expiry, rounded
|
|
283
|
+
* down so the trader keeps the ramp dust.
|
|
284
|
+
*/
|
|
285
|
+
export function legFee(options: LegFeeOptions) {
|
|
286
|
+
const packageAddress =
|
|
287
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
288
|
+
const argumentsTypes = ['u64', 'u64', 'u64', 'u64', 'u64', 'u64', 'u64'] satisfies (
|
|
289
|
+
string | null
|
|
290
|
+
)[];
|
|
291
|
+
const parameterNames = [
|
|
292
|
+
'baseFee',
|
|
293
|
+
'minFee',
|
|
294
|
+
'windowMs',
|
|
295
|
+
'maxMultiplier',
|
|
296
|
+
'probability',
|
|
297
|
+
'quantity',
|
|
298
|
+
'timeToExpiryMs',
|
|
299
|
+
];
|
|
300
|
+
return (tx: Transaction) =>
|
|
301
|
+
tx.moveCall({
|
|
302
|
+
package: packageAddress,
|
|
303
|
+
module: 'math',
|
|
304
|
+
function: 'leg_fee',
|
|
305
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
export interface PotentialArguments {
|
|
309
|
+
maxRate: RawTransactionArgument<number | bigint>;
|
|
310
|
+
scale: RawTransactionArgument<number | bigint>;
|
|
311
|
+
liability: RawTransactionArgument<number | bigint>;
|
|
312
|
+
}
|
|
313
|
+
export interface PotentialOptions {
|
|
314
|
+
package?: string;
|
|
315
|
+
arguments:
|
|
316
|
+
| PotentialArguments
|
|
317
|
+
| [
|
|
318
|
+
maxRate: RawTransactionArgument<number | bigint>,
|
|
319
|
+
scale: RawTransactionArgument<number | bigint>,
|
|
320
|
+
liability: RawTransactionArgument<number | bigint>,
|
|
321
|
+
];
|
|
322
|
+
config?: {
|
|
323
|
+
predictMathPackageId?: string;
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The inventory-impact potential of `liability`: the marginal rate rises linearly
|
|
328
|
+
* from zero to `max_rate` over `scale`, then stays capped:
|
|
329
|
+
*
|
|
330
|
+
* `phi(L) = r_max * L^2 / (2B)` for `L <= B` `phi(L) = phi(B) + r_max * (L - B)`
|
|
331
|
+
* for `L > B`.
|
|
332
|
+
*
|
|
333
|
+
* Defined by this exact sequence of rounded integer operations, so charges and
|
|
334
|
+
* rebates, which always subtract two evaluations, telescope exactly.
|
|
335
|
+
*/
|
|
336
|
+
export function potential(options: PotentialOptions) {
|
|
337
|
+
const packageAddress =
|
|
338
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
339
|
+
const argumentsTypes = ['u64', 'u64', 'u64'] satisfies (string | null)[];
|
|
340
|
+
const parameterNames = ['maxRate', 'scale', 'liability'];
|
|
341
|
+
return (tx: Transaction) =>
|
|
342
|
+
tx.moveCall({
|
|
343
|
+
package: packageAddress,
|
|
344
|
+
module: 'math',
|
|
345
|
+
function: 'potential',
|
|
346
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
export interface MaxQtyArguments {
|
|
350
|
+
probability: RawTransactionArgument<number | bigint>;
|
|
351
|
+
maxPremium: RawTransactionArgument<number | bigint>;
|
|
352
|
+
lot: RawTransactionArgument<number | bigint>;
|
|
353
|
+
maxLots: RawTransactionArgument<number | bigint>;
|
|
354
|
+
}
|
|
355
|
+
export interface MaxQtyOptions {
|
|
356
|
+
package?: string;
|
|
357
|
+
arguments:
|
|
358
|
+
| MaxQtyArguments
|
|
359
|
+
| [
|
|
360
|
+
probability: RawTransactionArgument<number | bigint>,
|
|
361
|
+
maxPremium: RawTransactionArgument<number | bigint>,
|
|
362
|
+
lot: RawTransactionArgument<number | bigint>,
|
|
363
|
+
maxLots: RawTransactionArgument<number | bigint>,
|
|
364
|
+
];
|
|
365
|
+
config?: {
|
|
366
|
+
predictMathPackageId?: string;
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
/**
|
|
370
|
+
* The largest whole number of `lot`s, at most `max_lots`, whose premium
|
|
371
|
+
* `mul_down(probability, quantity)` fits `max_premium`, as a quantity. The probe
|
|
372
|
+
* is the premium mint admission charges, so the result is exact, and an oversized
|
|
373
|
+
* budget saturates at `max_lots` instead of aborting.
|
|
374
|
+
*/
|
|
375
|
+
export function maxQty(options: MaxQtyOptions) {
|
|
376
|
+
const packageAddress =
|
|
377
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
378
|
+
const argumentsTypes = ['u64', 'u64', 'u64', 'u64'] satisfies (string | null)[];
|
|
379
|
+
const parameterNames = ['probability', 'maxPremium', 'lot', 'maxLots'];
|
|
380
|
+
return (tx: Transaction) =>
|
|
381
|
+
tx.moveCall({
|
|
382
|
+
package: packageAddress,
|
|
383
|
+
module: 'math',
|
|
384
|
+
function: 'max_qty',
|
|
385
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
export interface BuilderFeeArguments {
|
|
389
|
+
feeAmount: RawTransactionArgument<number | bigint>;
|
|
390
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
391
|
+
multiplier: RawTransactionArgument<number | bigint>;
|
|
392
|
+
maxRate: RawTransactionArgument<number | bigint>;
|
|
393
|
+
}
|
|
394
|
+
export interface BuilderFeeOptions {
|
|
395
|
+
package?: string;
|
|
396
|
+
arguments:
|
|
397
|
+
| BuilderFeeArguments
|
|
398
|
+
| [
|
|
399
|
+
feeAmount: RawTransactionArgument<number | bigint>,
|
|
400
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
401
|
+
multiplier: RawTransactionArgument<number | bigint>,
|
|
402
|
+
maxRate: RawTransactionArgument<number | bigint>,
|
|
403
|
+
];
|
|
404
|
+
config?: {
|
|
405
|
+
predictMathPackageId?: string;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* The builder fee on a trade with a builder code: `fee_amount * multiplier`,
|
|
410
|
+
* capped at `quantity * max_rate`, each rounded down.
|
|
411
|
+
*/
|
|
412
|
+
export function builderFee(options: BuilderFeeOptions) {
|
|
413
|
+
const packageAddress =
|
|
414
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
415
|
+
const argumentsTypes = ['u64', 'u64', 'u64', 'u64'] satisfies (string | null)[];
|
|
416
|
+
const parameterNames = ['feeAmount', 'quantity', 'multiplier', 'maxRate'];
|
|
417
|
+
return (tx: Transaction) =>
|
|
418
|
+
tx.moveCall({
|
|
419
|
+
package: packageAddress,
|
|
420
|
+
module: 'math',
|
|
421
|
+
function: 'builder_fee',
|
|
422
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
export interface NeedQtyArguments {
|
|
426
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
427
|
+
p: RawTransactionArgument<number | bigint>;
|
|
428
|
+
}
|
|
429
|
+
export interface NeedQtyOptions {
|
|
430
|
+
package?: string;
|
|
431
|
+
arguments:
|
|
432
|
+
| NeedQtyArguments
|
|
433
|
+
| [
|
|
434
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
435
|
+
p: RawTransactionArgument<number | bigint>,
|
|
436
|
+
];
|
|
437
|
+
config?: {
|
|
438
|
+
predictMathPackageId?: string;
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Exact-quantity mint cash need: `ceil(quantity * (1 - p)) + 1`, where `p` is the
|
|
443
|
+
* market's minimum entry probability: a fill pays at least `p` per contract into
|
|
444
|
+
* market cash.
|
|
445
|
+
*/
|
|
446
|
+
export function needQty(options: NeedQtyOptions) {
|
|
447
|
+
const packageAddress =
|
|
448
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
449
|
+
const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[];
|
|
450
|
+
const parameterNames = ['quantity', 'p'];
|
|
451
|
+
return (tx: Transaction) =>
|
|
452
|
+
tx.moveCall({
|
|
453
|
+
package: packageAddress,
|
|
454
|
+
module: 'math',
|
|
455
|
+
function: 'need_qty',
|
|
456
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
export interface NeedBudgetArguments {
|
|
460
|
+
budget: RawTransactionArgument<number | bigint>;
|
|
461
|
+
p: RawTransactionArgument<number | bigint>;
|
|
462
|
+
}
|
|
463
|
+
export interface NeedBudgetOptions {
|
|
464
|
+
package?: string;
|
|
465
|
+
arguments:
|
|
466
|
+
| NeedBudgetArguments
|
|
467
|
+
| [budget: RawTransactionArgument<number | bigint>, p: RawTransactionArgument<number | bigint>];
|
|
468
|
+
config?: {
|
|
469
|
+
predictMathPackageId?: string;
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Budget mint cash need: `ceil((budget + 1) * (1 / p - 1)) + 1`. The `budget + 1`
|
|
474
|
+
* covers premiums rounding down, which lets a fill buy up to `1 / p` raw units
|
|
475
|
+
* more than `budget / p`.
|
|
476
|
+
*/
|
|
477
|
+
export function needBudget(options: NeedBudgetOptions) {
|
|
478
|
+
const packageAddress =
|
|
479
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
480
|
+
const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[];
|
|
481
|
+
const parameterNames = ['budget', 'p'];
|
|
482
|
+
return (tx: Transaction) =>
|
|
483
|
+
tx.moveCall({
|
|
484
|
+
package: packageAddress,
|
|
485
|
+
module: 'math',
|
|
486
|
+
function: 'need_budget',
|
|
487
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
export interface NeedSellArguments {
|
|
491
|
+
closeQuantity: RawTransactionArgument<number | bigint>;
|
|
492
|
+
lambda: RawTransactionArgument<number | bigint>;
|
|
493
|
+
}
|
|
494
|
+
export interface NeedSellOptions {
|
|
495
|
+
package?: string;
|
|
496
|
+
arguments:
|
|
497
|
+
| NeedSellArguments
|
|
498
|
+
| [
|
|
499
|
+
closeQuantity: RawTransactionArgument<number | bigint>,
|
|
500
|
+
lambda: RawTransactionArgument<number | bigint>,
|
|
501
|
+
];
|
|
502
|
+
config?: {
|
|
503
|
+
predictMathPackageId?: string;
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Sell cash need: `ceil(close_quantity * (1 - lambda)) + 1`. A close lowers payout
|
|
508
|
+
* liability by at least `lambda * close_quantity` and pays at most
|
|
509
|
+
* `close_quantity`.
|
|
510
|
+
*/
|
|
511
|
+
export function needSell(options: NeedSellOptions) {
|
|
512
|
+
const packageAddress =
|
|
513
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
514
|
+
const argumentsTypes = ['u64', 'u64'] satisfies (string | null)[];
|
|
515
|
+
const parameterNames = ['closeQuantity', 'lambda'];
|
|
516
|
+
return (tx: Transaction) =>
|
|
517
|
+
tx.moveCall({
|
|
518
|
+
package: packageAddress,
|
|
519
|
+
module: 'math',
|
|
520
|
+
function: 'need_sell',
|
|
521
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
export interface OrderTermsArguments {
|
|
525
|
+
orderId: RawTransactionArgument<number | bigint>;
|
|
526
|
+
}
|
|
527
|
+
export interface OrderTermsOptions {
|
|
528
|
+
package?: string;
|
|
529
|
+
arguments: OrderTermsArguments | [orderId: RawTransactionArgument<number | bigint>];
|
|
530
|
+
config?: {
|
|
531
|
+
predictMathPackageId?: string;
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Decode a packed Predict order ID into `(lower_tick, higher_tick, quantity)`,
|
|
536
|
+
* with the quantity in USDC base units. For the order-flow companion's sell sizing
|
|
537
|
+
* and remainder checks over order IDs Predict issued: it validates nothing. The
|
|
538
|
+
* layout is Predict's frozen order-ID encoding: 30-bit ticks at bits 70 and 40,
|
|
539
|
+
* and a 32-bit count of 10_000-unit lots at bit 100.
|
|
540
|
+
*/
|
|
541
|
+
export function orderTerms(options: OrderTermsOptions) {
|
|
542
|
+
const packageAddress =
|
|
543
|
+
options.package ?? options.config?.predictMathPackageId ?? '@local-pkg/deepbook_predict_math';
|
|
544
|
+
const argumentsTypes = ['u256'] satisfies (string | null)[];
|
|
545
|
+
const parameterNames = ['orderId'];
|
|
546
|
+
return (tx: Transaction) =>
|
|
547
|
+
tx.moveCall({
|
|
548
|
+
package: packageAddress,
|
|
549
|
+
module: 'math',
|
|
550
|
+
function: 'order_terms',
|
|
551
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
552
|
+
});
|
|
553
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
import { type ConfigValue } from '../utils/index.js';
|
|
5
|
+
export interface DeepbookPredictOrdersConfig {
|
|
6
|
+
predictOrdersPackageId?: string;
|
|
7
|
+
orderDesk: ConfigValue;
|
|
8
|
+
queueRegistry: ConfigValue;
|
|
9
|
+
protocolConfig: ConfigValue;
|
|
10
|
+
oracleRegistry: ConfigValue;
|
|
11
|
+
}
|