@mysten/deepbook-v3 2.1.4 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/PREDICT.md +154 -48
- package/README.md +18 -13
- package/dist/account.d.mts.map +1 -1
- package/dist/account.mjs +3 -1
- package/dist/account.mjs.map +1 -1
- package/dist/client.d.mts +2 -2
- package/dist/contracts/account/account.d.mts +23 -23
- package/dist/contracts/account/account.d.mts.map +1 -1
- package/dist/contracts/account/account_events.d.mts +20 -20
- package/dist/contracts/account/account_registry.d.mts +19 -19
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.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_predict/admin.d.mts +27 -0
- package/dist/contracts/deepbook_predict/admin.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/admin.mjs +38 -0
- package/dist/contracts/deepbook_predict/admin.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/builder_code.d.mts +81 -0
- package/dist/contracts/deepbook_predict/builder_code.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/builder_code.mjs +103 -0
- package/dist/contracts/deepbook_predict/builder_code.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts +25 -0
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/builder_code_events.mjs +7 -1
- package/dist/contracts/deepbook_predict/builder_code_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/config_events.d.mts +104 -0
- package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/config_events.mjs +155 -0
- package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_map.mjs +37 -0
- package/dist/contracts/deepbook_predict/deps/sui/vec_map.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/ewma_config.mjs +28 -0
- package/dist/contracts/deepbook_predict/ewma_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_cash.mjs +1 -1
- package/dist/contracts/deepbook_predict/expiry_cash.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.d.mts +859 -0
- package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.mjs +662 -7
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +39 -0
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.mjs +51 -0
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/market_manager.d.mts +159 -0
- package/dist/contracts/deepbook_predict/market_manager.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/market_manager.mjs +88 -2
- package/dist/contracts/deepbook_predict/market_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.d.mts +101 -0
- package/dist/contracts/deepbook_predict/order_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/order_events.mjs +7 -1
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pause_cap.d.mts +39 -0
- package/dist/contracts/deepbook_predict/pause_cap.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/pause_cap.mjs +51 -0
- package/dist/contracts/deepbook_predict/pause_cap.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/plp.d.mts +801 -0
- package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/plp.mjs +511 -32
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +7 -7
- package/dist/contracts/deepbook_predict/pool_accounting.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +39 -0
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/pool_valuation_cap.mjs +52 -0
- package/dist/contracts/deepbook_predict/pool_valuation_cap.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/predict_account.d.mts +90 -0
- package/dist/contracts/deepbook_predict/predict_account.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/predict_account.mjs +25 -2
- package/dist/contracts/deepbook_predict/predict_account.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.d.mts +127 -0
- package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/pricing.mjs +37 -1
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing_config.mjs +28 -0
- package/dist/contracts/deepbook_predict/pricing_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/protocol_config.d.mts +665 -0
- package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/protocol_config.mjs +841 -0
- package/dist/contracts/deepbook_predict/protocol_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/range_codec.d.mts +30 -0
- package/dist/contracts/deepbook_predict/range_codec.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/range_codec.mjs +6 -1
- package/dist/contracts/deepbook_predict/range_codec.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/registry.d.mts +382 -0
- package/dist/contracts/deepbook_predict/registry.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/registry.mjs +458 -2
- package/dist/contracts/deepbook_predict/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +13 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.d.mts +199 -0
- package/dist/contracts/deepbook_predict/vault_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict/vault_events.mjs +38 -8
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -1
- package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
- package/dist/contracts/deepbook_sessions/session_config.d.mts.map +1 -1
- package/dist/contracts/deepbook_sessions/sessions.d.mts +22 -22
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/deployments/index.d.mts +3 -2
- package/dist/deployments/index.d.mts.map +1 -1
- package/dist/deployments/index.mjs +4 -1
- package/dist/deployments/index.mjs.map +1 -1
- package/dist/deployments/mainnet.d.mts +14 -0
- package/dist/deployments/mainnet.d.mts.map +1 -0
- package/dist/deployments/mainnet.mjs +73 -0
- package/dist/deployments/mainnet.mjs.map +1 -0
- package/dist/deployments/testnet.mjs +23 -23
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/deployments/types.d.mts +1 -1
- package/dist/predict/client.d.mts +28 -6
- package/dist/predict/client.d.mts.map +1 -1
- package/dist/predict/client.mjs +7 -6
- package/dist/predict/client.mjs.map +1 -1
- package/dist/predict/config/index.d.mts +2 -0
- package/dist/predict/config/index.d.mts.map +1 -1
- package/dist/predict/config/index.mjs +4 -1
- package/dist/predict/config/index.mjs.map +1 -1
- package/dist/predict/config/mainnet.d.mts +17 -0
- package/dist/predict/config/mainnet.d.mts.map +1 -0
- package/dist/predict/config/mainnet.mjs +26 -0
- package/dist/predict/config/mainnet.mjs.map +1 -0
- package/dist/predict/config/types.d.mts +6 -0
- package/dist/predict/config/types.d.mts.map +1 -1
- package/dist/predict/index.d.mts +21 -2
- package/dist/predict/index.mjs +20 -1
- package/dist/predict/pricing.d.mts +6 -6
- package/dist/predict/pricing.d.mts.map +1 -1
- package/dist/predict/pricing.mjs +6 -6
- package/dist/predict/pricing.mjs.map +1 -1
- package/dist/predict/reads/balances.mjs.map +1 -1
- package/dist/predict/reads/markets.mjs +1 -1
- package/dist/predict/reads/markets.mjs.map +1 -1
- package/dist/predict/reads/pricing.d.mts +2 -1
- package/dist/predict/reads/pricing.d.mts.map +1 -1
- package/dist/predict/reads/pricing.mjs.map +1 -1
- package/dist/sessions.d.mts.map +1 -1
- package/dist/sessions.mjs +3 -1
- package/dist/sessions.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/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/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/package.json +3 -3
- package/src/account.ts +3 -1
- package/src/contracts/deepbook_predict/builder_code.ts +3 -3
- package/src/contracts/deepbook_predict/config_events.ts +9 -2
- package/src/contracts/deepbook_predict/deps/sui/vec_map.ts +33 -0
- package/src/contracts/deepbook_predict/expiry_cash.ts +1 -1
- package/src/contracts/deepbook_predict/expiry_market.ts +70 -11
- package/src/contracts/deepbook_predict/market_lifecycle_cap.ts +3 -10
- package/src/contracts/deepbook_predict/market_manager.ts +2 -2
- package/src/contracts/deepbook_predict/order_events.ts +6 -6
- package/src/contracts/deepbook_predict/plp.ts +263 -81
- package/src/contracts/deepbook_predict/pool_accounting.ts +14 -14
- package/src/contracts/deepbook_predict/pool_valuation_cap.ts +69 -0
- package/src/contracts/deepbook_predict/predict_account.ts +1 -1
- package/src/contracts/deepbook_predict/pricing.ts +16 -4
- package/src/contracts/deepbook_predict/protocol_config.ts +202 -7
- package/src/contracts/deepbook_predict/registry.ts +91 -17
- package/src/contracts/deepbook_predict/strike_exposure.ts +1 -1
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +27 -0
- package/src/contracts/deepbook_predict/vault_events.ts +45 -14
- package/src/contracts/propbook/block_scholes_store.ts +8 -42
- package/src/deployments/index.ts +13 -3
- package/src/deployments/mainnet.ts +107 -0
- package/src/deployments/testnet.ts +25 -25
- package/src/deployments/types.ts +1 -1
- package/src/predict/client.ts +48 -17
- package/src/predict/config/index.ts +7 -2
- package/src/predict/config/mainnet.ts +27 -0
- package/src/predict/config/types.ts +7 -1
- package/src/predict/index.ts +31 -2
- package/src/predict/pricing.ts +11 -9
- package/src/predict/reads/balances.ts +1 -1
- package/src/predict/reads/markets.ts +1 -1
- package/src/predict/reads/pricing.ts +2 -1
- package/src/sessions.ts +4 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plp.d.mts","names":[],"sources":["../../../src/contracts/deepbook_predict/plp.ts"],"mappings":";;;;;;;;;cAkCa,GAAA,EAAG,UAAA;eAKd,kBAAA,CAAA,OAAA;AAAA;AAAA,cACW,kBAAA,EAAkB,UAAA;eAK7B,kBAAA,CAAA,OAAA;AAAA;AAAA,cACW,aAAA,EAAa,UAAA;eAKxB,kBAAA,CAAA,OAAA;AAAA;AAAA,cACW,aAAA,EAAa,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gEADxB;;EALwB;;;;;;AAM1B;;;;;;;;;;;;;;;;;;;;;;;cAuDa,SAAA,EAAS,UAAA;;;;;;;;0CAvDI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EAChB,OAAA;EACA,SAAA,EAAW,4BAAA;EACX,MAAA;IACC,SAAA,EAAW,WAAA;IACX,cAAA,EAAgB,WAAA;IAChB,gBAAA;EAAA;AAAA;;;;AA3pBF;iBAkqBgB,mBAAA,CAAoB,OAAA,EAAS,0BAAA,IAapC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;AAAA,UAgBP,8BAAA;EAChB,KAAA,GAAQ,sBAAA;EACR,OAAA,EAAS,sBAAA;EACT,IAAA,EAAM,mBAAA;EACN,MAAA,GAAS,sBAAA;EACT,KAAA,EAAO,sBAAA;AAAA;AAAA,UAES,4BAAA;EAChB,OAAA;EACA,SAAA,EAAW,8BAAA;EACX,MAAA;IACC,SAAA,EAAW,WAAA;IACX,cAAA,EAAgB,WAAA;IAChB,gBAAA;EAAA;AAAA;AAhsBF;;;;AAAA,iBAusBgB,qBAAA,CAAsB,OAAA,EAAS,4BAAA,IAatC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { __exportAll } from "../../_virtual/rolldown_runtime.mjs";
|
|
1
2
|
import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
|
|
2
3
|
import { U64 } from "../../bcs/integers.mjs";
|
|
3
4
|
import { Balance } from "./deps/sui/balance.mjs";
|
|
5
|
+
import { VecMap } from "./deps/sui/vec_map.mjs";
|
|
6
|
+
import { FrozenPricer } from "./pricing.mjs";
|
|
4
7
|
import { LpBook } from "./lp_book.mjs";
|
|
5
8
|
import { Ledger } from "./pool_accounting.mjs";
|
|
6
9
|
import { bcs } from "@mysten/sui/bcs";
|
|
@@ -12,21 +15,80 @@ import { bcs } from "@mysten/sui/bcs";
|
|
|
12
15
|
/**
|
|
13
16
|
* PLP token and pool vault.
|
|
14
17
|
*
|
|
15
|
-
* PoolVault owns the PLP treasury cap, idle
|
|
18
|
+
* PoolVault owns the PLP treasury cap, idle USDC, the protocol reserve,
|
|
16
19
|
* sponsor-funded fee incentives, per-expiry cash accounting, and the queued LP
|
|
17
|
-
* supply/withdraw requests. It coordinates the full-pool NAV valuation
|
|
18
|
-
*
|
|
20
|
+
* supply/withdraw requests. It coordinates the full-pool NAV valuation — an atomic
|
|
21
|
+
* oracle snapshot followed by resumable per-market valuation transactions, with
|
|
22
|
+
* trading live throughout (see `PoolValuation`) — and the unified per-market cash
|
|
19
23
|
* flow (initial funding, live rebalance/sweep, and settled-market sweep with
|
|
20
24
|
* terminal profit materialization). LPs queue supply/withdraw requests routed
|
|
21
|
-
* through a loaded Account; each flush (`finish_flush`) drains
|
|
22
|
-
* pool NAV, minting/burning PLP and delivering
|
|
23
|
-
* balance accumulator.
|
|
25
|
+
* through a loaded Account; each flush (`finish_flush`) drains the requests that
|
|
26
|
+
* predate its snapshot at the frozen pool NAV, minting/burning PLP and delivering
|
|
27
|
+
* fills to each account via the balance accumulator.
|
|
24
28
|
*/
|
|
29
|
+
var plp_exports = /* @__PURE__ */ __exportAll({
|
|
30
|
+
PLP: () => PLP,
|
|
31
|
+
PoolValuation: () => PoolValuation,
|
|
32
|
+
PoolValuationProof: () => PoolValuationProof,
|
|
33
|
+
PoolVault: () => PoolVault,
|
|
34
|
+
SnapshotStage: () => SnapshotStage,
|
|
35
|
+
activeExpiryMarkets: () => activeExpiryMarkets,
|
|
36
|
+
activeLiveExpiryCount: () => activeLiveExpiryCount,
|
|
37
|
+
cancelSupplyRequest: () => cancelSupplyRequest,
|
|
38
|
+
cancelWithdrawRequest: () => cancelWithdrawRequest,
|
|
39
|
+
feeIncentiveReserve: () => feeIncentiveReserve,
|
|
40
|
+
finishFlush: () => finishFlush,
|
|
41
|
+
id: () => id,
|
|
42
|
+
idleBalance: () => idleBalance,
|
|
43
|
+
lockCapital: () => lockCapital,
|
|
44
|
+
pendingProtocolProfit: () => pendingProtocolProfit,
|
|
45
|
+
plpTotalSupply: () => plpTotalSupply,
|
|
46
|
+
profitBasisCredits: () => profitBasisCredits,
|
|
47
|
+
profitBasisDebits: () => profitBasisDebits,
|
|
48
|
+
protocolReserveBalance: () => protocolReserveBalance,
|
|
49
|
+
rebalanceExpiryCash: () => rebalanceExpiryCash,
|
|
50
|
+
requestSupply: () => requestSupply,
|
|
51
|
+
requestWithdraw: () => requestWithdraw,
|
|
52
|
+
sealValuationSnapshot: () => sealValuationSnapshot,
|
|
53
|
+
snapshotExpiryPricer: () => snapshotExpiryPricer,
|
|
54
|
+
sponsorFeeIncentives: () => sponsorFeeIncentives,
|
|
55
|
+
startPoolValuation: () => startPoolValuation,
|
|
56
|
+
supplyRequestsPending: () => supplyRequestsPending,
|
|
57
|
+
valueExpiry: () => valueExpiry,
|
|
58
|
+
withdrawRequestsPending: () => withdrawRequestsPending
|
|
59
|
+
});
|
|
25
60
|
const $moduleName = "@local-pkg/deepbook_predict::plp";
|
|
26
61
|
const PLP = new MoveStruct({
|
|
27
62
|
name: `${$moduleName}::PLP`,
|
|
28
63
|
fields: { dummy_field: bcs.bool() }
|
|
29
64
|
});
|
|
65
|
+
const PoolValuationProof = new MoveStruct({
|
|
66
|
+
name: `${$moduleName}::PoolValuationProof`,
|
|
67
|
+
fields: { dummy_field: bcs.bool() }
|
|
68
|
+
});
|
|
69
|
+
const SnapshotStage = new MoveStruct({
|
|
70
|
+
name: `${$moduleName}::SnapshotStage`,
|
|
71
|
+
fields: { dummy_field: bcs.bool() }
|
|
72
|
+
});
|
|
73
|
+
const PoolValuation = new MoveStruct({
|
|
74
|
+
name: `${$moduleName}::PoolValuation`,
|
|
75
|
+
fields: {
|
|
76
|
+
expected_expiry_markets: bcs.vector(bcs.Address),
|
|
77
|
+
valued_expiry_markets: bcs.vector(bcs.Address),
|
|
78
|
+
total_nav: U64,
|
|
79
|
+
frozen_pricers: VecMap(bcs.Address, bcs.option(FrozenPricer)),
|
|
80
|
+
sealed: bcs.bool(),
|
|
81
|
+
started_at_ms: U64,
|
|
82
|
+
supply_budget: bcs.option(U64),
|
|
83
|
+
withdraw_budget: bcs.option(U64),
|
|
84
|
+
supply_request_cutoff: U64,
|
|
85
|
+
withdraw_request_cutoff: U64,
|
|
86
|
+
frozen_idle_balance: U64,
|
|
87
|
+
frozen_profit_basis_credits: U64,
|
|
88
|
+
frozen_profit_basis_debits: U64,
|
|
89
|
+
frozen_pending_protocol_profit: U64
|
|
90
|
+
}
|
|
91
|
+
});
|
|
30
92
|
const PoolVault = new MoveStruct({
|
|
31
93
|
name: `${$moduleName}::PoolVault`,
|
|
32
94
|
fields: {
|
|
@@ -34,19 +96,26 @@ const PoolVault = new MoveStruct({
|
|
|
34
96
|
protocol_reserve_balance: Balance,
|
|
35
97
|
fee_incentive_reserve: Balance,
|
|
36
98
|
lp: LpBook,
|
|
37
|
-
expiry_accounting: Ledger
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
const PoolValuation = new MoveStruct({
|
|
41
|
-
name: `${$moduleName}::PoolValuation`,
|
|
42
|
-
fields: {
|
|
43
|
-
pool_vault_id: bcs.Address,
|
|
44
|
-
expected_expiry_markets: bcs.vector(bcs.Address),
|
|
45
|
-
valued_expiry_markets: bcs.vector(bcs.Address),
|
|
46
|
-
total_nav: U64
|
|
99
|
+
expiry_accounting: Ledger,
|
|
100
|
+
valuation: bcs.option(PoolValuation)
|
|
47
101
|
}
|
|
48
102
|
});
|
|
49
|
-
/** Return
|
|
103
|
+
/** Return the pool vault object ID for external discovery and PTB construction. */
|
|
104
|
+
function id(options) {
|
|
105
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
106
|
+
const argumentsTypes = [null];
|
|
107
|
+
const parameterNames = ["vault"];
|
|
108
|
+
return (tx) => tx.moveCall({
|
|
109
|
+
package: packageAddress,
|
|
110
|
+
module: "plp",
|
|
111
|
+
function: "id",
|
|
112
|
+
arguments: normalizeMoveArguments({
|
|
113
|
+
...options.arguments,
|
|
114
|
+
vault: options.arguments?.vault ?? options.config?.poolVault
|
|
115
|
+
}, argumentsTypes, parameterNames)
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/** Return idle USDC for SDK and devInspect state reads. */
|
|
50
119
|
function idleBalance(options) {
|
|
51
120
|
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
52
121
|
const argumentsTypes = [null];
|
|
@@ -61,6 +130,36 @@ function idleBalance(options) {
|
|
|
61
130
|
}, argumentsTypes, parameterNames)
|
|
62
131
|
});
|
|
63
132
|
}
|
|
133
|
+
/** Return protocol-owned USDC for SDK and devInspect state reads. */
|
|
134
|
+
function protocolReserveBalance(options) {
|
|
135
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
136
|
+
const argumentsTypes = [null];
|
|
137
|
+
const parameterNames = ["vault"];
|
|
138
|
+
return (tx) => tx.moveCall({
|
|
139
|
+
package: packageAddress,
|
|
140
|
+
module: "plp",
|
|
141
|
+
function: "protocol_reserve_balance",
|
|
142
|
+
arguments: normalizeMoveArguments({
|
|
143
|
+
...options.arguments,
|
|
144
|
+
vault: options.arguments?.vault ?? options.config?.poolVault
|
|
145
|
+
}, argumentsTypes, parameterNames)
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/** Return sponsor-funded fee reserves for SDK and devInspect state reads. */
|
|
149
|
+
function feeIncentiveReserve(options) {
|
|
150
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
151
|
+
const argumentsTypes = [null];
|
|
152
|
+
const parameterNames = ["vault"];
|
|
153
|
+
return (tx) => tx.moveCall({
|
|
154
|
+
package: packageAddress,
|
|
155
|
+
module: "plp",
|
|
156
|
+
function: "fee_incentive_reserve",
|
|
157
|
+
arguments: normalizeMoveArguments({
|
|
158
|
+
...options.arguments,
|
|
159
|
+
vault: options.arguments?.vault ?? options.config?.poolVault
|
|
160
|
+
}, argumentsTypes, parameterNames)
|
|
161
|
+
});
|
|
162
|
+
}
|
|
64
163
|
/** Return total PLP supply for SDK and devInspect state reads. */
|
|
65
164
|
function plpTotalSupply(options) {
|
|
66
165
|
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
@@ -121,11 +220,391 @@ function activeExpiryMarkets(options) {
|
|
|
121
220
|
}, argumentsTypes, parameterNames)
|
|
122
221
|
});
|
|
123
222
|
}
|
|
223
|
+
/** Return the pre-expiry active count for SDK and devInspect capacity reads. */
|
|
224
|
+
function activeLiveExpiryCount(options) {
|
|
225
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
226
|
+
const argumentsTypes = [null, "0x2::clock::Clock"];
|
|
227
|
+
const parameterNames = ["vault"];
|
|
228
|
+
return (tx) => tx.moveCall({
|
|
229
|
+
package: packageAddress,
|
|
230
|
+
module: "plp",
|
|
231
|
+
function: "active_live_expiry_count",
|
|
232
|
+
arguments: normalizeMoveArguments({
|
|
233
|
+
...options.arguments,
|
|
234
|
+
vault: options.arguments?.vault ?? options.config?.poolVault
|
|
235
|
+
}, argumentsTypes, parameterNames)
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/** Return the profit-basis debits for external accounting observability. */
|
|
239
|
+
function profitBasisDebits(options) {
|
|
240
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
241
|
+
const argumentsTypes = [null];
|
|
242
|
+
const parameterNames = ["vault"];
|
|
243
|
+
return (tx) => tx.moveCall({
|
|
244
|
+
package: packageAddress,
|
|
245
|
+
module: "plp",
|
|
246
|
+
function: "profit_basis_debits",
|
|
247
|
+
arguments: normalizeMoveArguments({
|
|
248
|
+
...options.arguments,
|
|
249
|
+
vault: options.arguments?.vault ?? options.config?.poolVault
|
|
250
|
+
}, argumentsTypes, parameterNames)
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/** Return the profit-basis credits for external accounting observability. */
|
|
254
|
+
function profitBasisCredits(options) {
|
|
255
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
256
|
+
const argumentsTypes = [null];
|
|
257
|
+
const parameterNames = ["vault"];
|
|
258
|
+
return (tx) => tx.moveCall({
|
|
259
|
+
package: packageAddress,
|
|
260
|
+
module: "plp",
|
|
261
|
+
function: "profit_basis_credits",
|
|
262
|
+
arguments: normalizeMoveArguments({
|
|
263
|
+
...options.arguments,
|
|
264
|
+
vault: options.arguments?.vault ?? options.config?.poolVault
|
|
265
|
+
}, argumentsTypes, parameterNames)
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/** Return deferred protocol profit for external accounting observability. */
|
|
269
|
+
function pendingProtocolProfit(options) {
|
|
270
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
271
|
+
const argumentsTypes = [null];
|
|
272
|
+
const parameterNames = ["vault"];
|
|
273
|
+
return (tx) => tx.moveCall({
|
|
274
|
+
package: packageAddress,
|
|
275
|
+
module: "plp",
|
|
276
|
+
function: "pending_protocol_profit",
|
|
277
|
+
arguments: normalizeMoveArguments({
|
|
278
|
+
...options.arguments,
|
|
279
|
+
vault: options.arguments?.vault ?? options.config?.poolVault
|
|
280
|
+
}, argumentsTypes, parameterNames)
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Begin a full-pool valuation using a registry-issued pool-valuation proof. The
|
|
285
|
+
* proof grants control over when current oracle state is frozen for queued LP
|
|
286
|
+
* fills. Starting engages the cross-transaction valuation flag, snapshots the
|
|
287
|
+
* active expiry set and each LP queue's eligibility cutoff, and opens the atomic
|
|
288
|
+
* snapshot stage: freeze every active market's pricer under the returned
|
|
289
|
+
* `SnapshotStage`, then seal it in the same transaction.
|
|
290
|
+
*/
|
|
291
|
+
function startPoolValuation(options) {
|
|
292
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
293
|
+
const argumentsTypes = [
|
|
294
|
+
null,
|
|
295
|
+
null,
|
|
296
|
+
null,
|
|
297
|
+
"0x1::option::Option<u64>",
|
|
298
|
+
"0x1::option::Option<u64>",
|
|
299
|
+
"0x2::clock::Clock"
|
|
300
|
+
];
|
|
301
|
+
const parameterNames = [
|
|
302
|
+
"config",
|
|
303
|
+
"vault",
|
|
304
|
+
"valuationProof",
|
|
305
|
+
"supplyBudget",
|
|
306
|
+
"withdrawBudget"
|
|
307
|
+
];
|
|
308
|
+
return (tx) => tx.moveCall({
|
|
309
|
+
package: packageAddress,
|
|
310
|
+
module: "plp",
|
|
311
|
+
function: "start_pool_valuation",
|
|
312
|
+
arguments: normalizeMoveArguments({
|
|
313
|
+
...options.arguments,
|
|
314
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
315
|
+
vault: options.arguments?.vault ?? options.config?.poolVault
|
|
316
|
+
}, argumentsTypes, parameterNames)
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Freeze one snapshotted market's oracle state for this flush and stamp the
|
|
321
|
+
* market, capturing its cash rows and activating its payout-tree snapshot at this
|
|
322
|
+
* instant.
|
|
323
|
+
*
|
|
324
|
+
* Holding `SnapshotStage` is what admits this call, and that potato cannot leave
|
|
325
|
+
* the transaction `start_pool_valuation` minted it in — so every `Pricer` here is
|
|
326
|
+
* loaded at one instant, which is what lets the valuation stage span transactions
|
|
327
|
+
* without mixing marks (audit L10). This stage reads oracles only — it never walks
|
|
328
|
+
* a payout tree — so all markets fit one PTB regardless of book size.
|
|
329
|
+
*
|
|
330
|
+
* The oracle feeding this stage must have been written in an EARLIER transaction:
|
|
331
|
+
* `pricing::resolve_live_pricer` refuses a read stamped with the current
|
|
332
|
+
* transaction digest (RP-24), so a keeper cannot refresh and snapshot in one PTB.
|
|
333
|
+
*
|
|
334
|
+
* A market already settled at snapshot time is recorded with no pricer, gets no
|
|
335
|
+
* stamp (settled flows never touch live NAV), and contributes 0. An
|
|
336
|
+
* expired-but-unsettled market aborts: it has no well-defined mark, and because
|
|
337
|
+
* this stage is atomic the abort reverts the whole snapshot transaction, so the
|
|
338
|
+
* flag is never left engaged. Settle it first, then start the flush; settlement is
|
|
339
|
+
* never blocked by a flush, so that ordering is always available.
|
|
340
|
+
*/
|
|
341
|
+
function snapshotExpiryPricer(options) {
|
|
342
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
343
|
+
const argumentsTypes = [
|
|
344
|
+
null,
|
|
345
|
+
null,
|
|
346
|
+
null,
|
|
347
|
+
null,
|
|
348
|
+
null,
|
|
349
|
+
null,
|
|
350
|
+
null,
|
|
351
|
+
null,
|
|
352
|
+
"0x2::clock::Clock"
|
|
353
|
+
];
|
|
354
|
+
const parameterNames = [
|
|
355
|
+
"vault",
|
|
356
|
+
"Stage",
|
|
357
|
+
"market",
|
|
358
|
+
"config",
|
|
359
|
+
"propbookRegistry",
|
|
360
|
+
"pyth",
|
|
361
|
+
"bsValues",
|
|
362
|
+
"bsSvi"
|
|
363
|
+
];
|
|
364
|
+
return (tx) => tx.moveCall({
|
|
365
|
+
package: packageAddress,
|
|
366
|
+
module: "plp",
|
|
367
|
+
function: "snapshot_expiry_pricer",
|
|
368
|
+
arguments: normalizeMoveArguments({
|
|
369
|
+
...options.arguments,
|
|
370
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
371
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
372
|
+
propbookRegistry: options.arguments?.propbookRegistry ?? options.config?.oracleRegistry
|
|
373
|
+
}, argumentsTypes, parameterNames)
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Close the snapshot stage once every expected market has a frozen pricer, and
|
|
378
|
+
* freeze the vault-side figures — idle, the profit basis, the pending protocol cut
|
|
379
|
+
* — completing the snapshot.
|
|
380
|
+
*
|
|
381
|
+
* Consuming `SnapshotStage` is the simultaneity proof: the potato dies here, so no
|
|
382
|
+
* later transaction can add oracle state to this flush, and every market is marked
|
|
383
|
+
* at the instant the snapshot transaction executed. The vault capture is
|
|
384
|
+
* consistent with the per-market stamps because `rebalance_expiry_cash` refuses to
|
|
385
|
+
* run while the stage is open (`ESnapshotStageOpen`), so no idle↔market move can
|
|
386
|
+
* land between a stamp and this capture. Valuation may then resume across as many
|
|
387
|
+
* transactions as it needs.
|
|
388
|
+
*/
|
|
389
|
+
function sealValuationSnapshot(options) {
|
|
390
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
391
|
+
const argumentsTypes = [
|
|
392
|
+
null,
|
|
393
|
+
null,
|
|
394
|
+
null
|
|
395
|
+
];
|
|
396
|
+
const parameterNames = [
|
|
397
|
+
"vault",
|
|
398
|
+
"stage",
|
|
399
|
+
"config"
|
|
400
|
+
];
|
|
401
|
+
return (tx) => tx.moveCall({
|
|
402
|
+
package: packageAddress,
|
|
403
|
+
module: "plp",
|
|
404
|
+
function: "seal_valuation_snapshot",
|
|
405
|
+
arguments: normalizeMoveArguments({
|
|
406
|
+
...options.arguments,
|
|
407
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
408
|
+
config: options.arguments?.config ?? options.config?.protocolConfig
|
|
409
|
+
}, argumentsTypes, parameterNames)
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Fold one snapshotted market's SNAPSHOT-INSTANT NAV into the running total. A
|
|
414
|
+
* market frozen as settled is swept and contributes 0; one frozen with a pricer is
|
|
415
|
+
* valued via `expiry_market::snapshot_nav` over its captured cash and tree
|
|
416
|
+
* shadows, then has its stamp cleared (releasing the tree snapshot), so later
|
|
417
|
+
* trades and the next flush start clean.
|
|
418
|
+
*
|
|
419
|
+
* The resumable stage: any transaction after the seal, one market per transaction
|
|
420
|
+
* (`constants::max_payout_tree_nodes`), reading no oracle and no clock.
|
|
421
|
+
* MEASUREMENT-ONLY for every member — settled members were swept during the
|
|
422
|
+
* snapshot stage and every frozen figure was captured there, so this call moves no
|
|
423
|
+
* cash and `rebalance_expiry_cash` runs at any time. A market that expired
|
|
424
|
+
* mid-window is valued at its frozen pre-expiry mark; its settlement does not wait
|
|
425
|
+
* for this call, because settlement is never blocked by a flush.
|
|
426
|
+
*/
|
|
427
|
+
function valueExpiry(options) {
|
|
428
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
429
|
+
const argumentsTypes = [
|
|
430
|
+
null,
|
|
431
|
+
null,
|
|
432
|
+
null
|
|
433
|
+
];
|
|
434
|
+
const parameterNames = [
|
|
435
|
+
"vault",
|
|
436
|
+
"market",
|
|
437
|
+
"config"
|
|
438
|
+
];
|
|
439
|
+
return (tx) => tx.moveCall({
|
|
440
|
+
package: packageAddress,
|
|
441
|
+
module: "plp",
|
|
442
|
+
function: "value_expiry",
|
|
443
|
+
arguments: normalizeMoveArguments({
|
|
444
|
+
...options.arguments,
|
|
445
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
446
|
+
config: options.arguments?.config ?? options.config?.protocolConfig
|
|
447
|
+
}, argumentsTypes, parameterNames)
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Finish a full-pool valuation and run the LP flush: prove every snapshotted
|
|
452
|
+
* market was valued exactly once, price the pool NAV, then drain the
|
|
453
|
+
* supply/withdraw queues at that frozen mark (mint PLP for supplies, burn PLP and
|
|
454
|
+
* pay USDC for withdrawals), release the valuation flag, retire the in-flight
|
|
455
|
+
* valuation, and return the LP-attributable pool-wide USDC NAV (frozen idle + Σ
|
|
456
|
+
* active NAV, net of the pending-protocol-profit exclusion priced from the frozen
|
|
457
|
+
* profit basis — every term as of the snapshot instant). Each drain fills only
|
|
458
|
+
* requests submitted before the flush's snapshot instant (the recorded queue
|
|
459
|
+
* cutoffs); younger requests wait for the next mark.
|
|
460
|
+
*
|
|
461
|
+
* `supply_budget` and `withdraw_budget` bound how many requests each queue may
|
|
462
|
+
* process this flush (`None` = unbounded). Fills — whole or partial — and
|
|
463
|
+
* protocol-refunded heads — non-executable, or quoting below the request's own
|
|
464
|
+
* minimum output — all count as processed. At `ProtocolConfig`'s shipped attempt
|
|
465
|
+
* count of one, a head that misses its limit is refunded by the flush that reaches
|
|
466
|
+
* it; above one it stays queued and stops that queue for the flush. The budgets
|
|
467
|
+
* are independent, so a supply backlog does not consume withdrawal capacity.
|
|
468
|
+
*
|
|
469
|
+
* Capacity bounds each pass on top of the budgets and refunds nothing: supplies
|
|
470
|
+
* fill only up to `ProtocolConfig`'s LP pool-value cap, withdrawals only up to
|
|
471
|
+
* idle. A head larger than the room left fills to the room, spends flush budget,
|
|
472
|
+
* and keeps its remainder queued at a rescaled limit; a head with no usable room
|
|
473
|
+
* carries untouched and spends none. Either way the pass stops, so an unbounded
|
|
474
|
+
* budget does not mean every queued request is processed (RP-23).
|
|
475
|
+
*
|
|
476
|
+
* Because queueing is permissionless and a refunded request returns its escrow in
|
|
477
|
+
* the same transaction, an operator should bound both budgets in production rather
|
|
478
|
+
* than rely on queue length staying small — see RP-12.
|
|
479
|
+
*/
|
|
480
|
+
function finishFlush(options) {
|
|
481
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
482
|
+
const argumentsTypes = [
|
|
483
|
+
null,
|
|
484
|
+
null,
|
|
485
|
+
"0x2::clock::Clock"
|
|
486
|
+
];
|
|
487
|
+
const parameterNames = ["vault", "config"];
|
|
488
|
+
return (tx) => tx.moveCall({
|
|
489
|
+
package: packageAddress,
|
|
490
|
+
module: "plp",
|
|
491
|
+
function: "finish_flush",
|
|
492
|
+
arguments: normalizeMoveArguments({
|
|
493
|
+
...options.arguments,
|
|
494
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
495
|
+
config: options.arguments?.config ?? options.config?.protocolConfig
|
|
496
|
+
}, argumentsTypes, parameterNames)
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Move cash between pool idle liquidity and one expiry market.
|
|
501
|
+
*
|
|
502
|
+
* Permissionless and standalone: anyone may call it at any cadence. Handles all
|
|
503
|
+
* three per-market cases — initial funding of a freshly registered (unfunded)
|
|
504
|
+
* market, ongoing live rebalance/surplus-sweep toward target, and the
|
|
505
|
+
* settled-market sweep (deactivate, return all free cash, materialize profit).
|
|
506
|
+
* Call `expiry_market::try_settle` first in the same PTB when settlement may be
|
|
507
|
+
* due. An expired unsettled market is a no-op until that transition succeeds. Mint
|
|
508
|
+
* asserts backing but never pulls pool cash, so this is what makes a market
|
|
509
|
+
* mintable. The market must already be registered to this vault
|
|
510
|
+
* (`registry::create_and_share_expiry_market`). Runs at any time, including while
|
|
511
|
+
* a flush is in flight — every figure the mark reads was frozen at the snapshot
|
|
512
|
+
* instant, so no move here can reach it. The one refusal is the still-open
|
|
513
|
+
* snapshot stage (start → seal, a single transaction): a cross-move landing
|
|
514
|
+
* between a market's stamp and the seal's vault capture would skew the frozen
|
|
515
|
+
* figures, so it is structurally rejected rather than corrected for.
|
|
516
|
+
*/
|
|
517
|
+
function rebalanceExpiryCash(options) {
|
|
518
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
519
|
+
const argumentsTypes = [
|
|
520
|
+
null,
|
|
521
|
+
null,
|
|
522
|
+
null,
|
|
523
|
+
"0x2::clock::Clock"
|
|
524
|
+
];
|
|
525
|
+
const parameterNames = [
|
|
526
|
+
"vault",
|
|
527
|
+
"market",
|
|
528
|
+
"config"
|
|
529
|
+
];
|
|
530
|
+
return (tx) => tx.moveCall({
|
|
531
|
+
package: packageAddress,
|
|
532
|
+
module: "plp",
|
|
533
|
+
function: "rebalance_expiry_cash",
|
|
534
|
+
arguments: normalizeMoveArguments({
|
|
535
|
+
...options.arguments,
|
|
536
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
537
|
+
config: options.arguments?.config ?? options.config?.protocolConfig
|
|
538
|
+
}, argumentsTypes, parameterNames)
|
|
539
|
+
});
|
|
540
|
+
}
|
|
124
541
|
/**
|
|
125
|
-
*
|
|
542
|
+
* Sponsor taker fee incentives with USDC. Anyone may contribute; the payment joins
|
|
543
|
+
* a pool-level reserve that is excluded from PLP NAV and later allocated to expiry
|
|
544
|
+
* markets by the normal rebalance flow.
|
|
545
|
+
*/
|
|
546
|
+
function sponsorFeeIncentives(options) {
|
|
547
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
548
|
+
const argumentsTypes = [
|
|
549
|
+
null,
|
|
550
|
+
null,
|
|
551
|
+
null
|
|
552
|
+
];
|
|
553
|
+
const parameterNames = [
|
|
554
|
+
"vault",
|
|
555
|
+
"config",
|
|
556
|
+
"payment"
|
|
557
|
+
];
|
|
558
|
+
return (tx) => tx.moveCall({
|
|
559
|
+
package: packageAddress,
|
|
560
|
+
module: "plp",
|
|
561
|
+
function: "sponsor_fee_incentives",
|
|
562
|
+
arguments: normalizeMoveArguments({
|
|
563
|
+
...options.arguments,
|
|
564
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
565
|
+
config: options.arguments?.config ?? options.config?.protocolConfig
|
|
566
|
+
}, argumentsTypes, parameterNames)
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
/**
|
|
570
|
+
* Bootstrap the pool exactly once: permanently lock `payment` USDC of minimum
|
|
571
|
+
* liquidity. Mints matching PLP (1:1) into the book's locked balance — never
|
|
572
|
+
* withdrawable, so the caller receives no shares — and joins the USDC into idle.
|
|
573
|
+
* This keeps `total_supply > 0` while the vault exists and gives rounding dust a
|
|
574
|
+
* non-withdrawable PLP holder. Requires root authority and zero existing supply.
|
|
575
|
+
* Supply, withdrawal, and flush flows remain disabled until the locked liquidity
|
|
576
|
+
* has been created.
|
|
577
|
+
*/
|
|
578
|
+
function lockCapital(options) {
|
|
579
|
+
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
580
|
+
const argumentsTypes = [
|
|
581
|
+
null,
|
|
582
|
+
null,
|
|
583
|
+
null,
|
|
584
|
+
null
|
|
585
|
+
];
|
|
586
|
+
const parameterNames = [
|
|
587
|
+
"vault",
|
|
588
|
+
"config",
|
|
589
|
+
"AdminCap",
|
|
590
|
+
"payment"
|
|
591
|
+
];
|
|
592
|
+
return (tx) => tx.moveCall({
|
|
593
|
+
package: packageAddress,
|
|
594
|
+
module: "plp",
|
|
595
|
+
function: "lock_capital",
|
|
596
|
+
arguments: normalizeMoveArguments({
|
|
597
|
+
...options.arguments,
|
|
598
|
+
vault: options.arguments?.vault ?? options.config?.poolVault,
|
|
599
|
+
config: options.arguments?.config ?? options.config?.protocolConfig
|
|
600
|
+
}, argumentsTypes, parameterNames)
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Queue a supply request: pull `amount` USDC from account custody into queue
|
|
126
605
|
* escrow, recording the account's receive address as the fill recipient. The pull
|
|
127
|
-
* auto-settles any flush-delivered
|
|
128
|
-
* supply fee — zero by default — on the
|
|
606
|
+
* auto-settles any flush-delivered USDC first. The flush charges the protocol's
|
|
607
|
+
* supply fee — zero by default — on the USDC it takes in and prices shares on the
|
|
129
608
|
* remainder, so `min_plp_out` is measured after that fee. The account receives
|
|
130
609
|
* minted PLP only at a mark that mints at least `min_plp_out` for the whole
|
|
131
610
|
* `amount` — a **price floor**, not a promise of that many shares: if the pool cap
|
|
@@ -171,15 +650,15 @@ function requestSupply(options) {
|
|
|
171
650
|
* Queue a withdraw request: pull `amount` PLP shares from account custody into
|
|
172
651
|
* queue escrow, recording the account's receive address as the fill recipient. The
|
|
173
652
|
* pull auto-settles any flush-delivered PLP first. The flush withholds the
|
|
174
|
-
* protocol's withdraw fee from the marked payout, so `
|
|
653
|
+
* protocol's withdraw fee from the marked payout, so `min_usdc_out` is measured
|
|
175
654
|
* after the fee. The account is paid only at a mark that quotes at least
|
|
176
|
-
* `
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
655
|
+
* `min_usdc_out` for the whole `amount` — a **price floor**, not a promise of that
|
|
656
|
+
* much USDC: if idle liquidity covers only part of the payout, only the shares
|
|
657
|
+
* idle affords are burned, the fill is proportionally smaller at the same price,
|
|
658
|
+
* and the remainder stays queued with its limit rescaled. At the shipped attempt
|
|
659
|
+
* count of one, a flush whose mark quotes less cancels and refunds the request
|
|
660
|
+
* there and then; a higher configured count lets it rest and retry that many
|
|
661
|
+
* flushes first. Returns the queue index used to cancel before the flush.
|
|
183
662
|
*/
|
|
184
663
|
function requestWithdraw(options) {
|
|
185
664
|
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
@@ -199,7 +678,7 @@ function requestWithdraw(options) {
|
|
|
199
678
|
"auth",
|
|
200
679
|
"config",
|
|
201
680
|
"amount",
|
|
202
|
-
"
|
|
681
|
+
"minUsdcOut"
|
|
203
682
|
];
|
|
204
683
|
return (tx) => tx.moveCall({
|
|
205
684
|
package: packageAddress,
|
|
@@ -213,8 +692,8 @@ function requestWithdraw(options) {
|
|
|
213
692
|
});
|
|
214
693
|
}
|
|
215
694
|
/**
|
|
216
|
-
* Cancel a still-pending supply request, refunding its escrowed
|
|
217
|
-
*
|
|
695
|
+
* Cancel a still-pending supply request, refunding its escrowed USDC straight into
|
|
696
|
+
* the requesting account. `account` must be the request's recorded recipient.
|
|
218
697
|
*/
|
|
219
698
|
function cancelSupplyRequest(options) {
|
|
220
699
|
const packageAddress = options.package ?? options.config?.predictPackageId ?? "@local-pkg/deepbook_predict";
|
|
@@ -280,5 +759,5 @@ function cancelWithdrawRequest(options) {
|
|
|
280
759
|
}
|
|
281
760
|
|
|
282
761
|
//#endregion
|
|
283
|
-
export { activeExpiryMarkets, cancelSupplyRequest, cancelWithdrawRequest, idleBalance, plpTotalSupply, requestSupply, requestWithdraw, supplyRequestsPending, withdrawRequestsPending };
|
|
762
|
+
export { activeExpiryMarkets, cancelSupplyRequest, cancelWithdrawRequest, idleBalance, plpTotalSupply, plp_exports, requestSupply, requestWithdraw, supplyRequestsPending, withdrawRequestsPending };
|
|
284
763
|
//# sourceMappingURL=plp.mjs.map
|