@mysten/deepbook-v3 2.0.1 → 2.1.4
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 +85 -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/client.d.mts +2 -2
- 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/balances.d.mts +4 -4
- 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_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/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/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/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/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 +25 -4
- 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_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/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/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/dist/types/bcs.mjs +0 -7
|
@@ -0,0 +1,987 @@
|
|
|
1
|
+
/**************************************************************
|
|
2
|
+
* THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
|
|
3
|
+
**************************************************************/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* PLP token and pool vault.
|
|
7
|
+
*
|
|
8
|
+
* PoolVault owns the PLP treasury cap, idle DUSDC, the protocol reserve,
|
|
9
|
+
* sponsor-funded fee incentives, per-expiry cash accounting, and the queued LP
|
|
10
|
+
* supply/withdraw requests. It coordinates the full-pool NAV valuation (a
|
|
11
|
+
* hot-potato aggregation over every active market) and the unified per-market cash
|
|
12
|
+
* flow (initial funding, live rebalance/sweep, and settled-market sweep with
|
|
13
|
+
* terminal profit materialization). LPs queue supply/withdraw requests routed
|
|
14
|
+
* through a loaded Account; each flush (`finish_flush`) drains them at the frozen
|
|
15
|
+
* pool NAV, minting/burning PLP and delivering fills to each account via the
|
|
16
|
+
* balance accumulator.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
MoveStruct,
|
|
21
|
+
normalizeMoveArguments,
|
|
22
|
+
type RawTransactionArgument,
|
|
23
|
+
type ConfigValue,
|
|
24
|
+
} from '../utils/index.js';
|
|
25
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
26
|
+
import { U64 } from '../../bcs/integers.js';
|
|
27
|
+
import { type Transaction, type TransactionArgument } from '@mysten/sui/transactions';
|
|
28
|
+
import * as balance from './deps/sui/balance.js';
|
|
29
|
+
import * as lp_book from './lp_book.js';
|
|
30
|
+
import * as pool_accounting from './pool_accounting.js';
|
|
31
|
+
const $moduleName = '@local-pkg/deepbook_predict::plp';
|
|
32
|
+
export const PLP = new MoveStruct({
|
|
33
|
+
name: `${$moduleName}::PLP`,
|
|
34
|
+
fields: {
|
|
35
|
+
dummy_field: bcs.bool(),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export const PoolVault = new MoveStruct({
|
|
39
|
+
name: `${$moduleName}::PoolVault`,
|
|
40
|
+
fields: {
|
|
41
|
+
id: bcs.Address,
|
|
42
|
+
/**
|
|
43
|
+
* Protocol-owned DUSDC excluded from PLP redemption. No package entrypoint
|
|
44
|
+
* withdraws this balance.
|
|
45
|
+
*/
|
|
46
|
+
protocol_reserve_balance: balance.Balance,
|
|
47
|
+
/** Sponsor-funded DUSDC reserved for taker fee sponsorship, excluded from PLP NAV. */
|
|
48
|
+
fee_incentive_reserve: balance.Balance,
|
|
49
|
+
/** PLP share issuance plus queued supply/withdraw escrow. */
|
|
50
|
+
lp: lp_book.LpBook,
|
|
51
|
+
/** Idle DUSDC custody, registered expiries, and per-expiry cash-flow rows. */
|
|
52
|
+
expiry_accounting: pool_accounting.Ledger,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
export const PoolValuation = new MoveStruct({
|
|
56
|
+
name: `${$moduleName}::PoolValuation`,
|
|
57
|
+
fields: {
|
|
58
|
+
pool_vault_id: bcs.Address,
|
|
59
|
+
/** Active expiry markets snapshotted at start; every one must be valued. */
|
|
60
|
+
expected_expiry_markets: bcs.vector(bcs.Address),
|
|
61
|
+
/** Markets valued so far this flow; folded against `expected` at finish. */
|
|
62
|
+
valued_expiry_markets: bcs.vector(bcs.Address),
|
|
63
|
+
/** Running Σ of each valued market's NAV (settled markets contribute 0). */
|
|
64
|
+
total_nav: U64,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
export interface IdArguments {
|
|
68
|
+
vault?: RawTransactionArgument<string>;
|
|
69
|
+
}
|
|
70
|
+
export interface IdOptions {
|
|
71
|
+
package?: string;
|
|
72
|
+
arguments?: IdArguments;
|
|
73
|
+
config?: {
|
|
74
|
+
poolVault: ConfigValue;
|
|
75
|
+
predictPackageId?: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** Return the pool vault object ID for external discovery and PTB construction. */
|
|
79
|
+
export function id(options: IdOptions) {
|
|
80
|
+
const packageAddress =
|
|
81
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
82
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
83
|
+
const parameterNames = ['vault'];
|
|
84
|
+
return (tx: Transaction) =>
|
|
85
|
+
tx.moveCall({
|
|
86
|
+
package: packageAddress,
|
|
87
|
+
module: 'plp',
|
|
88
|
+
function: 'id',
|
|
89
|
+
arguments: normalizeMoveArguments(
|
|
90
|
+
{
|
|
91
|
+
...options.arguments,
|
|
92
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
93
|
+
},
|
|
94
|
+
argumentsTypes,
|
|
95
|
+
parameterNames,
|
|
96
|
+
),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
export interface IdleBalanceArguments {
|
|
100
|
+
vault?: RawTransactionArgument<string>;
|
|
101
|
+
}
|
|
102
|
+
export interface IdleBalanceOptions {
|
|
103
|
+
package?: string;
|
|
104
|
+
arguments?: IdleBalanceArguments;
|
|
105
|
+
config?: {
|
|
106
|
+
poolVault: ConfigValue;
|
|
107
|
+
predictPackageId?: string;
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** Return idle DUSDC for SDK and devInspect state reads. */
|
|
111
|
+
export function idleBalance(options: IdleBalanceOptions) {
|
|
112
|
+
const packageAddress =
|
|
113
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
114
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
115
|
+
const parameterNames = ['vault'];
|
|
116
|
+
return (tx: Transaction) =>
|
|
117
|
+
tx.moveCall({
|
|
118
|
+
package: packageAddress,
|
|
119
|
+
module: 'plp',
|
|
120
|
+
function: 'idle_balance',
|
|
121
|
+
arguments: normalizeMoveArguments(
|
|
122
|
+
{
|
|
123
|
+
...options.arguments,
|
|
124
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
125
|
+
},
|
|
126
|
+
argumentsTypes,
|
|
127
|
+
parameterNames,
|
|
128
|
+
),
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
export interface ProtocolReserveBalanceArguments {
|
|
132
|
+
vault?: RawTransactionArgument<string>;
|
|
133
|
+
}
|
|
134
|
+
export interface ProtocolReserveBalanceOptions {
|
|
135
|
+
package?: string;
|
|
136
|
+
arguments?: ProtocolReserveBalanceArguments;
|
|
137
|
+
config?: {
|
|
138
|
+
poolVault: ConfigValue;
|
|
139
|
+
predictPackageId?: string;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/** Return protocol-owned DUSDC for SDK and devInspect state reads. */
|
|
143
|
+
export function protocolReserveBalance(options: ProtocolReserveBalanceOptions) {
|
|
144
|
+
const packageAddress =
|
|
145
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
146
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
147
|
+
const parameterNames = ['vault'];
|
|
148
|
+
return (tx: Transaction) =>
|
|
149
|
+
tx.moveCall({
|
|
150
|
+
package: packageAddress,
|
|
151
|
+
module: 'plp',
|
|
152
|
+
function: 'protocol_reserve_balance',
|
|
153
|
+
arguments: normalizeMoveArguments(
|
|
154
|
+
{
|
|
155
|
+
...options.arguments,
|
|
156
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
157
|
+
},
|
|
158
|
+
argumentsTypes,
|
|
159
|
+
parameterNames,
|
|
160
|
+
),
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
export interface FeeIncentiveReserveArguments {
|
|
164
|
+
vault?: RawTransactionArgument<string>;
|
|
165
|
+
}
|
|
166
|
+
export interface FeeIncentiveReserveOptions {
|
|
167
|
+
package?: string;
|
|
168
|
+
arguments?: FeeIncentiveReserveArguments;
|
|
169
|
+
config?: {
|
|
170
|
+
poolVault: ConfigValue;
|
|
171
|
+
predictPackageId?: string;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
/** Return sponsor-funded fee reserves for SDK and devInspect state reads. */
|
|
175
|
+
export function feeIncentiveReserve(options: FeeIncentiveReserveOptions) {
|
|
176
|
+
const packageAddress =
|
|
177
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
178
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
179
|
+
const parameterNames = ['vault'];
|
|
180
|
+
return (tx: Transaction) =>
|
|
181
|
+
tx.moveCall({
|
|
182
|
+
package: packageAddress,
|
|
183
|
+
module: 'plp',
|
|
184
|
+
function: 'fee_incentive_reserve',
|
|
185
|
+
arguments: normalizeMoveArguments(
|
|
186
|
+
{
|
|
187
|
+
...options.arguments,
|
|
188
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
189
|
+
},
|
|
190
|
+
argumentsTypes,
|
|
191
|
+
parameterNames,
|
|
192
|
+
),
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
export interface PlpTotalSupplyArguments {
|
|
196
|
+
vault?: RawTransactionArgument<string>;
|
|
197
|
+
}
|
|
198
|
+
export interface PlpTotalSupplyOptions {
|
|
199
|
+
package?: string;
|
|
200
|
+
arguments?: PlpTotalSupplyArguments;
|
|
201
|
+
config?: {
|
|
202
|
+
poolVault: ConfigValue;
|
|
203
|
+
predictPackageId?: string;
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
/** Return total PLP supply for SDK and devInspect state reads. */
|
|
207
|
+
export function plpTotalSupply(options: PlpTotalSupplyOptions) {
|
|
208
|
+
const packageAddress =
|
|
209
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
210
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
211
|
+
const parameterNames = ['vault'];
|
|
212
|
+
return (tx: Transaction) =>
|
|
213
|
+
tx.moveCall({
|
|
214
|
+
package: packageAddress,
|
|
215
|
+
module: 'plp',
|
|
216
|
+
function: 'plp_total_supply',
|
|
217
|
+
arguments: normalizeMoveArguments(
|
|
218
|
+
{
|
|
219
|
+
...options.arguments,
|
|
220
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
221
|
+
},
|
|
222
|
+
argumentsTypes,
|
|
223
|
+
parameterNames,
|
|
224
|
+
),
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
export interface SupplyRequestsPendingArguments {
|
|
228
|
+
vault?: RawTransactionArgument<string>;
|
|
229
|
+
}
|
|
230
|
+
export interface SupplyRequestsPendingOptions {
|
|
231
|
+
package?: string;
|
|
232
|
+
arguments?: SupplyRequestsPendingArguments;
|
|
233
|
+
config?: {
|
|
234
|
+
poolVault: ConfigValue;
|
|
235
|
+
predictPackageId?: string;
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/** Return pending LP supply count for SDK and devInspect queue reads. */
|
|
239
|
+
export function supplyRequestsPending(options: SupplyRequestsPendingOptions) {
|
|
240
|
+
const packageAddress =
|
|
241
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
242
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
243
|
+
const parameterNames = ['vault'];
|
|
244
|
+
return (tx: Transaction) =>
|
|
245
|
+
tx.moveCall({
|
|
246
|
+
package: packageAddress,
|
|
247
|
+
module: 'plp',
|
|
248
|
+
function: 'supply_requests_pending',
|
|
249
|
+
arguments: normalizeMoveArguments(
|
|
250
|
+
{
|
|
251
|
+
...options.arguments,
|
|
252
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
253
|
+
},
|
|
254
|
+
argumentsTypes,
|
|
255
|
+
parameterNames,
|
|
256
|
+
),
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
export interface WithdrawRequestsPendingArguments {
|
|
260
|
+
vault?: RawTransactionArgument<string>;
|
|
261
|
+
}
|
|
262
|
+
export interface WithdrawRequestsPendingOptions {
|
|
263
|
+
package?: string;
|
|
264
|
+
arguments?: WithdrawRequestsPendingArguments;
|
|
265
|
+
config?: {
|
|
266
|
+
poolVault: ConfigValue;
|
|
267
|
+
predictPackageId?: string;
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
/** Return pending LP withdrawal count for SDK and devInspect queue reads. */
|
|
271
|
+
export function withdrawRequestsPending(options: WithdrawRequestsPendingOptions) {
|
|
272
|
+
const packageAddress =
|
|
273
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
274
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
275
|
+
const parameterNames = ['vault'];
|
|
276
|
+
return (tx: Transaction) =>
|
|
277
|
+
tx.moveCall({
|
|
278
|
+
package: packageAddress,
|
|
279
|
+
module: 'plp',
|
|
280
|
+
function: 'withdraw_requests_pending',
|
|
281
|
+
arguments: normalizeMoveArguments(
|
|
282
|
+
{
|
|
283
|
+
...options.arguments,
|
|
284
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
285
|
+
},
|
|
286
|
+
argumentsTypes,
|
|
287
|
+
parameterNames,
|
|
288
|
+
),
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
export interface ActiveExpiryMarketsArguments {
|
|
292
|
+
vault?: RawTransactionArgument<string>;
|
|
293
|
+
}
|
|
294
|
+
export interface ActiveExpiryMarketsOptions {
|
|
295
|
+
package?: string;
|
|
296
|
+
arguments?: ActiveExpiryMarketsArguments;
|
|
297
|
+
config?: {
|
|
298
|
+
poolVault: ConfigValue;
|
|
299
|
+
predictPackageId?: string;
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/** Return active expiry IDs for external PTB construction and pool inspection. */
|
|
303
|
+
export function activeExpiryMarkets(options: ActiveExpiryMarketsOptions) {
|
|
304
|
+
const packageAddress =
|
|
305
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
306
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
307
|
+
const parameterNames = ['vault'];
|
|
308
|
+
return (tx: Transaction) =>
|
|
309
|
+
tx.moveCall({
|
|
310
|
+
package: packageAddress,
|
|
311
|
+
module: 'plp',
|
|
312
|
+
function: 'active_expiry_markets',
|
|
313
|
+
arguments: normalizeMoveArguments(
|
|
314
|
+
{
|
|
315
|
+
...options.arguments,
|
|
316
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
317
|
+
},
|
|
318
|
+
argumentsTypes,
|
|
319
|
+
parameterNames,
|
|
320
|
+
),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
export interface ActiveLiveExpiryCountArguments {
|
|
324
|
+
vault?: RawTransactionArgument<string>;
|
|
325
|
+
}
|
|
326
|
+
export interface ActiveLiveExpiryCountOptions {
|
|
327
|
+
package?: string;
|
|
328
|
+
arguments?: ActiveLiveExpiryCountArguments;
|
|
329
|
+
config?: {
|
|
330
|
+
poolVault: ConfigValue;
|
|
331
|
+
predictPackageId?: string;
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
/** Return the pre-expiry active count for SDK and devInspect capacity reads. */
|
|
335
|
+
export function activeLiveExpiryCount(options: ActiveLiveExpiryCountOptions) {
|
|
336
|
+
const packageAddress =
|
|
337
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
338
|
+
const argumentsTypes = [null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
339
|
+
const parameterNames = ['vault'];
|
|
340
|
+
return (tx: Transaction) =>
|
|
341
|
+
tx.moveCall({
|
|
342
|
+
package: packageAddress,
|
|
343
|
+
module: 'plp',
|
|
344
|
+
function: 'active_live_expiry_count',
|
|
345
|
+
arguments: normalizeMoveArguments(
|
|
346
|
+
{
|
|
347
|
+
...options.arguments,
|
|
348
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
349
|
+
},
|
|
350
|
+
argumentsTypes,
|
|
351
|
+
parameterNames,
|
|
352
|
+
),
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
export interface ProfitBasisDebitsArguments {
|
|
356
|
+
vault?: RawTransactionArgument<string>;
|
|
357
|
+
}
|
|
358
|
+
export interface ProfitBasisDebitsOptions {
|
|
359
|
+
package?: string;
|
|
360
|
+
arguments?: ProfitBasisDebitsArguments;
|
|
361
|
+
config?: {
|
|
362
|
+
poolVault: ConfigValue;
|
|
363
|
+
predictPackageId?: string;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
/** Return the profit-basis debits for external accounting observability. */
|
|
367
|
+
export function profitBasisDebits(options: ProfitBasisDebitsOptions) {
|
|
368
|
+
const packageAddress =
|
|
369
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
370
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
371
|
+
const parameterNames = ['vault'];
|
|
372
|
+
return (tx: Transaction) =>
|
|
373
|
+
tx.moveCall({
|
|
374
|
+
package: packageAddress,
|
|
375
|
+
module: 'plp',
|
|
376
|
+
function: 'profit_basis_debits',
|
|
377
|
+
arguments: normalizeMoveArguments(
|
|
378
|
+
{
|
|
379
|
+
...options.arguments,
|
|
380
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
381
|
+
},
|
|
382
|
+
argumentsTypes,
|
|
383
|
+
parameterNames,
|
|
384
|
+
),
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
export interface ProfitBasisCreditsArguments {
|
|
388
|
+
vault?: RawTransactionArgument<string>;
|
|
389
|
+
}
|
|
390
|
+
export interface ProfitBasisCreditsOptions {
|
|
391
|
+
package?: string;
|
|
392
|
+
arguments?: ProfitBasisCreditsArguments;
|
|
393
|
+
config?: {
|
|
394
|
+
poolVault: ConfigValue;
|
|
395
|
+
predictPackageId?: string;
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
/** Return the profit-basis credits for external accounting observability. */
|
|
399
|
+
export function profitBasisCredits(options: ProfitBasisCreditsOptions) {
|
|
400
|
+
const packageAddress =
|
|
401
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
402
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
403
|
+
const parameterNames = ['vault'];
|
|
404
|
+
return (tx: Transaction) =>
|
|
405
|
+
tx.moveCall({
|
|
406
|
+
package: packageAddress,
|
|
407
|
+
module: 'plp',
|
|
408
|
+
function: 'profit_basis_credits',
|
|
409
|
+
arguments: normalizeMoveArguments(
|
|
410
|
+
{
|
|
411
|
+
...options.arguments,
|
|
412
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
413
|
+
},
|
|
414
|
+
argumentsTypes,
|
|
415
|
+
parameterNames,
|
|
416
|
+
),
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
export interface PendingProtocolProfitArguments {
|
|
420
|
+
vault?: RawTransactionArgument<string>;
|
|
421
|
+
}
|
|
422
|
+
export interface PendingProtocolProfitOptions {
|
|
423
|
+
package?: string;
|
|
424
|
+
arguments?: PendingProtocolProfitArguments;
|
|
425
|
+
config?: {
|
|
426
|
+
poolVault: ConfigValue;
|
|
427
|
+
predictPackageId?: string;
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
/** Return deferred protocol profit for external accounting observability. */
|
|
431
|
+
export function pendingProtocolProfit(options: PendingProtocolProfitOptions) {
|
|
432
|
+
const packageAddress =
|
|
433
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
434
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
435
|
+
const parameterNames = ['vault'];
|
|
436
|
+
return (tx: Transaction) =>
|
|
437
|
+
tx.moveCall({
|
|
438
|
+
package: packageAddress,
|
|
439
|
+
module: 'plp',
|
|
440
|
+
function: 'pending_protocol_profit',
|
|
441
|
+
arguments: normalizeMoveArguments(
|
|
442
|
+
{
|
|
443
|
+
...options.arguments,
|
|
444
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
445
|
+
},
|
|
446
|
+
argumentsTypes,
|
|
447
|
+
parameterNames,
|
|
448
|
+
),
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
export interface StartPoolValuationArguments {
|
|
452
|
+
config?: RawTransactionArgument<string>;
|
|
453
|
+
vault?: RawTransactionArgument<string>;
|
|
454
|
+
lifecycleProof: TransactionArgument;
|
|
455
|
+
}
|
|
456
|
+
export interface StartPoolValuationOptions {
|
|
457
|
+
package?: string;
|
|
458
|
+
arguments: StartPoolValuationArguments;
|
|
459
|
+
config?: {
|
|
460
|
+
protocolConfig: ConfigValue;
|
|
461
|
+
poolVault: ConfigValue;
|
|
462
|
+
predictPackageId?: string;
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Begin a full-pool valuation using a registry-issued lifecycle proof. The proof
|
|
467
|
+
* grants control over when current oracle state is frozen for queued LP fills.
|
|
468
|
+
* Starting engages the transaction-local valuation lock and snapshots every active
|
|
469
|
+
* expiry that must be included before the queues can drain.
|
|
470
|
+
*/
|
|
471
|
+
export function startPoolValuation(options: StartPoolValuationOptions) {
|
|
472
|
+
const packageAddress =
|
|
473
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
474
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
475
|
+
const parameterNames = ['config', 'vault', 'lifecycleProof'];
|
|
476
|
+
return (tx: Transaction) =>
|
|
477
|
+
tx.moveCall({
|
|
478
|
+
package: packageAddress,
|
|
479
|
+
module: 'plp',
|
|
480
|
+
function: 'start_pool_valuation',
|
|
481
|
+
arguments: normalizeMoveArguments(
|
|
482
|
+
{
|
|
483
|
+
...options.arguments,
|
|
484
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
485
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
486
|
+
},
|
|
487
|
+
argumentsTypes,
|
|
488
|
+
parameterNames,
|
|
489
|
+
),
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
export interface ValueExpiryArguments {
|
|
493
|
+
valuation: TransactionArgument;
|
|
494
|
+
vault?: RawTransactionArgument<string>;
|
|
495
|
+
market: RawTransactionArgument<string>;
|
|
496
|
+
config?: RawTransactionArgument<string>;
|
|
497
|
+
propbookRegistry?: RawTransactionArgument<string>;
|
|
498
|
+
pyth: RawTransactionArgument<string>;
|
|
499
|
+
bsValues: RawTransactionArgument<string>;
|
|
500
|
+
bsSvi: RawTransactionArgument<string>;
|
|
501
|
+
}
|
|
502
|
+
export interface ValueExpiryOptions {
|
|
503
|
+
package?: string;
|
|
504
|
+
arguments: ValueExpiryArguments;
|
|
505
|
+
config?: {
|
|
506
|
+
poolVault: ConfigValue;
|
|
507
|
+
protocolConfig: ConfigValue;
|
|
508
|
+
oracleRegistry: ConfigValue;
|
|
509
|
+
predictPackageId?: string;
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Run the per-market cash flow for one snapshotted market, then fold its NAV into
|
|
514
|
+
* the running total. The market must be in the snapshot and not already valued. A
|
|
515
|
+
* settled market is swept (deactivated, cash returned, profit materialized) and
|
|
516
|
+
* contributes 0; a live market is rebalanced to target and valued on its current
|
|
517
|
+
* cash.
|
|
518
|
+
*
|
|
519
|
+
* Settlement is a separate PTB step through `expiry_market::try_settle`. An
|
|
520
|
+
* expired unsettled market cannot produce the live pricer required here.
|
|
521
|
+
*/
|
|
522
|
+
export function valueExpiry(options: ValueExpiryOptions) {
|
|
523
|
+
const packageAddress =
|
|
524
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
525
|
+
const argumentsTypes = [
|
|
526
|
+
null,
|
|
527
|
+
null,
|
|
528
|
+
null,
|
|
529
|
+
null,
|
|
530
|
+
null,
|
|
531
|
+
null,
|
|
532
|
+
null,
|
|
533
|
+
null,
|
|
534
|
+
'0x2::clock::Clock',
|
|
535
|
+
] satisfies (string | null)[];
|
|
536
|
+
const parameterNames = [
|
|
537
|
+
'valuation',
|
|
538
|
+
'vault',
|
|
539
|
+
'market',
|
|
540
|
+
'config',
|
|
541
|
+
'propbookRegistry',
|
|
542
|
+
'pyth',
|
|
543
|
+
'bsValues',
|
|
544
|
+
'bsSvi',
|
|
545
|
+
];
|
|
546
|
+
return (tx: Transaction) =>
|
|
547
|
+
tx.moveCall({
|
|
548
|
+
package: packageAddress,
|
|
549
|
+
module: 'plp',
|
|
550
|
+
function: 'value_expiry',
|
|
551
|
+
arguments: normalizeMoveArguments(
|
|
552
|
+
{
|
|
553
|
+
...options.arguments,
|
|
554
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
555
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
556
|
+
propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry,
|
|
557
|
+
},
|
|
558
|
+
argumentsTypes,
|
|
559
|
+
parameterNames,
|
|
560
|
+
),
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
export interface FinishFlushArguments {
|
|
564
|
+
valuation: TransactionArgument;
|
|
565
|
+
vault?: RawTransactionArgument<string>;
|
|
566
|
+
config?: RawTransactionArgument<string>;
|
|
567
|
+
supplyBudget: RawTransactionArgument<number | bigint | null>;
|
|
568
|
+
withdrawBudget: RawTransactionArgument<number | bigint | null>;
|
|
569
|
+
}
|
|
570
|
+
export interface FinishFlushOptions {
|
|
571
|
+
package?: string;
|
|
572
|
+
arguments: FinishFlushArguments;
|
|
573
|
+
config?: {
|
|
574
|
+
poolVault: ConfigValue;
|
|
575
|
+
protocolConfig: ConfigValue;
|
|
576
|
+
predictPackageId?: string;
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* Finish a full-pool valuation and run the LP flush: prove every snapshotted
|
|
581
|
+
* market was valued exactly once, price the pool NAV, then drain the
|
|
582
|
+
* supply/withdraw queues at that frozen mark (mint PLP for supplies, burn PLP and
|
|
583
|
+
* pay DUSDC for withdrawals), release the valuation lock, consume the potato, and
|
|
584
|
+
* return the LP-attributable pool-wide DUSDC NAV (idle + Σ active NAV, net of the
|
|
585
|
+
* pending-protocol-profit exclusion priced from the aggregate profit basis).
|
|
586
|
+
*
|
|
587
|
+
* `supply_budget` and `withdraw_budget` bound how many requests each queue may
|
|
588
|
+
* process this flush (`None` = unbounded). Fills — whole or partial — and
|
|
589
|
+
* protocol-refunded heads — non-executable, or quoting below the request's own
|
|
590
|
+
* minimum output — all count as processed. At `ProtocolConfig`'s shipped attempt
|
|
591
|
+
* count of one, a head that misses its limit is refunded by the flush that reaches
|
|
592
|
+
* it; above one it stays queued and stops that queue for the flush. The budgets
|
|
593
|
+
* are independent, so a supply backlog does not consume withdrawal capacity.
|
|
594
|
+
*
|
|
595
|
+
* Capacity bounds each pass on top of the budgets and refunds nothing: supplies
|
|
596
|
+
* fill only up to `ProtocolConfig`'s LP pool-value cap, withdrawals only up to
|
|
597
|
+
* idle. A head larger than the room left fills to the room, spends flush budget,
|
|
598
|
+
* and keeps its remainder queued at a rescaled limit; a head with no usable room
|
|
599
|
+
* carries untouched and spends none. Either way the pass stops, so an unbounded
|
|
600
|
+
* budget does not mean every queued request is processed (RP-23).
|
|
601
|
+
*
|
|
602
|
+
* Because queueing is permissionless and a refunded request returns its escrow in
|
|
603
|
+
* the same transaction, an operator should bound both budgets in production rather
|
|
604
|
+
* than rely on queue length staying small — see RP-12.
|
|
605
|
+
*/
|
|
606
|
+
export function finishFlush(options: FinishFlushOptions) {
|
|
607
|
+
const packageAddress =
|
|
608
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
609
|
+
const argumentsTypes = [
|
|
610
|
+
null,
|
|
611
|
+
null,
|
|
612
|
+
null,
|
|
613
|
+
'0x1::option::Option<u64>',
|
|
614
|
+
'0x1::option::Option<u64>',
|
|
615
|
+
] satisfies (string | null)[];
|
|
616
|
+
const parameterNames = ['valuation', 'vault', 'config', 'supplyBudget', 'withdrawBudget'];
|
|
617
|
+
return (tx: Transaction) =>
|
|
618
|
+
tx.moveCall({
|
|
619
|
+
package: packageAddress,
|
|
620
|
+
module: 'plp',
|
|
621
|
+
function: 'finish_flush',
|
|
622
|
+
arguments: normalizeMoveArguments(
|
|
623
|
+
{
|
|
624
|
+
...options.arguments,
|
|
625
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
626
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
627
|
+
},
|
|
628
|
+
argumentsTypes,
|
|
629
|
+
parameterNames,
|
|
630
|
+
),
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
export interface RebalanceExpiryCashArguments {
|
|
634
|
+
vault?: RawTransactionArgument<string>;
|
|
635
|
+
market: RawTransactionArgument<string>;
|
|
636
|
+
config?: RawTransactionArgument<string>;
|
|
637
|
+
}
|
|
638
|
+
export interface RebalanceExpiryCashOptions {
|
|
639
|
+
package?: string;
|
|
640
|
+
arguments: RebalanceExpiryCashArguments;
|
|
641
|
+
config?: {
|
|
642
|
+
poolVault: ConfigValue;
|
|
643
|
+
protocolConfig: ConfigValue;
|
|
644
|
+
predictPackageId?: string;
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Move cash between pool idle liquidity and one expiry market.
|
|
649
|
+
*
|
|
650
|
+
* Permissionless and standalone: anyone may call it at any cadence. Handles all
|
|
651
|
+
* three per-market cases — initial funding of a freshly registered (unfunded)
|
|
652
|
+
* market, ongoing live rebalance/surplus-sweep toward target, and the
|
|
653
|
+
* settled-market sweep (deactivate, return all free cash, materialize profit).
|
|
654
|
+
* Call `expiry_market::try_settle` first in the same PTB when settlement may be
|
|
655
|
+
* due. An expired unsettled market is a no-op until that transition succeeds. Mint
|
|
656
|
+
* asserts backing but never pulls pool cash, so this is what makes a market
|
|
657
|
+
* mintable. The market must already be registered to this vault
|
|
658
|
+
* (`registry::create_and_share_expiry_market`). Blocked while a full-pool
|
|
659
|
+
* valuation is in progress.
|
|
660
|
+
*/
|
|
661
|
+
export function rebalanceExpiryCash(options: RebalanceExpiryCashOptions) {
|
|
662
|
+
const packageAddress =
|
|
663
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
664
|
+
const argumentsTypes = [null, null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
665
|
+
const parameterNames = ['vault', 'market', 'config'];
|
|
666
|
+
return (tx: Transaction) =>
|
|
667
|
+
tx.moveCall({
|
|
668
|
+
package: packageAddress,
|
|
669
|
+
module: 'plp',
|
|
670
|
+
function: 'rebalance_expiry_cash',
|
|
671
|
+
arguments: normalizeMoveArguments(
|
|
672
|
+
{
|
|
673
|
+
...options.arguments,
|
|
674
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
675
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
676
|
+
},
|
|
677
|
+
argumentsTypes,
|
|
678
|
+
parameterNames,
|
|
679
|
+
),
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
export interface SponsorFeeIncentivesArguments {
|
|
683
|
+
vault?: RawTransactionArgument<string>;
|
|
684
|
+
config?: RawTransactionArgument<string>;
|
|
685
|
+
payment: RawTransactionArgument<string>;
|
|
686
|
+
}
|
|
687
|
+
export interface SponsorFeeIncentivesOptions {
|
|
688
|
+
package?: string;
|
|
689
|
+
arguments: SponsorFeeIncentivesArguments;
|
|
690
|
+
config?: {
|
|
691
|
+
poolVault: ConfigValue;
|
|
692
|
+
protocolConfig: ConfigValue;
|
|
693
|
+
predictPackageId?: string;
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* Sponsor taker fee incentives with DUSDC. Anyone may contribute; the payment
|
|
698
|
+
* joins a pool-level reserve that is excluded from PLP NAV and later allocated to
|
|
699
|
+
* expiry markets by the normal rebalance flow.
|
|
700
|
+
*/
|
|
701
|
+
export function sponsorFeeIncentives(options: SponsorFeeIncentivesOptions) {
|
|
702
|
+
const packageAddress =
|
|
703
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
704
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
705
|
+
const parameterNames = ['vault', 'config', 'payment'];
|
|
706
|
+
return (tx: Transaction) =>
|
|
707
|
+
tx.moveCall({
|
|
708
|
+
package: packageAddress,
|
|
709
|
+
module: 'plp',
|
|
710
|
+
function: 'sponsor_fee_incentives',
|
|
711
|
+
arguments: normalizeMoveArguments(
|
|
712
|
+
{
|
|
713
|
+
...options.arguments,
|
|
714
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
715
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
716
|
+
},
|
|
717
|
+
argumentsTypes,
|
|
718
|
+
parameterNames,
|
|
719
|
+
),
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
export interface LockCapitalArguments {
|
|
723
|
+
vault?: RawTransactionArgument<string>;
|
|
724
|
+
config?: RawTransactionArgument<string>;
|
|
725
|
+
AdminCap: RawTransactionArgument<string>;
|
|
726
|
+
payment: RawTransactionArgument<string>;
|
|
727
|
+
}
|
|
728
|
+
export interface LockCapitalOptions {
|
|
729
|
+
package?: string;
|
|
730
|
+
arguments: LockCapitalArguments;
|
|
731
|
+
config?: {
|
|
732
|
+
poolVault: ConfigValue;
|
|
733
|
+
protocolConfig: ConfigValue;
|
|
734
|
+
predictPackageId?: string;
|
|
735
|
+
};
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Bootstrap the pool exactly once: permanently lock `payment` DUSDC of minimum
|
|
739
|
+
* liquidity. Mints matching PLP (1:1) into the book's locked balance — never
|
|
740
|
+
* withdrawable, so the caller receives no shares — and joins the DUSDC into idle.
|
|
741
|
+
* This keeps `total_supply > 0` while the vault exists and gives rounding dust a
|
|
742
|
+
* non-withdrawable PLP holder. Requires root authority and zero existing supply.
|
|
743
|
+
* Supply, withdrawal, and flush flows remain disabled until the locked liquidity
|
|
744
|
+
* has been created.
|
|
745
|
+
*/
|
|
746
|
+
export function lockCapital(options: LockCapitalOptions) {
|
|
747
|
+
const packageAddress =
|
|
748
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
749
|
+
const argumentsTypes = [null, null, null, null] satisfies (string | null)[];
|
|
750
|
+
const parameterNames = ['vault', 'config', 'AdminCap', 'payment'];
|
|
751
|
+
return (tx: Transaction) =>
|
|
752
|
+
tx.moveCall({
|
|
753
|
+
package: packageAddress,
|
|
754
|
+
module: 'plp',
|
|
755
|
+
function: 'lock_capital',
|
|
756
|
+
arguments: normalizeMoveArguments(
|
|
757
|
+
{
|
|
758
|
+
...options.arguments,
|
|
759
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
760
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
761
|
+
},
|
|
762
|
+
argumentsTypes,
|
|
763
|
+
parameterNames,
|
|
764
|
+
),
|
|
765
|
+
});
|
|
766
|
+
}
|
|
767
|
+
export interface RequestSupplyArguments {
|
|
768
|
+
vault?: RawTransactionArgument<string>;
|
|
769
|
+
wrapper: RawTransactionArgument<string>;
|
|
770
|
+
auth: TransactionArgument;
|
|
771
|
+
config?: RawTransactionArgument<string>;
|
|
772
|
+
amount: RawTransactionArgument<number | bigint>;
|
|
773
|
+
minPlpOut: RawTransactionArgument<number | bigint>;
|
|
774
|
+
}
|
|
775
|
+
export interface RequestSupplyOptions {
|
|
776
|
+
package?: string;
|
|
777
|
+
arguments: RequestSupplyArguments;
|
|
778
|
+
config?: {
|
|
779
|
+
poolVault: ConfigValue;
|
|
780
|
+
protocolConfig: ConfigValue;
|
|
781
|
+
predictPackageId?: string;
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Queue a supply request: pull `amount` DUSDC from account custody into queue
|
|
786
|
+
* escrow, recording the account's receive address as the fill recipient. The pull
|
|
787
|
+
* auto-settles any flush-delivered DUSDC first. The flush charges the protocol's
|
|
788
|
+
* supply fee — zero by default — on the DUSDC it takes in and prices shares on the
|
|
789
|
+
* remainder, so `min_plp_out` is measured after that fee. The account receives
|
|
790
|
+
* minted PLP only at a mark that mints at least `min_plp_out` for the whole
|
|
791
|
+
* `amount` — a **price floor**, not a promise of that many shares: if the pool cap
|
|
792
|
+
* leaves room for only part of the deposit, the fill is proportionally smaller at
|
|
793
|
+
* the same price and the remainder stays queued with its limit rescaled. At the
|
|
794
|
+
* shipped attempt count of one, a flush whose mark quotes less cancels and refunds
|
|
795
|
+
* the request there and then; a higher configured count lets it rest and retry
|
|
796
|
+
* that many flushes first. Returns the queue index, the handle used to cancel
|
|
797
|
+
* before the flush.
|
|
798
|
+
*/
|
|
799
|
+
export function requestSupply(options: RequestSupplyOptions) {
|
|
800
|
+
const packageAddress =
|
|
801
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
802
|
+
const argumentsTypes = [
|
|
803
|
+
null,
|
|
804
|
+
null,
|
|
805
|
+
null,
|
|
806
|
+
null,
|
|
807
|
+
'u64',
|
|
808
|
+
'u64',
|
|
809
|
+
'0x2::accumulator::AccumulatorRoot',
|
|
810
|
+
'0x2::clock::Clock',
|
|
811
|
+
] satisfies (string | null)[];
|
|
812
|
+
const parameterNames = ['vault', 'wrapper', 'auth', 'config', 'amount', 'minPlpOut'];
|
|
813
|
+
return (tx: Transaction) =>
|
|
814
|
+
tx.moveCall({
|
|
815
|
+
package: packageAddress,
|
|
816
|
+
module: 'plp',
|
|
817
|
+
function: 'request_supply',
|
|
818
|
+
arguments: normalizeMoveArguments(
|
|
819
|
+
{
|
|
820
|
+
...options.arguments,
|
|
821
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
822
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
823
|
+
},
|
|
824
|
+
argumentsTypes,
|
|
825
|
+
parameterNames,
|
|
826
|
+
),
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
export interface RequestWithdrawArguments {
|
|
830
|
+
vault?: RawTransactionArgument<string>;
|
|
831
|
+
wrapper: RawTransactionArgument<string>;
|
|
832
|
+
auth: TransactionArgument;
|
|
833
|
+
config?: RawTransactionArgument<string>;
|
|
834
|
+
amount: RawTransactionArgument<number | bigint>;
|
|
835
|
+
minDusdcOut: RawTransactionArgument<number | bigint>;
|
|
836
|
+
}
|
|
837
|
+
export interface RequestWithdrawOptions {
|
|
838
|
+
package?: string;
|
|
839
|
+
arguments: RequestWithdrawArguments;
|
|
840
|
+
config?: {
|
|
841
|
+
poolVault: ConfigValue;
|
|
842
|
+
protocolConfig: ConfigValue;
|
|
843
|
+
predictPackageId?: string;
|
|
844
|
+
};
|
|
845
|
+
}
|
|
846
|
+
/**
|
|
847
|
+
* Queue a withdraw request: pull `amount` PLP shares from account custody into
|
|
848
|
+
* queue escrow, recording the account's receive address as the fill recipient. The
|
|
849
|
+
* pull auto-settles any flush-delivered PLP first. The flush withholds the
|
|
850
|
+
* protocol's withdraw fee from the marked payout, so `min_dusdc_out` is measured
|
|
851
|
+
* after the fee. The account is paid only at a mark that quotes at least
|
|
852
|
+
* `min_dusdc_out` for the whole `amount` — a **price floor**, not a promise of
|
|
853
|
+
* that much DUSDC: if idle liquidity covers only part of the payout, only the
|
|
854
|
+
* shares idle affords are burned, the fill is proportionally smaller at the same
|
|
855
|
+
* price, and the remainder stays queued with its limit rescaled. At the shipped
|
|
856
|
+
* attempt count of one, a flush whose mark quotes less cancels and refunds the
|
|
857
|
+
* request there and then; a higher configured count lets it rest and retry that
|
|
858
|
+
* many flushes first. Returns the queue index used to cancel before the flush.
|
|
859
|
+
*/
|
|
860
|
+
export function requestWithdraw(options: RequestWithdrawOptions) {
|
|
861
|
+
const packageAddress =
|
|
862
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
863
|
+
const argumentsTypes = [
|
|
864
|
+
null,
|
|
865
|
+
null,
|
|
866
|
+
null,
|
|
867
|
+
null,
|
|
868
|
+
'u64',
|
|
869
|
+
'u64',
|
|
870
|
+
'0x2::accumulator::AccumulatorRoot',
|
|
871
|
+
'0x2::clock::Clock',
|
|
872
|
+
] satisfies (string | null)[];
|
|
873
|
+
const parameterNames = ['vault', 'wrapper', 'auth', 'config', 'amount', 'minDusdcOut'];
|
|
874
|
+
return (tx: Transaction) =>
|
|
875
|
+
tx.moveCall({
|
|
876
|
+
package: packageAddress,
|
|
877
|
+
module: 'plp',
|
|
878
|
+
function: 'request_withdraw',
|
|
879
|
+
arguments: normalizeMoveArguments(
|
|
880
|
+
{
|
|
881
|
+
...options.arguments,
|
|
882
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
883
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
884
|
+
},
|
|
885
|
+
argumentsTypes,
|
|
886
|
+
parameterNames,
|
|
887
|
+
),
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
export interface CancelSupplyRequestArguments {
|
|
891
|
+
vault?: RawTransactionArgument<string>;
|
|
892
|
+
wrapper: RawTransactionArgument<string>;
|
|
893
|
+
auth: TransactionArgument;
|
|
894
|
+
config?: RawTransactionArgument<string>;
|
|
895
|
+
index: RawTransactionArgument<number | bigint>;
|
|
896
|
+
}
|
|
897
|
+
export interface CancelSupplyRequestOptions {
|
|
898
|
+
package?: string;
|
|
899
|
+
arguments: CancelSupplyRequestArguments;
|
|
900
|
+
config?: {
|
|
901
|
+
poolVault: ConfigValue;
|
|
902
|
+
protocolConfig: ConfigValue;
|
|
903
|
+
predictPackageId?: string;
|
|
904
|
+
};
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Cancel a still-pending supply request, refunding its escrowed DUSDC straight
|
|
908
|
+
* into the requesting account. `account` must be the request's recorded recipient.
|
|
909
|
+
*/
|
|
910
|
+
export function cancelSupplyRequest(options: CancelSupplyRequestOptions) {
|
|
911
|
+
const packageAddress =
|
|
912
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
913
|
+
const argumentsTypes = [
|
|
914
|
+
null,
|
|
915
|
+
null,
|
|
916
|
+
null,
|
|
917
|
+
null,
|
|
918
|
+
'u64',
|
|
919
|
+
'0x2::accumulator::AccumulatorRoot',
|
|
920
|
+
'0x2::clock::Clock',
|
|
921
|
+
] satisfies (string | null)[];
|
|
922
|
+
const parameterNames = ['vault', 'wrapper', 'auth', 'config', 'index'];
|
|
923
|
+
return (tx: Transaction) =>
|
|
924
|
+
tx.moveCall({
|
|
925
|
+
package: packageAddress,
|
|
926
|
+
module: 'plp',
|
|
927
|
+
function: 'cancel_supply_request',
|
|
928
|
+
arguments: normalizeMoveArguments(
|
|
929
|
+
{
|
|
930
|
+
...options.arguments,
|
|
931
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
932
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
933
|
+
},
|
|
934
|
+
argumentsTypes,
|
|
935
|
+
parameterNames,
|
|
936
|
+
),
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
export interface CancelWithdrawRequestArguments {
|
|
940
|
+
vault?: RawTransactionArgument<string>;
|
|
941
|
+
wrapper: RawTransactionArgument<string>;
|
|
942
|
+
auth: TransactionArgument;
|
|
943
|
+
config?: RawTransactionArgument<string>;
|
|
944
|
+
index: RawTransactionArgument<number | bigint>;
|
|
945
|
+
}
|
|
946
|
+
export interface CancelWithdrawRequestOptions {
|
|
947
|
+
package?: string;
|
|
948
|
+
arguments: CancelWithdrawRequestArguments;
|
|
949
|
+
config?: {
|
|
950
|
+
poolVault: ConfigValue;
|
|
951
|
+
protocolConfig: ConfigValue;
|
|
952
|
+
predictPackageId?: string;
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
/**
|
|
956
|
+
* Cancel a still-pending withdraw request, refunding its escrowed PLP straight
|
|
957
|
+
* into the requesting account. `account` must be the request's recorded recipient.
|
|
958
|
+
*/
|
|
959
|
+
export function cancelWithdrawRequest(options: CancelWithdrawRequestOptions) {
|
|
960
|
+
const packageAddress =
|
|
961
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
962
|
+
const argumentsTypes = [
|
|
963
|
+
null,
|
|
964
|
+
null,
|
|
965
|
+
null,
|
|
966
|
+
null,
|
|
967
|
+
'u64',
|
|
968
|
+
'0x2::accumulator::AccumulatorRoot',
|
|
969
|
+
'0x2::clock::Clock',
|
|
970
|
+
] satisfies (string | null)[];
|
|
971
|
+
const parameterNames = ['vault', 'wrapper', 'auth', 'config', 'index'];
|
|
972
|
+
return (tx: Transaction) =>
|
|
973
|
+
tx.moveCall({
|
|
974
|
+
package: packageAddress,
|
|
975
|
+
module: 'plp',
|
|
976
|
+
function: 'cancel_withdraw_request',
|
|
977
|
+
arguments: normalizeMoveArguments(
|
|
978
|
+
{
|
|
979
|
+
...options.arguments,
|
|
980
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
981
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
982
|
+
},
|
|
983
|
+
argumentsTypes,
|
|
984
|
+
parameterNames,
|
|
985
|
+
),
|
|
986
|
+
});
|
|
987
|
+
}
|