@mysten/deepbook-v3 2.0.0 → 2.1.3
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 +100 -0
- package/PREDICT.md +256 -0
- package/README.md +116 -0
- package/dist/account.d.mts +139 -0
- package/dist/account.d.mts.map +1 -0
- package/dist/account.mjs +181 -0
- package/dist/account.mjs.map +1 -0
- package/dist/bcs/integers.mjs +23 -0
- package/dist/bcs/integers.mjs.map +1 -0
- package/dist/contracts/account/account.d.mts +382 -0
- package/dist/contracts/account/account.d.mts.map +1 -0
- package/dist/contracts/account/account.mjs +443 -0
- package/dist/contracts/account/account.mjs.map +1 -0
- package/dist/contracts/account/account_events.d.mts +41 -0
- package/dist/contracts/account/account_events.d.mts.map +1 -0
- package/dist/contracts/account/account_events.mjs +72 -0
- package/dist/contracts/account/account_events.mjs.map +1 -0
- package/dist/contracts/account/account_registry.d.mts +210 -0
- package/dist/contracts/account/account_registry.d.mts.map +1 -0
- package/dist/contracts/account/account_registry.mjs +263 -0
- package/dist/contracts/account/account_registry.mjs.map +1 -0
- package/dist/contracts/account/config-arguments.d.mts +10 -0
- package/dist/contracts/account/config-arguments.d.mts.map +1 -0
- package/dist/contracts/account/deps/sui/bag.mjs +44 -0
- package/dist/contracts/account/deps/sui/bag.mjs.map +1 -0
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -1
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/balances.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs.map +1 -1
- package/dist/contracts/deepbook/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/builder_code_events.mjs +38 -0
- package/dist/contracts/deepbook_predict/builder_code_events.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/config-arguments.d.mts +13 -0
- package/dist/contracts/deepbook_predict/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/deps/fixed_math/i64.mjs +25 -0
- package/dist/contracts/deepbook_predict/deps/fixed_math/i64.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/balance.mjs +25 -0
- package/dist/contracts/deepbook_predict/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/coin.mjs +24 -0
- package/dist/contracts/deepbook_predict/deps/sui/coin.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/table.mjs +39 -0
- package/dist/contracts/deepbook_predict/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_set.mjs +26 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_set.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/ewma.mjs +29 -0
- package/dist/contracts/deepbook_predict/ewma.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_cash.mjs +27 -0
- package/dist/contracts/deepbook_predict/expiry_cash.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.mjs +367 -0
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/lp_book.mjs +92 -0
- package/dist/contracts/deepbook_predict/lp_book.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/market_manager.mjs +59 -0
- package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/order.mjs +26 -0
- package/dist/contracts/deepbook_predict/order.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/order_events.mjs +84 -0
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/plp.mjs +284 -0
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +58 -0
- package/dist/contracts/deepbook_predict/pool_accounting.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/predict_account.mjs +106 -0
- package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/pricing.mjs +80 -0
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/range_codec.mjs +41 -0
- package/dist/contracts/deepbook_predict/range_codec.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/registry.mjs +55 -0
- package/dist/contracts/deepbook_predict/registry.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/strike_exposure.mjs +65 -0
- package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/strike_exposure_config.mjs +33 -0
- package/dist/contracts/deepbook_predict/strike_exposure_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +72 -0
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/vault_events.mjs +184 -0
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/config-arguments.d.mts +10 -0
- package/dist/contracts/deepbook_sessions/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_sessions/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_sessions/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts +63 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.mjs +82 -0
- package/dist/contracts/deepbook_sessions/session_config.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/sessions.d.mts +275 -0
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -0
- package/dist/contracts/deepbook_sessions/sessions.mjs +443 -0
- package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -0
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -1
- package/dist/contracts/utils/index.d.mts +18 -1
- package/dist/contracts/utils/index.d.mts.map +1 -1
- package/dist/deployments/index.d.mts +31 -0
- package/dist/deployments/index.d.mts.map +1 -0
- package/dist/deployments/index.mjs +30 -0
- package/dist/deployments/index.mjs.map +1 -0
- package/dist/deployments/testnet.d.mts +14 -0
- package/dist/deployments/testnet.d.mts.map +1 -0
- package/dist/deployments/testnet.mjs +73 -0
- package/dist/deployments/testnet.mjs.map +1 -0
- package/dist/deployments/types.d.mts +36 -0
- package/dist/deployments/types.d.mts.map +1 -0
- package/dist/index.mjs +0 -1
- package/dist/predict/client.d.mts +255 -0
- package/dist/predict/client.d.mts.map +1 -0
- package/dist/predict/client.mjs +436 -0
- package/dist/predict/client.mjs.map +1 -0
- package/dist/predict/config/generated.d.mts +29 -0
- package/dist/predict/config/generated.d.mts.map +1 -0
- package/dist/predict/config/generated.mjs +16 -0
- package/dist/predict/config/generated.mjs.map +1 -0
- package/dist/predict/config/index.d.mts +10 -0
- package/dist/predict/config/index.d.mts.map +1 -0
- package/dist/predict/config/index.mjs +13 -0
- package/dist/predict/config/index.mjs.map +1 -0
- package/dist/predict/config/testnet.d.mts +17 -0
- package/dist/predict/config/testnet.d.mts.map +1 -0
- package/dist/predict/config/testnet.mjs +26 -0
- package/dist/predict/config/testnet.mjs.map +1 -0
- package/dist/predict/config/types.d.mts +55 -0
- package/dist/predict/config/types.d.mts.map +1 -0
- package/dist/predict/decode.d.mts +162 -0
- package/dist/predict/decode.d.mts.map +1 -0
- package/dist/predict/decode.mjs +175 -0
- package/dist/predict/decode.mjs.map +1 -0
- package/dist/predict/errors.d.mts +42 -0
- package/dist/predict/errors.d.mts.map +1 -0
- package/dist/predict/errors.mjs +37 -0
- package/dist/predict/errors.mjs.map +1 -0
- package/dist/predict/index.d.mts +18 -0
- package/dist/predict/index.mjs +14 -0
- package/dist/predict/pricing.d.mts +73 -0
- package/dist/predict/pricing.d.mts.map +1 -0
- package/dist/predict/pricing.mjs +129 -0
- package/dist/predict/pricing.mjs.map +1 -0
- package/dist/predict/reads/balances.mjs +41 -0
- package/dist/predict/reads/balances.mjs.map +1 -0
- package/dist/predict/reads/inspect.d.mts +8 -0
- package/dist/predict/reads/inspect.d.mts.map +1 -0
- package/dist/predict/reads/inspect.mjs +37 -0
- package/dist/predict/reads/inspect.mjs.map +1 -0
- package/dist/predict/reads/markets.mjs +130 -0
- package/dist/predict/reads/markets.mjs.map +1 -0
- package/dist/predict/reads/parse.mjs +20 -0
- package/dist/predict/reads/parse.mjs.map +1 -0
- package/dist/predict/reads/pool.mjs +26 -0
- package/dist/predict/reads/pool.mjs.map +1 -0
- package/dist/predict/reads/positions.d.mts +12 -0
- package/dist/predict/reads/positions.d.mts.map +1 -0
- package/dist/predict/reads/positions.mjs +77 -0
- package/dist/predict/reads/positions.mjs.map +1 -0
- package/dist/predict/reads/pricing.d.mts +20 -0
- package/dist/predict/reads/pricing.d.mts.map +1 -0
- package/dist/predict/reads/pricing.mjs +43 -0
- package/dist/predict/reads/pricing.mjs.map +1 -0
- package/dist/predict/ticks.d.mts +11 -0
- package/dist/predict/ticks.d.mts.map +1 -0
- package/dist/predict/ticks.mjs +21 -0
- package/dist/predict/ticks.mjs.map +1 -0
- package/dist/predict/tx/authed.mjs +18 -0
- package/dist/predict/tx/authed.mjs.map +1 -0
- package/dist/predict/tx/common.d.mts +18 -0
- package/dist/predict/tx/common.d.mts.map +1 -0
- package/dist/predict/tx/common.mjs +52 -0
- package/dist/predict/tx/common.mjs.map +1 -0
- package/dist/predict/tx/trade.d.mts +15 -0
- package/dist/predict/tx/trade.d.mts.map +1 -0
- package/dist/predict/tx/trade.mjs +86 -0
- package/dist/predict/tx/trade.mjs.map +1 -0
- package/dist/predict/units.d.mts +11 -0
- package/dist/predict/units.d.mts.map +1 -0
- package/dist/predict/units.mjs +44 -0
- package/dist/predict/units.mjs.map +1 -0
- package/dist/queries/accountQueries.mjs +0 -1
- package/dist/queries/accountQueries.mjs.map +1 -1
- package/dist/queries/orderQueries.mjs +0 -1
- package/dist/queries/orderQueries.mjs.map +1 -1
- package/dist/queries/registryQueries.mjs +0 -1
- package/dist/queries/registryQueries.mjs.map +1 -1
- package/dist/sessions.d.mts +244 -0
- package/dist/sessions.d.mts.map +1 -0
- package/dist/sessions.mjs +291 -0
- package/dist/sessions.mjs.map +1 -0
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/deepbook.d.mts +20 -20
- 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/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- 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/poolProxy.d.mts +8 -8
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +1 -1
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +33 -12
- package/src/account.ts +239 -0
- package/src/bcs/integers.ts +35 -0
- package/src/contracts/account/account.ts +706 -0
- package/src/contracts/account/account_events.ts +64 -0
- package/src/contracts/account/account_registry.ts +468 -0
- package/src/contracts/account/config-arguments.ts +8 -0
- package/src/contracts/account/deps/sui/bag.ts +42 -0
- package/src/contracts/deepbook/balance_manager.ts +1 -2
- package/src/contracts/deepbook/pool.ts +12 -24
- package/src/contracts/deepbook/registry.ts +1 -2
- package/src/contracts/deepbook_margin/margin_manager.ts +9 -18
- package/src/contracts/deepbook_margin/margin_manager_upgraded.ts +5 -10
- package/src/contracts/deepbook_margin/margin_pool.ts +2 -4
- package/src/contracts/deepbook_margin/margin_registry.ts +3 -6
- package/src/contracts/deepbook_margin/pool_proxy.ts +3 -6
- package/src/contracts/deepbook_margin/protocol_config.ts +1 -2
- package/src/contracts/deepbook_margin/tpsl.ts +1 -2
- package/src/contracts/deepbook_predict/admin.ts +44 -0
- package/src/contracts/deepbook_predict/builder_code.ts +155 -0
- package/src/contracts/deepbook_predict/builder_code_events.ts +34 -0
- package/src/contracts/deepbook_predict/config-arguments.ts +11 -0
- package/src/contracts/deepbook_predict/config_events.ts +140 -0
- package/src/contracts/deepbook_predict/deps/fixed_math/i64.ts +21 -0
- package/src/contracts/deepbook_predict/deps/sui/balance.ts +25 -0
- package/src/contracts/deepbook_predict/deps/sui/coin.ts +20 -0
- package/src/contracts/deepbook_predict/deps/sui/table.ts +37 -0
- package/src/contracts/deepbook_predict/deps/sui/vec_set.ts +22 -0
- package/src/contracts/deepbook_predict/ewma.ts +26 -0
- package/src/contracts/deepbook_predict/ewma_config.ts +28 -0
- package/src/contracts/deepbook_predict/expiry_cash.ts +24 -0
- package/src/contracts/deepbook_predict/expiry_market.ts +1549 -0
- package/src/contracts/deepbook_predict/lp_book.ts +105 -0
- package/src/contracts/deepbook_predict/market_lifecycle_cap.ts +75 -0
- package/src/contracts/deepbook_predict/market_manager.ts +218 -0
- package/src/contracts/deepbook_predict/order.ts +24 -0
- package/src/contracts/deepbook_predict/order_events.ts +129 -0
- package/src/contracts/deepbook_predict/pause_cap.ts +68 -0
- package/src/contracts/deepbook_predict/plp.ts +987 -0
- package/src/contracts/deepbook_predict/pool_accounting.ts +79 -0
- package/src/contracts/deepbook_predict/predict_account.ts +180 -0
- package/src/contracts/deepbook_predict/pricing.ts +124 -0
- package/src/contracts/deepbook_predict/pricing_config.ts +41 -0
- package/src/contracts/deepbook_predict/protocol_config.ts +1066 -0
- package/src/contracts/deepbook_predict/range_codec.ts +53 -0
- package/src/contracts/deepbook_predict/registry.ts +694 -0
- package/src/contracts/deepbook_predict/strike_exposure.ts +77 -0
- package/src/contracts/deepbook_predict/strike_exposure_config.ts +46 -0
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +89 -0
- package/src/contracts/deepbook_predict/vault_events.ts +222 -0
- package/src/contracts/deepbook_sessions/config-arguments.ts +8 -0
- package/src/contracts/deepbook_sessions/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_sessions/session_config.ts +130 -0
- package/src/contracts/deepbook_sessions/sessions.ts +663 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +2 -4
- package/src/contracts/propbook/block_scholes_store.ts +842 -0
- package/src/contracts/propbook/deps/sui/table.ts +37 -0
- package/src/contracts/propbook/oracle_lane.ts +170 -0
- package/src/contracts/propbook/pyth_feed.ts +414 -0
- package/src/contracts/propbook/registry.ts +596 -0
- package/src/contracts/pyth/pyth.ts +2 -4
- package/src/deployments/index.ts +73 -0
- package/src/deployments/testnet.ts +107 -0
- package/src/deployments/types.ts +81 -0
- package/src/index.ts +5 -0
- package/src/predict/client.ts +941 -0
- package/src/predict/config/generated.ts +39 -0
- package/src/predict/config/index.ts +25 -0
- package/src/predict/config/testnet.ts +27 -0
- package/src/predict/config/types.ts +52 -0
- package/src/predict/decode.ts +476 -0
- package/src/predict/errors.ts +83 -0
- package/src/predict/index.ts +94 -0
- package/src/predict/pricing.ts +199 -0
- package/src/predict/reads/balances.ts +55 -0
- package/src/predict/reads/inspect.ts +78 -0
- package/src/predict/reads/markets.ts +222 -0
- package/src/predict/reads/parse.ts +30 -0
- package/src/predict/reads/pool.ts +37 -0
- package/src/predict/reads/positions.ts +144 -0
- package/src/predict/reads/pricing.ts +79 -0
- package/src/predict/ticks.ts +42 -0
- package/src/predict/tx/authed.ts +20 -0
- package/src/predict/tx/common.ts +92 -0
- package/src/predict/tx/trade.ts +183 -0
- package/src/predict/units.ts +49 -0
- package/src/sessions.ts +471 -0
- package/src/types/index.ts +1 -2
- package/src/utils/constants.ts +1 -7
- package/dist/types/bcs.mjs +0 -7
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Pool-owned expiry registration and cash-flow accounting.
|
|
7
|
+
*
|
|
8
|
+
* This module owns pool idle DUSDC custody, the durable set of expiries registered
|
|
9
|
+
* to a pool, the active expiry index used for valuation, DUSDC sent from the main
|
|
10
|
+
* pool into each expiry, DUSDC received back from each expiry, snapshotted
|
|
11
|
+
* lifetime fee-incentive caps and allocations, terminal cash watermarks, and
|
|
12
|
+
* per-expiry cap checks. It does not classify expiry-local liabilities or apply
|
|
13
|
+
* PLP reserve policy; PoolVault uses the aggregate profit basis to price PLP and
|
|
14
|
+
* decide protocol reserve transfers.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { MoveStruct } from '../utils/index.js';
|
|
18
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
19
|
+
import { U64 } from '../../bcs/integers.js';
|
|
20
|
+
import * as balance from './deps/sui/balance.js';
|
|
21
|
+
import * as table from './deps/sui/table.js';
|
|
22
|
+
const $moduleName = '@local-pkg/deepbook_predict::pool_accounting';
|
|
23
|
+
export const ActiveExpiry = new MoveStruct({
|
|
24
|
+
name: `${$moduleName}::ActiveExpiry`,
|
|
25
|
+
fields: {
|
|
26
|
+
expiry_market_id: bcs.Address,
|
|
27
|
+
expiry_ms: U64,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
export const Ledger = new MoveStruct({
|
|
31
|
+
name: `${$moduleName}::Ledger`,
|
|
32
|
+
fields: {
|
|
33
|
+
/** Idle LP-owned DUSDC available for withdrawals and expiry funding. */
|
|
34
|
+
idle_balance: balance.Balance,
|
|
35
|
+
/** Expiry markets that still contribute active pool valuation/risk. */
|
|
36
|
+
active_expiry_markets: bcs.vector(ActiveExpiry),
|
|
37
|
+
/**
|
|
38
|
+
* Permanent per-expiry accounting rows. Presence means the expiry belongs to this
|
|
39
|
+
* pool.
|
|
40
|
+
*/
|
|
41
|
+
registered_expiries: table.Table,
|
|
42
|
+
/** Pricing debit basis: DUSDC sent to expiries plus materialized terminal profit. */
|
|
43
|
+
profit_basis_debits: U64,
|
|
44
|
+
/** Pricing credit basis: all DUSDC received back from expiries. */
|
|
45
|
+
profit_basis_credits: U64,
|
|
46
|
+
/**
|
|
47
|
+
* Aggregate terminal losses that later terminal profits must recover first; losses
|
|
48
|
+
* do not claw back profit that was already materialized.
|
|
49
|
+
*/
|
|
50
|
+
net_losses_to_fill: U64,
|
|
51
|
+
/**
|
|
52
|
+
* Protocol profit already materialized into the debit basis but not yet physically
|
|
53
|
+
* moved to the reserve because idle was deployed in other active markets at
|
|
54
|
+
* materialization. Excluded from LP value until drained.
|
|
55
|
+
*/
|
|
56
|
+
pending_protocol_profit: U64,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
export const RegisteredExpiry = new MoveStruct({
|
|
60
|
+
name: `${$moduleName}::RegisteredExpiry`,
|
|
61
|
+
fields: {
|
|
62
|
+
/** DUSDC pool allocation cap snapshotted when this expiry was created. */
|
|
63
|
+
max_expiry_allocation: U64,
|
|
64
|
+
/** Minimum DUSDC cash target snapshotted when this expiry was created. */
|
|
65
|
+
initial_expiry_cash: U64,
|
|
66
|
+
/** DUSDC sent from the main pool into this expiry. */
|
|
67
|
+
sent_to_expiry: U64,
|
|
68
|
+
/** DUSDC returned from this expiry to the main pool. */
|
|
69
|
+
received_from_expiry: U64,
|
|
70
|
+
/** Absolute lifetime fee-incentive cap snapshotted when this expiry was registered. */
|
|
71
|
+
fee_incentive_lifetime_cap: U64,
|
|
72
|
+
/** Lifetime sponsor-funded fee incentives allocated to this expiry. */
|
|
73
|
+
fee_incentives_allocated: U64,
|
|
74
|
+
/** True once this expiry has started terminal profit/loss accounting. */
|
|
75
|
+
terminal_accounting_started: bcs.bool(),
|
|
76
|
+
/** Received amount already consumed by terminal accounting. */
|
|
77
|
+
terminal_received_watermark: U64,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Predict's per-account state, stored as an app-data slot on a shared `Account`
|
|
7
|
+
* (the `account` package).
|
|
8
|
+
*
|
|
9
|
+
* This is Predict's account-local state: open positions and sticky builder-code
|
|
10
|
+
* attribution. DUSDC/PLP custody lives in `Account`. The `PredictApp` witness
|
|
11
|
+
* namespaces this slot, so only Predict writes it.
|
|
12
|
+
*
|
|
13
|
+
* Position mutations are package-internal. Builder-code configuration accepts an
|
|
14
|
+
* account `Auth`; the account package decides which owner or authorized
|
|
15
|
+
* application may obtain that mutable borrow.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
MoveTuple,
|
|
20
|
+
MoveStruct,
|
|
21
|
+
normalizeMoveArguments,
|
|
22
|
+
type RawTransactionArgument,
|
|
23
|
+
} from '../utils/index.js';
|
|
24
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
25
|
+
import { U256, U64 } from '../../bcs/integers.js';
|
|
26
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
27
|
+
import * as table from './deps/sui/table.js';
|
|
28
|
+
const $moduleName = '@local-pkg/deepbook_predict::predict_account';
|
|
29
|
+
export const PredictApp = new MoveTuple({
|
|
30
|
+
name: `${$moduleName}::PredictApp`,
|
|
31
|
+
fields: [bcs.bool()],
|
|
32
|
+
});
|
|
33
|
+
export const PositionKey = new MoveStruct({
|
|
34
|
+
name: `${$moduleName}::PositionKey`,
|
|
35
|
+
fields: {
|
|
36
|
+
expiry_market_id: bcs.Address,
|
|
37
|
+
order_id: U256,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
export const Position = new MoveStruct({
|
|
41
|
+
name: `${$moduleName}::Position`,
|
|
42
|
+
fields: {
|
|
43
|
+
/** Root order ID, carried forward unchanged across partial-close replacements. */
|
|
44
|
+
root_id: U256,
|
|
45
|
+
/**
|
|
46
|
+
* On-chain time (`clock.timestamp_ms()`) the position was opened, carried forward
|
|
47
|
+
* unchanged across partial-close replacements. A live redeem in the same timestamp
|
|
48
|
+
* is rejected, blocking an atomic mint -> oracle-update -> redeem in one
|
|
49
|
+
* transaction.
|
|
50
|
+
*/
|
|
51
|
+
opened_at_ms: U64,
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
export const PredictData = new MoveStruct({
|
|
55
|
+
name: `${$moduleName}::PredictData`,
|
|
56
|
+
fields: {
|
|
57
|
+
/** Open positions scoped by expiry market. */
|
|
58
|
+
positions: table.Table,
|
|
59
|
+
/** Sticky builder-code attribution for future trades, if set. */
|
|
60
|
+
builder_code_id: bcs.option(bcs.Address),
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
export interface HasPositionArguments {
|
|
64
|
+
account: TransactionArgument;
|
|
65
|
+
expiryMarketId: RawTransactionArgument<string>;
|
|
66
|
+
orderId: RawTransactionArgument<number | bigint>;
|
|
67
|
+
}
|
|
68
|
+
export interface HasPositionOptions {
|
|
69
|
+
package?: string;
|
|
70
|
+
arguments:
|
|
71
|
+
| HasPositionArguments
|
|
72
|
+
| [
|
|
73
|
+
account: TransactionArgument,
|
|
74
|
+
expiryMarketId: RawTransactionArgument<string>,
|
|
75
|
+
orderId: RawTransactionArgument<number | bigint>,
|
|
76
|
+
];
|
|
77
|
+
config?: {
|
|
78
|
+
predictPackageId?: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Return whether an account holds a position for SDK and devInspect state reads. */
|
|
82
|
+
export function hasPosition(options: HasPositionOptions) {
|
|
83
|
+
const packageAddress =
|
|
84
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
85
|
+
const argumentsTypes = [null, '0x2::object::ID', 'u256'] satisfies (string | null)[];
|
|
86
|
+
const parameterNames = ['account', 'expiryMarketId', 'orderId'];
|
|
87
|
+
return (tx: Transaction) =>
|
|
88
|
+
tx.moveCall({
|
|
89
|
+
package: packageAddress,
|
|
90
|
+
module: 'predict_account',
|
|
91
|
+
function: 'has_position',
|
|
92
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
export interface BuilderCodeIdArguments {
|
|
96
|
+
account: TransactionArgument;
|
|
97
|
+
}
|
|
98
|
+
export interface BuilderCodeIdOptions {
|
|
99
|
+
package?: string;
|
|
100
|
+
arguments: BuilderCodeIdArguments | [account: TransactionArgument];
|
|
101
|
+
config?: {
|
|
102
|
+
predictPackageId?: string;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/** Return the sticky builder-code ID, if set. */
|
|
106
|
+
export function builderCodeId(options: BuilderCodeIdOptions) {
|
|
107
|
+
const packageAddress =
|
|
108
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
109
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
110
|
+
const parameterNames = ['account'];
|
|
111
|
+
return (tx: Transaction) =>
|
|
112
|
+
tx.moveCall({
|
|
113
|
+
package: packageAddress,
|
|
114
|
+
module: 'predict_account',
|
|
115
|
+
function: 'builder_code_id',
|
|
116
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export interface SetBuilderCodeArguments {
|
|
120
|
+
wrapper: RawTransactionArgument<string>;
|
|
121
|
+
auth: TransactionArgument;
|
|
122
|
+
code: RawTransactionArgument<string>;
|
|
123
|
+
}
|
|
124
|
+
export interface SetBuilderCodeOptions {
|
|
125
|
+
package?: string;
|
|
126
|
+
arguments:
|
|
127
|
+
| SetBuilderCodeArguments
|
|
128
|
+
| [
|
|
129
|
+
wrapper: RawTransactionArgument<string>,
|
|
130
|
+
auth: TransactionArgument,
|
|
131
|
+
code: RawTransactionArgument<string>,
|
|
132
|
+
];
|
|
133
|
+
config?: {
|
|
134
|
+
predictPackageId?: string;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Set sticky builder-code attribution for future trades using valid account auth.
|
|
139
|
+
* Owner auth and authorized-app auth both satisfy the account borrow boundary.
|
|
140
|
+
*/
|
|
141
|
+
export function setBuilderCode(options: SetBuilderCodeOptions) {
|
|
142
|
+
const packageAddress =
|
|
143
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
144
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
145
|
+
const parameterNames = ['wrapper', 'auth', 'code'];
|
|
146
|
+
return (tx: Transaction) =>
|
|
147
|
+
tx.moveCall({
|
|
148
|
+
package: packageAddress,
|
|
149
|
+
module: 'predict_account',
|
|
150
|
+
function: 'set_builder_code',
|
|
151
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
export interface UnsetBuilderCodeArguments {
|
|
155
|
+
wrapper: RawTransactionArgument<string>;
|
|
156
|
+
auth: TransactionArgument;
|
|
157
|
+
}
|
|
158
|
+
export interface UnsetBuilderCodeOptions {
|
|
159
|
+
package?: string;
|
|
160
|
+
arguments:
|
|
161
|
+
| UnsetBuilderCodeArguments
|
|
162
|
+
| [wrapper: RawTransactionArgument<string>, auth: TransactionArgument];
|
|
163
|
+
config?: {
|
|
164
|
+
predictPackageId?: string;
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/** Clear sticky builder-code attribution using valid owner or authorized-app auth. */
|
|
168
|
+
export function unsetBuilderCode(options: UnsetBuilderCodeOptions) {
|
|
169
|
+
const packageAddress =
|
|
170
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
171
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
172
|
+
const parameterNames = ['wrapper', 'auth'];
|
|
173
|
+
return (tx: Transaction) =>
|
|
174
|
+
tx.moveCall({
|
|
175
|
+
package: packageAddress,
|
|
176
|
+
module: 'predict_account',
|
|
177
|
+
function: 'unset_builder_code',
|
|
178
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Pricing for Predict markets.
|
|
7
|
+
*
|
|
8
|
+
* This module reads canonical Propbook Pyth and Block Scholes feeds and computes
|
|
9
|
+
* SVI-adjusted digital probabilities. Live reads require fresh, pricing-safe Block
|
|
10
|
+
* Scholes spot, forward, and SVI observations. The live forward comes from one of
|
|
11
|
+
* two admin-selected sources (`PricingConfig.use_pyth_spot_for_forward`): a fresh
|
|
12
|
+
* positive Pyth spot carrying the Block Scholes basis, or the Block Scholes
|
|
13
|
+
* forward directly. Exact-history reads do not apply live freshness policy.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { MoveStruct, normalizeMoveArguments } from '../utils/index.js';
|
|
17
|
+
import { U128, U64 } from '../../bcs/integers.js';
|
|
18
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
19
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
20
|
+
import * as i64 from './deps/fixed_math/i64.js';
|
|
21
|
+
const $moduleName = '@local-pkg/deepbook_predict::pricing';
|
|
22
|
+
export const PricingSVI = new MoveStruct({
|
|
23
|
+
name: `${$moduleName}::PricingSVI`,
|
|
24
|
+
fields: {
|
|
25
|
+
/** Rolled-down SVI `a`, magnitude at 1e18, sign in `a_is_negative`. */
|
|
26
|
+
a_magnitude: U128,
|
|
27
|
+
a_is_negative: bcs.bool(),
|
|
28
|
+
/** Rolled-down SVI `b`, at 1e18. */
|
|
29
|
+
b: U128,
|
|
30
|
+
rho: i64.I64,
|
|
31
|
+
m: i64.I64,
|
|
32
|
+
sigma: U64,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
export const Pricer = new MoveStruct({
|
|
36
|
+
name: `${$moduleName}::Pricer`,
|
|
37
|
+
fields: {
|
|
38
|
+
/** Expiry market this snapshot was loaded for. */
|
|
39
|
+
expiry_market_id: bcs.Address,
|
|
40
|
+
forward: U64,
|
|
41
|
+
svi: PricingSVI,
|
|
42
|
+
/**
|
|
43
|
+
* Timestamps of the oracle observations this snapshot validated, as trade events
|
|
44
|
+
* report them — each observation's own economic clock. Pyth carries its source
|
|
45
|
+
* timestamp (`0` only when no usable normalized observation exists); the Block
|
|
46
|
+
* Scholes reads carry their batch envelope time (`source_timestamp_ms`), the clock
|
|
47
|
+
* freshness gated and the SVI roll-down anchored on. The provider's calibration
|
|
48
|
+
* (model) times stay on the stored observations and their ingestion events.
|
|
49
|
+
*/
|
|
50
|
+
pyth_spot_source_timestamp_ms: U64,
|
|
51
|
+
block_scholes_spot_source_timestamp_ms: U64,
|
|
52
|
+
block_scholes_forward_source_timestamp_ms: U64,
|
|
53
|
+
block_scholes_svi_source_timestamp_ms: U64,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
export const RawSVI = new MoveStruct({
|
|
57
|
+
name: `${$moduleName}::RawSVI`,
|
|
58
|
+
fields: {
|
|
59
|
+
a: i64.I64,
|
|
60
|
+
b: U64,
|
|
61
|
+
rho: i64.I64,
|
|
62
|
+
m: i64.I64,
|
|
63
|
+
sigma: U64,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
export interface UpPriceArguments {
|
|
67
|
+
pricer: TransactionArgument;
|
|
68
|
+
strike: TransactionArgument;
|
|
69
|
+
}
|
|
70
|
+
export interface UpPriceOptions {
|
|
71
|
+
package?: string;
|
|
72
|
+
arguments: UpPriceArguments | [pricer: TransactionArgument, strike: TransactionArgument];
|
|
73
|
+
config?: {
|
|
74
|
+
predictPackageId?: string;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Return the current UP digital probability for a typed strike. Public PTB and
|
|
79
|
+
* devInspect reads can compose it with a transaction-local `Pricer`.
|
|
80
|
+
*/
|
|
81
|
+
export function upPrice(options: UpPriceOptions) {
|
|
82
|
+
const packageAddress =
|
|
83
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
84
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
85
|
+
const parameterNames = ['pricer', 'strike'];
|
|
86
|
+
return (tx: Transaction) =>
|
|
87
|
+
tx.moveCall({
|
|
88
|
+
package: packageAddress,
|
|
89
|
+
module: 'pricing',
|
|
90
|
+
function: 'up_price',
|
|
91
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
export interface RangePriceArguments {
|
|
95
|
+
pricer: TransactionArgument;
|
|
96
|
+
lower: TransactionArgument;
|
|
97
|
+
higher: TransactionArgument;
|
|
98
|
+
}
|
|
99
|
+
export interface RangePriceOptions {
|
|
100
|
+
package?: string;
|
|
101
|
+
arguments:
|
|
102
|
+
| RangePriceArguments
|
|
103
|
+
| [pricer: TransactionArgument, lower: TransactionArgument, higher: TransactionArgument];
|
|
104
|
+
config?: {
|
|
105
|
+
predictPackageId?: string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Return the current probability for `(lower, higher]`, floored at zero if the two
|
|
110
|
+
* approximated boundary probabilities invert.
|
|
111
|
+
*/
|
|
112
|
+
export function rangePrice(options: RangePriceOptions) {
|
|
113
|
+
const packageAddress =
|
|
114
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
115
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
116
|
+
const parameterNames = ['pricer', 'lower', 'higher'];
|
|
117
|
+
return (tx: Transaction) =>
|
|
118
|
+
tx.moveCall({
|
|
119
|
+
package: packageAddress,
|
|
120
|
+
module: 'pricing',
|
|
121
|
+
function: 'range_price',
|
|
122
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
123
|
+
});
|
|
124
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Stored oracle source-selection and freshness config for Predict quotes.
|
|
7
|
+
*
|
|
8
|
+
* ProtocolConfig owns this mutable policy. Pricing reads it when resolving live
|
|
9
|
+
* probabilities for mint and redeem flows.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { MoveStruct } from '../utils/index.js';
|
|
13
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
14
|
+
import { U64 } from '../../bcs/integers.js';
|
|
15
|
+
const $moduleName = '@local-pkg/deepbook_predict::pricing_config';
|
|
16
|
+
export const PricingConfig = new MoveStruct({
|
|
17
|
+
name: `${$moduleName}::PricingConfig`,
|
|
18
|
+
fields: {
|
|
19
|
+
/**
|
|
20
|
+
* Selects which live-forward formula pricing uses. True carries the Block Scholes
|
|
21
|
+
* basis on a fresh Pyth spot (`pyth_spot * bs_forward / bs_spot`); false uses the
|
|
22
|
+
* Block Scholes forward directly and no Pyth spot, fresh or not, moves a quote.
|
|
23
|
+
*/
|
|
24
|
+
use_pyth_spot_for_forward: bcs.bool(),
|
|
25
|
+
/**
|
|
26
|
+
* Fixed wall-clock maximum age for Pyth spot; it does not vary with time to
|
|
27
|
+
* expiry.
|
|
28
|
+
*/
|
|
29
|
+
pyth_spot_freshness_ms: U64,
|
|
30
|
+
/**
|
|
31
|
+
* Fixed wall-clock maximum age for Block Scholes spot and forward; it does not
|
|
32
|
+
* vary with time to expiry.
|
|
33
|
+
*/
|
|
34
|
+
block_scholes_price_freshness_ms: U64,
|
|
35
|
+
/**
|
|
36
|
+
* Fixed wall-clock maximum age for Block Scholes SVI parameters; it does not vary
|
|
37
|
+
* with time to expiry.
|
|
38
|
+
*/
|
|
39
|
+
block_scholes_svi_freshness_ms: U64,
|
|
40
|
+
},
|
|
41
|
+
});
|