@mysten/deepbook-v3 2.6.4 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +153 -0
- package/PREDICT.md +389 -61
- package/dist/contracts/account/account.d.mts +23 -23
- package/dist/contracts/account/account.d.mts.map +1 -1
- package/dist/contracts/account/account_registry.d.mts +13 -13
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook_predict/admin.d.mts +4 -4
- package/dist/contracts/deepbook_predict/builder_code.d.mts +11 -11
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts +10 -10
- package/dist/contracts/deepbook_predict/config_events.d.mts +93 -68
- package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/config_events.mjs +45 -1
- package/dist/contracts/deepbook_predict/config_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/deps/std/type_name.mjs +17 -0
- package/dist/contracts/deepbook_predict/deps/std/type_name.mjs.map +1 -0
- package/dist/contracts/deepbook_predict/expiry_market.d.mts +652 -235
- package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.mjs +652 -186
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/lp_book.mjs +1 -1
- package/dist/contracts/deepbook_predict/market_lifecycle_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/market_manager.d.mts +27 -27
- package/dist/contracts/deepbook_predict/order_events.d.mts +50 -50
- package/dist/contracts/deepbook_predict/order_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.mjs +3 -1
- package/dist/contracts/deepbook_predict/order_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pause_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/plp.d.mts +184 -82
- package/dist/contracts/deepbook_predict/plp.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/plp.mjs +126 -7
- package/dist/contracts/deepbook_predict/plp.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pool_accounting.mjs +1 -1
- package/dist/contracts/deepbook_predict/pool_valuation_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/predict_account.d.mts +14 -14
- package/dist/contracts/deepbook_predict/pricing.d.mts +91 -58
- package/dist/contracts/deepbook_predict/pricing.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/pricing.mjs +30 -3
- package/dist/contracts/deepbook_predict/pricing.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/pricing_config.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/protocol_config.d.mts +400 -92
- package/dist/contracts/deepbook_predict/protocol_config.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/protocol_config.mjs +451 -61
- package/dist/contracts/deepbook_predict/protocol_config.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/range_codec.d.mts +2 -2
- package/dist/contracts/deepbook_predict/registry.d.mts +28 -28
- package/dist/contracts/deepbook_predict/strike_exposure.mjs +1 -1
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs +17 -12
- package/dist/contracts/deepbook_predict/strike_payout_tree.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.d.mts +154 -106
- package/dist/contracts/deepbook_predict/vault_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs +57 -1
- package/dist/contracts/deepbook_predict/vault_events.mjs.map +1 -1
- package/dist/contracts/deepbook_predict_math/config-arguments.d.mts +10 -0
- package/dist/contracts/deepbook_predict_math/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.d.mts +106 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.mjs +125 -0
- package/dist/contracts/deepbook_predict_math/lazer_price.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_math/math.d.mts +284 -0
- package/dist/contracts/deepbook_predict_math/math.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_math/math.mjs +364 -0
- package/dist/contracts/deepbook_predict_math/math.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts +13 -0
- package/dist/contracts/deepbook_predict_orders/config-arguments.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts +215 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs +215 -0
- package/dist/contracts/deepbook_predict_orders/delayed_execution_config.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs +87 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs +52 -0
- package/dist/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs +25 -0
- package/dist/contracts/deepbook_predict_orders/deps/fixed_math/i64.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs +21 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/balance.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs +39 -0
- package/dist/contracts/deepbook_predict_orders/deps/sui/table.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/desk.d.mts +187 -0
- package/dist/contracts/deepbook_predict_orders/desk.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/desk.mjs +261 -0
- package/dist/contracts/deepbook_predict_orders/desk.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.d.mts +1042 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.mjs +849 -0
- package/dist/contracts/deepbook_predict_orders/order_queue.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue.d.mts +683 -0
- package/dist/contracts/deepbook_predict_orders/queue.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue.mjs +912 -0
- package/dist/contracts/deepbook_predict_orders/queue.mjs.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.d.mts +195 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.d.mts.map +1 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.mjs +187 -0
- package/dist/contracts/deepbook_predict_orders/queue_events.mjs.map +1 -0
- package/dist/contracts/deepbook_sessions/session_config.d.mts +8 -8
- package/dist/contracts/deepbook_sessions/sessions.d.mts +163 -28
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/contracts/deepbook_sessions/sessions.mjs +234 -5
- package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -1
- package/dist/deployments/mainnet.mjs +7 -4
- package/dist/deployments/mainnet.mjs.map +1 -1
- package/dist/deployments/testnet.mjs +7 -4
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/predict/bindings/expiry-market.d.mts +77 -0
- package/dist/predict/bindings/expiry-market.d.mts.map +1 -0
- package/dist/predict/bindings/expiry-market.mjs +139 -0
- package/dist/predict/bindings/expiry-market.mjs.map +1 -0
- package/dist/predict/bindings/protocol-config.d.mts +39 -0
- package/dist/predict/bindings/protocol-config.d.mts.map +1 -0
- package/dist/predict/bindings/protocol-config.mjs +90 -0
- package/dist/predict/bindings/protocol-config.mjs.map +1 -0
- package/dist/predict/bindings/rename.mjs +9 -0
- package/dist/predict/bindings/rename.mjs.map +1 -0
- package/dist/predict/client.d.mts +595 -16
- package/dist/predict/client.d.mts.map +1 -1
- package/dist/predict/client.mjs +986 -10
- package/dist/predict/client.mjs.map +1 -1
- package/dist/predict/config/generated.d.mts +22 -1
- package/dist/predict/config/generated.d.mts.map +1 -1
- package/dist/predict/config/generated.mjs +30 -1
- package/dist/predict/config/generated.mjs.map +1 -1
- package/dist/predict/config/mainnet.mjs +11 -3
- package/dist/predict/config/mainnet.mjs.map +1 -1
- package/dist/predict/config/testnet.mjs +11 -3
- package/dist/predict/config/testnet.mjs.map +1 -1
- package/dist/predict/config/types.d.mts +50 -1
- package/dist/predict/config/types.d.mts.map +1 -1
- package/dist/predict/cost.d.mts +38 -11
- package/dist/predict/cost.d.mts.map +1 -1
- package/dist/predict/cost.mjs +37 -11
- package/dist/predict/cost.mjs.map +1 -1
- package/dist/predict/decode.d.mts +251 -1
- package/dist/predict/decode.d.mts.map +1 -1
- package/dist/predict/decode.mjs +342 -4
- package/dist/predict/decode.mjs.map +1 -1
- package/dist/predict/errors.d.mts +69 -6
- package/dist/predict/errors.d.mts.map +1 -1
- package/dist/predict/errors.mjs +277 -4
- package/dist/predict/errors.mjs.map +1 -1
- package/dist/predict/index.d.mts +21 -10
- package/dist/predict/index.mjs +24 -12
- package/dist/predict/queue-id.d.mts +13 -0
- package/dist/predict/queue-id.d.mts.map +1 -0
- package/dist/predict/queue-id.mjs +19 -0
- package/dist/predict/queue-id.mjs.map +1 -0
- package/dist/predict/queue.d.mts +505 -0
- package/dist/predict/queue.d.mts.map +1 -0
- package/dist/predict/queue.mjs +774 -0
- package/dist/predict/queue.mjs.map +1 -0
- package/dist/predict/reads/balances.mjs +1 -1
- package/dist/predict/reads/markets.mjs +46 -5
- package/dist/predict/reads/markets.mjs.map +1 -1
- package/dist/predict/reads/pool.mjs +1 -1
- package/dist/predict/reads/pricing.d.mts +1 -1
- package/dist/predict/reads/queue.d.mts +105 -0
- package/dist/predict/reads/queue.d.mts.map +1 -0
- package/dist/predict/reads/queue.mjs +445 -0
- package/dist/predict/reads/queue.mjs.map +1 -0
- package/dist/predict/ticks.d.mts +9 -1
- package/dist/predict/ticks.d.mts.map +1 -1
- package/dist/predict/ticks.mjs +18 -1
- package/dist/predict/ticks.mjs.map +1 -1
- package/dist/predict/tx/authed.mjs +1 -1
- package/dist/predict/tx/common.d.mts.map +1 -1
- package/dist/predict/tx/common.mjs +12 -1
- package/dist/predict/tx/common.mjs.map +1 -1
- package/dist/predict/tx/queue.d.mts +220 -0
- package/dist/predict/tx/queue.d.mts.map +1 -0
- package/dist/predict/tx/queue.mjs +399 -0
- package/dist/predict/tx/queue.mjs.map +1 -0
- package/dist/predict/tx/trade.d.mts.map +1 -1
- package/dist/predict/tx/trade.mjs +61 -43
- package/dist/predict/tx/trade.mjs.map +1 -1
- package/dist/sessions.d.mts +90 -2
- package/dist/sessions.d.mts.map +1 -1
- package/dist/sessions.mjs +107 -2
- package/dist/sessions.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/package.json +4 -4
- package/src/contracts/deepbook_predict/config_events.ts +39 -0
- package/src/contracts/deepbook_predict/deps/std/type_name.ts +24 -0
- package/src/contracts/deepbook_predict/expiry_market.ts +960 -169
- package/src/contracts/deepbook_predict/order_events.ts +3 -1
- package/src/contracts/deepbook_predict/plp.ts +150 -9
- package/src/contracts/deepbook_predict/pricing.ts +46 -7
- package/src/contracts/deepbook_predict/pricing_config.ts +3 -1
- package/src/contracts/deepbook_predict/protocol_config.ts +648 -33
- package/src/contracts/deepbook_predict/strike_payout_tree.ts +25 -21
- package/src/contracts/deepbook_predict/vault_events.ts +65 -0
- package/src/contracts/deepbook_predict_math/config-arguments.ts +6 -0
- package/src/contracts/deepbook_predict_math/lazer_price.ts +196 -0
- package/src/contracts/deepbook_predict_math/math.ts +553 -0
- package/src/contracts/deepbook_predict_orders/config-arguments.ts +11 -0
- package/src/contracts/deepbook_predict_orders/delayed_execution_config.ts +430 -0
- package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/expiry_market.ts +108 -0
- package/src/contracts/deepbook_predict_orders/deps/deepbook_predict/pricing.ts +58 -0
- package/src/contracts/deepbook_predict_orders/deps/fixed_math/i64.ts +21 -0
- package/src/contracts/deepbook_predict_orders/deps/sui/balance.ts +19 -0
- package/src/contracts/deepbook_predict_orders/deps/sui/table.ts +37 -0
- package/src/contracts/deepbook_predict_orders/desk.ts +419 -0
- package/src/contracts/deepbook_predict_orders/order_flow.ts +19 -0
- package/src/contracts/deepbook_predict_orders/order_queue.ts +1670 -0
- package/src/contracts/deepbook_predict_orders/queue.ts +1394 -0
- package/src/contracts/deepbook_predict_orders/queue_events.ts +189 -0
- package/src/contracts/deepbook_sessions/sessions.ts +355 -4
- package/src/deployments/mainnet.ts +7 -2
- package/src/deployments/testnet.ts +7 -2
- package/src/deployments/types.ts +14 -1
- package/src/predict/bindings/expiry-market.ts +127 -0
- package/src/predict/bindings/protocol-config.ts +59 -0
- package/src/predict/bindings/rename.ts +14 -0
- package/src/predict/client.ts +2076 -13
- package/src/predict/config/generated.ts +50 -0
- package/src/predict/config/mainnet.ts +16 -2
- package/src/predict/config/testnet.ts +16 -2
- package/src/predict/config/types.ts +51 -1
- package/src/predict/cost.ts +62 -14
- package/src/predict/decode.ts +691 -2
- package/src/predict/errors.ts +391 -14
- package/src/predict/index.ts +87 -6
- package/src/predict/queue-id.ts +22 -0
- package/src/predict/queue.ts +1231 -0
- package/src/predict/reads/markets.ts +30 -0
- package/src/predict/reads/queue.ts +606 -0
- package/src/predict/ticks.ts +35 -0
- package/src/predict/tx/common.ts +25 -1
- package/src/predict/tx/queue.ts +525 -0
- package/src/predict/tx/trade.ts +80 -49
- package/src/sessions.ts +206 -1
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { PredictConfig } from "./config/types.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { MaxMintNow, OrderKindName, OrderView, QueuedOrder, TimingPreview, slippageBand } from "./queue.mjs";
|
|
3
|
+
import { BalanceChangeReceipt, BuilderCodeReceipt, ClaimReceipt, CohortCommitReceipt, CreateManagerReceipt, DecodableTransactionResult, EnqueueReceipt, ExpiryPnlRealizedReceipt, MarketPayoutsCompletedReceipt, MintReceipt, OpenRecordPayoutReceipt, PlpCancelReceipt, PlpRequestReceipt, PolicyUpdateReceipt, QueueEvent, QueueOpsReceipt, QueuedFillReceipt, QueuedRefundReceipt, RecordFundsReceipt, RedeemReceipt } from "./decode.mjs";
|
|
4
4
|
import { BoardPricer } from "./pricing.mjs";
|
|
5
|
-
import { PricerSnapshot } from "./reads/pricing.mjs";
|
|
6
5
|
import { Side } from "./ticks.mjs";
|
|
6
|
+
import { FeePolicy } from "./cost.mjs";
|
|
7
|
+
import { PredictPreflightCode } from "./errors.mjs";
|
|
8
|
+
import { LazerPackages } from "./tx/queue.mjs";
|
|
9
|
+
import { ExecutionMode, MarketQueueState } from "./reads/queue.mjs";
|
|
10
|
+
import { OpenPosition } from "./reads/positions.mjs";
|
|
11
|
+
import { PricerSnapshot } from "./reads/pricing.mjs";
|
|
7
12
|
import { Transaction } from "@mysten/sui/transactions";
|
|
8
13
|
import { ClientWithCoreApi, SuiClientRegistration } from "@mysten/sui/client";
|
|
9
14
|
|
|
@@ -53,7 +58,7 @@ interface MintAmountOptions {
|
|
|
53
58
|
/** All-in cost ceiling in quote units (premium + fees). Omitted → uncapped. */
|
|
54
59
|
maxCost?: number;
|
|
55
60
|
}
|
|
56
|
-
/** Options for `mintCost`: all-in budget. Requires Predict v2
|
|
61
|
+
/** Options for `mintCost`: all-in budget. Requires Predict v2 or later. */
|
|
57
62
|
interface MintCostOptions {
|
|
58
63
|
/** All-in USDC budget; the chain also caps it at the account balance. */
|
|
59
64
|
spend: number;
|
|
@@ -119,6 +124,22 @@ interface MarketSummary {
|
|
|
119
124
|
/** The window's anchor strike in USD, or null until the keeper seeds it. */
|
|
120
125
|
referencePrice: number | null;
|
|
121
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* A market's settlement, from `read.settlement`. Pass `settlementPriceRaw` and `tickSizeRaw` to
|
|
129
|
+
* `cost.settledPayout` to show what a position paid.
|
|
130
|
+
*/
|
|
131
|
+
interface MarketSettlement {
|
|
132
|
+
marketId: string;
|
|
133
|
+
expiryMs: bigint;
|
|
134
|
+
/** Whether Predict has recorded the settlement price. */
|
|
135
|
+
settled: boolean;
|
|
136
|
+
/** The settlement price in USD, or null until the market settles. */
|
|
137
|
+
settlementPrice: number | null;
|
|
138
|
+
/** The settlement price at the 1e9 price scale, or null until the market settles. */
|
|
139
|
+
settlementPriceRaw: bigint | null;
|
|
140
|
+
/** The market's raw tick size, which `cost.settledPayout` rounds the price against. */
|
|
141
|
+
tickSizeRaw: bigint;
|
|
142
|
+
}
|
|
122
143
|
/** Aggregate pool figures. Balances in human units (shares raw); the pending fields
|
|
123
144
|
* are request COUNTS, not amounts — the on-chain getters expose queue lengths, and
|
|
124
145
|
* the escrowed USDC/PLP behind them is tracked separately. */
|
|
@@ -165,6 +186,17 @@ interface MintQuote {
|
|
|
165
186
|
};
|
|
166
187
|
/** True: computed by the real mint code path against real account state. */
|
|
167
188
|
feesExact: true;
|
|
189
|
+
/**
|
|
190
|
+
* True when this previews a queued (delayed-execution) fill: read from the chain's
|
|
191
|
+
* `quote_*` functions with the congestion penalty removed, since a queued fill pays none.
|
|
192
|
+
* Set when the network's config records delayed execution.
|
|
193
|
+
*/
|
|
194
|
+
queued?: boolean;
|
|
195
|
+
/**
|
|
196
|
+
* Queued previews only: the flat order fee, charged once at enqueue on top of `cost`. Show
|
|
197
|
+
* it once per order, not per contract.
|
|
198
|
+
*/
|
|
199
|
+
orderFee?: number;
|
|
168
200
|
}
|
|
169
201
|
/** Exact pre-close quote: the dry-run receipt of the redeem you are about to send. */
|
|
170
202
|
interface RedeemQuote {
|
|
@@ -189,6 +221,331 @@ interface RedeemQuote {
|
|
|
189
221
|
};
|
|
190
222
|
feesExact: true;
|
|
191
223
|
}
|
|
224
|
+
/** A market by its underlying and expiry, optionally pinned to an exact object. */
|
|
225
|
+
type MarketCoordinates = Pick<MarketDescriptor, 'underlying' | 'expiryMs' | 'marketId'>;
|
|
226
|
+
/** Options for `enqueueMint`: a queued mint of an exact payout quantity. */
|
|
227
|
+
interface EnqueueMintOptions {
|
|
228
|
+
quantity: number;
|
|
229
|
+
/** All-in USDC cap (premium + fees). Required: a queued mint has no "unlimited" cap. */
|
|
230
|
+
maxCost: number;
|
|
231
|
+
/** Entry-probability cap at τ, in (0, 1]. Required. See `queue.slippageBand`. */
|
|
232
|
+
maxProbability: number;
|
|
233
|
+
}
|
|
234
|
+
/** Options for `enqueueMintAmount`: a queued premium-budget mint. */
|
|
235
|
+
interface EnqueueMintAmountOptions {
|
|
236
|
+
/** Premium budget in USDC. */
|
|
237
|
+
spend: number;
|
|
238
|
+
/** Floor on the payout received. */
|
|
239
|
+
minQuantity: number;
|
|
240
|
+
/** All-in USDC cap (premium + fees). Required. */
|
|
241
|
+
maxCost: number;
|
|
242
|
+
}
|
|
243
|
+
/** Options for `enqueueMintCost`: a queued all-in-budget mint. */
|
|
244
|
+
interface EnqueueMintCostOptions {
|
|
245
|
+
/** All-in USDC budget, fees included. Escrowed at enqueue, less what the fill doesn't use. */
|
|
246
|
+
spend: number;
|
|
247
|
+
/** Floor on the payout received. Zero disables this slippage floor. */
|
|
248
|
+
minQuantity: number;
|
|
249
|
+
}
|
|
250
|
+
/** Options for `enqueueSell`: a queued early sell of an Open record. */
|
|
251
|
+
interface EnqueueSellOptions {
|
|
252
|
+
/** The Open record to sell from: its queue record ID, not the position's order ID. */
|
|
253
|
+
recordId: bigint;
|
|
254
|
+
/** Payout quantity to close. A partial sell must leave at least the policy minimum. */
|
|
255
|
+
quantity: number;
|
|
256
|
+
/** Close-side probability floor at τ, in [0, 1]. Pass 0 on purpose to disable it. */
|
|
257
|
+
minProbability: number;
|
|
258
|
+
/** Floor on the proceeds before the order fee, in USDC. Pass 0 on purpose to disable it. */
|
|
259
|
+
minProceeds: number;
|
|
260
|
+
/**
|
|
261
|
+
* Add `rebalance_expiry_cash` after the enqueue so the market is funded for this sell at once.
|
|
262
|
+
* `'auto'` (default) adds it only when the sell's cash need is above spare cash, `'always'`
|
|
263
|
+
* always, `'never'` never. It takes the hot `PoolVault`, so keep it conditional.
|
|
264
|
+
*/
|
|
265
|
+
fundMarket?: 'auto' | 'always' | 'never';
|
|
266
|
+
}
|
|
267
|
+
/** What a queued order builder previews alongside the transaction. Display only. */
|
|
268
|
+
interface QueuedOrderPreview {
|
|
269
|
+
marketId: string;
|
|
270
|
+
kind: number;
|
|
271
|
+
kindName: OrderKindName;
|
|
272
|
+
/** τ, deadline and cutoff for an order placed now, from the local clock. */
|
|
273
|
+
timing: TimingPreview;
|
|
274
|
+
/** The flat order fee, charged once at enqueue. */
|
|
275
|
+
orderFee: number;
|
|
276
|
+
/** USDC escrowed for the premium and fees; 0 for a sell. Unused budget returns at the fill. */
|
|
277
|
+
budget: number;
|
|
278
|
+
/** What enqueue debits: budget + order fee. */
|
|
279
|
+
totalDebit: number;
|
|
280
|
+
/** The order's worst-case cash need against the market's spare cash. */
|
|
281
|
+
cashNeedRaw: bigint;
|
|
282
|
+
spareCashRaw: bigint;
|
|
283
|
+
/**
|
|
284
|
+
* Sells only: the cash need is above spare cash, so the sell may be refunded in full
|
|
285
|
+
* (reason 8) unless the market is funded before the fill.
|
|
286
|
+
*/
|
|
287
|
+
needsFunding: boolean;
|
|
288
|
+
/** Whether the builder added `rebalance_expiry_cash` after the enqueue. */
|
|
289
|
+
fundedInTransaction: boolean;
|
|
290
|
+
raw: {
|
|
291
|
+
orderFee: bigint;
|
|
292
|
+
budget: bigint;
|
|
293
|
+
totalDebit: bigint;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/** A queued order's transaction and its preview. */
|
|
297
|
+
interface QueuedOrderPlan {
|
|
298
|
+
transaction: Transaction;
|
|
299
|
+
preview: QueuedOrderPreview;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* How much the price may move against a queued order between its quote and its fill, in cents per
|
|
303
|
+
* contract. A contract pays $1, so its price in cents is its probability: 10¢ of slippage lets
|
|
304
|
+
* a 42¢ contract fill at up to 52¢, fees included. It is never a percentage.
|
|
305
|
+
*/
|
|
306
|
+
interface SlippageOptions {
|
|
307
|
+
/**
|
|
308
|
+
* Cents per contract: `10` is 10¢. `'auto'` (the default) sizes it with `queue.slippageBand`
|
|
309
|
+
* from the time to expiry and the policy's delay.
|
|
310
|
+
*/
|
|
311
|
+
slippageCents?: number | 'auto';
|
|
312
|
+
/** Standard deviations of movement for `'auto'`. Default 2. */
|
|
313
|
+
k?: number;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Options for `read.planMint`. `amount` plans a purchase form's spend (an all-in budget mint),
|
|
317
|
+
* and `quantity` plans an exact payout.
|
|
318
|
+
*/
|
|
319
|
+
type PlanMintOptions = SlippageOptions & ({
|
|
320
|
+
/** The purchase amount in USDC. */amount: number;
|
|
321
|
+
/**
|
|
322
|
+
* Whether `amount` is the whole debit, order fee included (`'inclusive'`, the default),
|
|
323
|
+
* or the order fee is charged on top (`'exclusive'`).
|
|
324
|
+
*/
|
|
325
|
+
orderFee?: 'inclusive' | 'exclusive';
|
|
326
|
+
} | {
|
|
327
|
+
quantity: number;
|
|
328
|
+
});
|
|
329
|
+
/** The slippage a plan applied. */
|
|
330
|
+
interface AppliedSlippage {
|
|
331
|
+
/** Cents per contract. */
|
|
332
|
+
cents: number;
|
|
333
|
+
source: 'input' | 'auto';
|
|
334
|
+
/** The model band when `source` is `'auto'`. */
|
|
335
|
+
band: ReturnType<typeof slippageBand> | null;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* `read.planMint`: everything a purchase form shows, and the enqueue options that carry its
|
|
339
|
+
* slippage. Display only: the fill prices at τ, within the limits in `order`.
|
|
340
|
+
*/
|
|
341
|
+
interface MintPlan {
|
|
342
|
+
shape: 'budget' | 'exact-quantity';
|
|
343
|
+
/** The owner, market and strike range the plan was quoted for. */
|
|
344
|
+
target: PlanTarget;
|
|
345
|
+
/** The quote at the current price. */
|
|
346
|
+
quote: MintQuote;
|
|
347
|
+
/**
|
|
348
|
+
* Whether the quote is the account's own (`quote_mint_*_for_account`, with its builder fee). A
|
|
349
|
+
* visitor without an account, or a balance below the order, gets `quote_mint`'s quote instead,
|
|
350
|
+
* with a budget's quantity found by a short search.
|
|
351
|
+
*/
|
|
352
|
+
quoteForAccount: boolean;
|
|
353
|
+
slippage: AppliedSlippage;
|
|
354
|
+
/** The payout if it wins, at the current price ("Potential payout"). */
|
|
355
|
+
potentialPayout: number;
|
|
356
|
+
/** The smallest payout the order accepts, at the worst price. A smaller fill is refunded. */
|
|
357
|
+
minPayout: number;
|
|
358
|
+
/** `potentialPayout / expectedDebit` ("Payout multiple"), order fee included. */
|
|
359
|
+
payoutMultiple: number;
|
|
360
|
+
/** `minPayout / totalDebit`: the multiple at the worst price. */
|
|
361
|
+
minPayoutMultiple: number;
|
|
362
|
+
/** All-in price per contract now in USDC (0.42 is 42¢), after the fee subsidy, order fee excluded. */
|
|
363
|
+
pricePerContract: number;
|
|
364
|
+
/**
|
|
365
|
+
* The worst price the limits admit: the price per contract without the fee subsidy, plus the
|
|
366
|
+
* slippage. Enqueue admission checks the order without the subsidy, and the subsidy can run out
|
|
367
|
+
* before the fill, so the limits never count on it.
|
|
368
|
+
*/
|
|
369
|
+
worstPricePerContract: number;
|
|
370
|
+
/** The flat order fee, read from the order desk, charged once per order. */
|
|
371
|
+
orderFee: number;
|
|
372
|
+
/** USDC escrowed for the premium and fees. Unused budget comes back at the fill. */
|
|
373
|
+
budget: number;
|
|
374
|
+
/** `budget + orderFee`: what enqueue debits. */
|
|
375
|
+
totalDebit: number;
|
|
376
|
+
/** `quote.cost + orderFee`: what the order costs if it fills at the current price. */
|
|
377
|
+
expectedDebit: number;
|
|
378
|
+
balance: {
|
|
379
|
+
/** Whether the owner has a Predict account yet. */hasAccount: boolean; /** The account's USDC, or null without an account. */
|
|
380
|
+
available: number | null; /** Whether the balance covers `totalDebit`, or null without an account. */
|
|
381
|
+
covers: boolean | null;
|
|
382
|
+
};
|
|
383
|
+
/**
|
|
384
|
+
* The largest `amount` (budget plans) or `quantity` (exact plans) the market's spare cash and,
|
|
385
|
+
* with an account, the balance allow now. An exact plan's balance bound prices each contract
|
|
386
|
+
* at the plan's `worstPricePerContract`. Null when neither binds.
|
|
387
|
+
*/
|
|
388
|
+
maxNow: number | null;
|
|
389
|
+
/** τ, deadline and cutoff for an order placed now, from the local clock. */
|
|
390
|
+
timing: TimingPreview;
|
|
391
|
+
/**
|
|
392
|
+
* Whether `tx.enqueuePlan` would build the order now and admission would take it at the current
|
|
393
|
+
* price: the builder's preflight (the queue gates, the order fee, the minimum premium and the
|
|
394
|
+
* market's cash), the balance against `totalDebit`, the payout bound and, for a budget, the
|
|
395
|
+
* floor admission buys without the fee subsidy. Two admission conditions are checked only on
|
|
396
|
+
* chain, at placement: the market's SVI age under the order desk's `svi_max_age_ms`, and room in
|
|
397
|
+
* the payout tree for a new strike's boundary nodes.
|
|
398
|
+
*/
|
|
399
|
+
accepting: boolean;
|
|
400
|
+
/**
|
|
401
|
+
* The `PredictPreflightError` code the order would get now, or null. `'fee'` also covers a
|
|
402
|
+
* missing account or a balance below `totalDebit`.
|
|
403
|
+
*/
|
|
404
|
+
refusal: PredictPreflightCode | null;
|
|
405
|
+
/** Pass `order.options` to `tx[order.builder]`. */
|
|
406
|
+
order: {
|
|
407
|
+
builder: 'enqueueMintCost';
|
|
408
|
+
options: EnqueueMintCostOptions;
|
|
409
|
+
} | {
|
|
410
|
+
builder: 'enqueueMint';
|
|
411
|
+
options: EnqueueMintOptions;
|
|
412
|
+
};
|
|
413
|
+
raw: {
|
|
414
|
+
budget: bigint;
|
|
415
|
+
orderFee: bigint;
|
|
416
|
+
totalDebit: bigint;
|
|
417
|
+
slippage: bigint;
|
|
418
|
+
minQuantity: bigint;
|
|
419
|
+
maxCost: bigint | null;
|
|
420
|
+
maxProbability: bigint | null;
|
|
421
|
+
pricePerContract: bigint;
|
|
422
|
+
worstPricePerContract: bigint;
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* What a plan was quoted for. Its limits are sized for that one order, so `tx.enqueuePlan` refuses
|
|
427
|
+
* the plan for any other owner, market, strike or record.
|
|
428
|
+
*/
|
|
429
|
+
interface PlanTarget {
|
|
430
|
+
owner: string;
|
|
431
|
+
expiryMarketId: string;
|
|
432
|
+
/** A mint's strike range, as the market's admission ticks. */
|
|
433
|
+
lowerTick?: bigint;
|
|
434
|
+
higherTick?: bigint;
|
|
435
|
+
/** A sell's Open record. Record IDs restart in every market. */
|
|
436
|
+
recordId?: bigint;
|
|
437
|
+
}
|
|
438
|
+
/** Options for `read.planSell`. */
|
|
439
|
+
type PlanSellOptions = SlippageOptions & {
|
|
440
|
+
/** The Open record to sell from. */recordId: bigint; /** Payout quantity to close. */
|
|
441
|
+
quantity: number;
|
|
442
|
+
};
|
|
443
|
+
/** `read.planSell`: what an early sell shows, and the enqueue options that carry its slippage. */
|
|
444
|
+
interface SellPlan {
|
|
445
|
+
/** The owner, market and record the plan was quoted for. */
|
|
446
|
+
target: PlanTarget;
|
|
447
|
+
/** The quote at the current price. */
|
|
448
|
+
quote: SellQuote;
|
|
449
|
+
slippage: AppliedSlippage;
|
|
450
|
+
/** Proceeds at the current price, before the order fee. */
|
|
451
|
+
proceeds: number;
|
|
452
|
+
/** `proceeds − orderFee`. */
|
|
453
|
+
net: number;
|
|
454
|
+
/** The proceeds floor the order carries, before the order fee. A smaller fill is refunded. */
|
|
455
|
+
minProceeds: number;
|
|
456
|
+
/**
|
|
457
|
+
* `minProceeds − orderFee`: the worst the sell nets if it fills. Negative when the order fee is
|
|
458
|
+
* above the proceeds floor.
|
|
459
|
+
*/
|
|
460
|
+
minNet: number;
|
|
461
|
+
orderFee: number;
|
|
462
|
+
timing: TimingPreview;
|
|
463
|
+
/**
|
|
464
|
+
* Whether `tx.enqueuePlan` would build the sell now: the builder's preflight, which checks the
|
|
465
|
+
* queue gates, that the record is Open and the owner's, the order fee and the minimum sell. The
|
|
466
|
+
* market's SVI age under the order desk's `svi_max_age_ms` is checked only on chain, at
|
|
467
|
+
* placement.
|
|
468
|
+
*/
|
|
469
|
+
accepting: boolean;
|
|
470
|
+
/** The `PredictPreflightError` code the sell would get now, or null. */
|
|
471
|
+
refusal: PredictPreflightCode | null;
|
|
472
|
+
/** Pass `order.options` to `tx.enqueueSell`. */
|
|
473
|
+
order: {
|
|
474
|
+
builder: 'enqueueSell';
|
|
475
|
+
options: EnqueueSellOptions;
|
|
476
|
+
};
|
|
477
|
+
raw: {
|
|
478
|
+
slippage: bigint;
|
|
479
|
+
minProceeds: bigint;
|
|
480
|
+
minProbability: bigint;
|
|
481
|
+
orderFee: bigint;
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
/** `read.queue`: a market's queue state plus the derived figures the app shows. */
|
|
485
|
+
interface MarketQueueView extends MarketQueueState {
|
|
486
|
+
mode: ExecutionMode;
|
|
487
|
+
/** τ, deadline and cutoff for an order placed now, from the local clock. */
|
|
488
|
+
timing: TimingPreview;
|
|
489
|
+
/**
|
|
490
|
+
* Whether a new mint would pass the queue gates now: the same gates `enqueueMint*` checks
|
|
491
|
+
* before its fee and cash checks (the order-flow allowlist, the cutover, pauses, stuck, mint
|
|
492
|
+
* capacity, the cutoff, and the account cap when an owner was given). One side can be full
|
|
493
|
+
* while the other is open.
|
|
494
|
+
*/
|
|
495
|
+
acceptingMints: boolean;
|
|
496
|
+
/** Whether a new sell would pass the queue gates now (sells skip the mint pauses). */
|
|
497
|
+
acceptingSells: boolean;
|
|
498
|
+
/**
|
|
499
|
+
* Why each side refuses now, or null: the `PredictPreflightError` code the builder would
|
|
500
|
+
* throw for the queue gates.
|
|
501
|
+
*/
|
|
502
|
+
refusal: {
|
|
503
|
+
mint: PredictPreflightCode | null;
|
|
504
|
+
sell: PredictPreflightCode | null;
|
|
505
|
+
};
|
|
506
|
+
/** The largest mint the market's spare cash admits now. */
|
|
507
|
+
maxMint: {
|
|
508
|
+
exactQuantity: MaxMintNow;
|
|
509
|
+
budget: MaxMintNow;
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
/** A queue record and its display state. */
|
|
513
|
+
interface QueuedOrderView {
|
|
514
|
+
recordId: bigint;
|
|
515
|
+
record: QueuedOrder;
|
|
516
|
+
view: OrderView;
|
|
517
|
+
}
|
|
518
|
+
/** How `read.waitForOutcome` ended. */
|
|
519
|
+
interface QueuedOrderOutcome {
|
|
520
|
+
/** `'gone'`: the record is missing (cleaned up, or not landed). `'timeout'`: still waiting. */
|
|
521
|
+
outcome: 'filled' | 'refunded' | 'closed' | 'gone' | 'timeout';
|
|
522
|
+
order: QueuedOrderView | null;
|
|
523
|
+
}
|
|
524
|
+
/** A quote for selling an Open record early (`quote_redeem_open`). */
|
|
525
|
+
interface SellQuote {
|
|
526
|
+
/** The live per-contract probability. */
|
|
527
|
+
probability: number;
|
|
528
|
+
/** Proceeds before the order fee, with no congestion penalty. */
|
|
529
|
+
proceeds: number;
|
|
530
|
+
/**
|
|
531
|
+
* `proceeds − orderFee`: what the account nets. Negative when the order fee is above the
|
|
532
|
+
* proceeds, since the fee is charged at enqueue whatever the sell returns.
|
|
533
|
+
*/
|
|
534
|
+
net: number;
|
|
535
|
+
fees: {
|
|
536
|
+
trading: number;
|
|
537
|
+
builder: number;
|
|
538
|
+
inventoryImpactRebate: number;
|
|
539
|
+
order: number;
|
|
540
|
+
};
|
|
541
|
+
quantityClosed: number;
|
|
542
|
+
raw: {
|
|
543
|
+
probability: bigint;
|
|
544
|
+
proceeds: bigint;
|
|
545
|
+
orderFee: bigint;
|
|
546
|
+
quantityClosed: bigint;
|
|
547
|
+
};
|
|
548
|
+
}
|
|
192
549
|
type BinaryMarketCoordinates = Pick<MarketDescriptor, 'underlying' | 'expiryMs' | 'marketId'> & {
|
|
193
550
|
strike: number | 'reference';
|
|
194
551
|
};
|
|
@@ -209,14 +566,6 @@ declare function predict<Name extends string = 'predict'>({
|
|
|
209
566
|
network: 'testnet' | 'mainnet';
|
|
210
567
|
config?: PredictConfig;
|
|
211
568
|
}): SuiClientRegistration<PredictCompatibleClient, Name, PredictClient>;
|
|
212
|
-
/**
|
|
213
|
-
* The one object an app constructs. Wraps the config, a client for reads, and
|
|
214
|
-
* a derived-account model so callers pass owner addresses, decimal amounts, and
|
|
215
|
-
* human market coordinates — the facade converts to raw units, resolves markets
|
|
216
|
-
* (cached), and delegates to the internal tx primitives / reads. Each `tx.*` builder
|
|
217
|
-
* returns a finished `Transaction`; callers composing their own PTBs use the generated
|
|
218
|
-
* move-call bindings this subpath exports (`plpMoveCalls`, `expiryMarketMoveCalls`, …).
|
|
219
|
-
*/
|
|
220
569
|
declare class PredictClient {
|
|
221
570
|
#private;
|
|
222
571
|
readonly cfg: PredictConfig;
|
|
@@ -227,6 +576,12 @@ declare class PredictClient {
|
|
|
227
576
|
});
|
|
228
577
|
/** The deterministic id of an owner's canonical account wrapper — no chain read. */
|
|
229
578
|
wrapperIdFor(owner: string): string;
|
|
579
|
+
/**
|
|
580
|
+
* The deterministic id of a market's `MarketQueue` under the config's queue registry, whether
|
|
581
|
+
* or not it exists yet — no chain read. Throws `PredictInputError` while the config doesn't
|
|
582
|
+
* record delayed execution.
|
|
583
|
+
*/
|
|
584
|
+
queueIdFor(marketId: string): string;
|
|
230
585
|
readonly tx: {
|
|
231
586
|
createManager: () => Transaction;
|
|
232
587
|
deposit: (owner: string, amountUsdc: number | string, opts?: {
|
|
@@ -235,11 +590,110 @@ declare class PredictClient {
|
|
|
235
590
|
withdraw: (owner: string, amountUsdc: number | string, opts?: {
|
|
236
591
|
toCoinObject?: boolean;
|
|
237
592
|
}) => Transaction;
|
|
238
|
-
|
|
593
|
+
/**
|
|
594
|
+
* Immediate exact-quantity mint (`mint_exact_quantity`).
|
|
595
|
+
* @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it
|
|
596
|
+
* (`EDelayedExecutionRequired`), so it works only while the config calls a pre-v4 package.
|
|
597
|
+
* Use {@link PredictClient.tx.enqueueMint}, and `read.executionMode()` to know which path a
|
|
598
|
+
* network is on.
|
|
599
|
+
*/
|
|
600
|
+
mint: (owner: string, m: MarketDescriptor, opts: MintOptions) => Promise<Transaction>;
|
|
601
|
+
/**
|
|
602
|
+
* V2 all-in budget mint; use minQuantity to protect the fill against slippage.
|
|
603
|
+
* @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it
|
|
604
|
+
* (`EDelayedExecutionRequired`). Use `tx.enqueueMintCost`.
|
|
605
|
+
*/
|
|
239
606
|
mintCost: (owner: string, m: MarketDescriptor, opts: MintCostOptions) => Promise<Transaction>;
|
|
607
|
+
/**
|
|
608
|
+
* Immediate premium-budget mint (`mint_exact_amount`).
|
|
609
|
+
* @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it
|
|
610
|
+
* (`EDelayedExecutionRequired`). Use `tx.enqueueMintAmount`.
|
|
611
|
+
*/
|
|
240
612
|
mintAmount: (owner: string, m: MarketDescriptor, opts: MintAmountOptions) => Promise<Transaction>;
|
|
613
|
+
/**
|
|
614
|
+
* Immediate close of an account position (`redeem_live`).
|
|
615
|
+
* @deprecated Retired by delayed execution (DBU-885): Predict v4 always aborts it
|
|
616
|
+
* (`EDelayedExecutionRequired`). A position held in the account then has no early exit and
|
|
617
|
+
* is paid at settlement with `claimSettled`. Queued fills are Open records in the market's
|
|
618
|
+
* queue, sold with `tx.enqueueSell`.
|
|
619
|
+
*/
|
|
241
620
|
redeem: (owner: string, m: MarketDescriptor, opts: CloseOptions) => Promise<Transaction>;
|
|
621
|
+
/**
|
|
622
|
+
* Pay a settled position held in the ACCOUNT (`redeem_settled`), in full. Unchanged by delayed
|
|
623
|
+
* execution, for positions minted before it. It doesn't pay Open queue records: the queue's
|
|
624
|
+
* settlement walk (`settle_step`) pays those to the account's wrapper address.
|
|
625
|
+
*/
|
|
242
626
|
claimSettled: (owner: string, m: Pick<MarketDescriptor, "underlying" | "expiryMs" | "marketId">, opts: Pick<CloseOptions, "orderId">) => Promise<Transaction>;
|
|
627
|
+
/**
|
|
628
|
+
* Queue a mint of an exact payout quantity, filled at Pyth's price for its τ. Escrows
|
|
629
|
+
* `min(maxCost, quantity, available − fee)` plus the order fee. `maxCost` and
|
|
630
|
+
* `maxProbability` are required caps (see `queue.slippageBand`). Size against
|
|
631
|
+
* `read.queue(...).maxMint`. The record ID is in the enqueue's `OrderEnqueued`
|
|
632
|
+
* (`decode.enqueue`).
|
|
633
|
+
*/
|
|
634
|
+
enqueueMint: (owner: string, m: MarketDescriptor, opts: EnqueueMintOptions) => Promise<QueuedOrderPlan>;
|
|
635
|
+
/**
|
|
636
|
+
* Queue a premium-budget mint: sized at τ under `spend`, at least `minQuantity`, with the
|
|
637
|
+
* all-in debit capped by the required `maxCost`.
|
|
638
|
+
*/
|
|
639
|
+
enqueueMintAmount: (owner: string, m: MarketDescriptor, opts: EnqueueMintAmountOptions) => Promise<QueuedOrderPlan>;
|
|
640
|
+
/**
|
|
641
|
+
* Queue an all-in-budget mint (the default mint): sized at τ so the all-in cost fits
|
|
642
|
+
* `spend`, at least `minQuantity`. Escrows `min(spend, available − fee)` plus the order fee.
|
|
643
|
+
*/
|
|
644
|
+
enqueueMintCost: (owner: string, m: MarketDescriptor, opts: EnqueueMintCostOptions) => Promise<QueuedOrderPlan>;
|
|
645
|
+
/**
|
|
646
|
+
* Queue an early sell of an Open record (`enqueue_redeem_open`), the only early sell in v4.
|
|
647
|
+
* The record must be Open and the owner's. Sells are never refused for market cash: when the
|
|
648
|
+
* sell's cash need is above spare cash the preview sets `needsFunding`, and by default the
|
|
649
|
+
* builder adds `rebalance_expiry_cash` after the enqueue (see `fundMarket`). A sell the market
|
|
650
|
+
* still can't cover at the fill is refunded in full (reason 8) and the position returns to an
|
|
651
|
+
* Open record.
|
|
652
|
+
*/
|
|
653
|
+
enqueueSell: (owner: string, m: MarketCoordinates, opts: EnqueueSellOptions) => Promise<QueuedOrderPlan>;
|
|
654
|
+
/**
|
|
655
|
+
* Queue the order a `read.planMint` or `read.planSell` plan describes, with its limits:
|
|
656
|
+
* `enqueueMintCost`, `enqueueMint` or `enqueueSell`, by `plan.order.builder`. Pass the
|
|
657
|
+
* market the plan was made for: the descriptor a mint plan was planned with, or the
|
|
658
|
+
* coordinates `read.planSell` took for a sell plan. Throws the plan's `refusal` as a
|
|
659
|
+
* `PredictPreflightError`, and `'fee'` when the balance now escrows less than the plan's
|
|
660
|
+
* budget.
|
|
661
|
+
*/
|
|
662
|
+
enqueuePlan: <P extends MintPlan | SellPlan>(owner: string, m: P extends SellPlan ? MarketCoordinates : MarketDescriptor, plan: P) => Promise<QueuedOrderPlan>;
|
|
663
|
+
/**
|
|
664
|
+
* Refund this market's orders past their deadline. For the app's "Refund my order" button
|
|
665
|
+
* only (`OrderView.canRequestRefund`), never prepended to other transactions: keepers
|
|
666
|
+
* refund on their own. Needs no account, session or Pyth key, and works during a freeze.
|
|
667
|
+
* `maxOrders` (default 100) bounds the records visited.
|
|
668
|
+
*/
|
|
669
|
+
refund: (m: MarketCoordinates, opts?: {
|
|
670
|
+
maxOrders?: number;
|
|
671
|
+
}) => Promise<Transaction>;
|
|
672
|
+
/**
|
|
673
|
+
* Send a finished record's parked funds to its receive address (`queue::claim_parked`): a
|
|
674
|
+
* refund or change the address couldn't take while it was on USDC's deny list or USDC was
|
|
675
|
+
* paused (`OrderView` `parkedRaw`). A skipped settlement payout isn't parked: pay it with
|
|
676
|
+
* `payOpen`. Permissionless, and a no-op returning 0 while
|
|
677
|
+
* the address is still denied. Needs no account, session or Pyth key.
|
|
678
|
+
*/
|
|
679
|
+
claimParked: (m: MarketCoordinates, recordId: bigint) => Promise<Transaction>;
|
|
680
|
+
/**
|
|
681
|
+
* Pay a settled market's Open record that the payout walk skipped (`queue::pay_open`), for
|
|
682
|
+
* example while its receive address was denied. Permissionless: the payout goes only to the
|
|
683
|
+
* record's own receive address. Aborts `EMarketNotSettled` before settlement.
|
|
684
|
+
*/
|
|
685
|
+
payOpen: (m: MarketCoordinates, recordId: bigint) => Promise<Transaction>;
|
|
686
|
+
/**
|
|
687
|
+
* The open filler: verify signed Pyth Lazer payloads, commit them to the market's waiting
|
|
688
|
+
* cohorts, then resolve up to `maxOrders` (default 15) records. Reads the current Lazer
|
|
689
|
+
* package from Lazer's `State` first (`lazerStateId`, or `config.oracle.pythLazerState`).
|
|
690
|
+
*/
|
|
691
|
+
fill: (m: MarketCoordinates, opts: {
|
|
692
|
+
payloads: readonly Uint8Array[];
|
|
693
|
+
maxOrders?: number;
|
|
694
|
+
refundOverdue?: boolean;
|
|
695
|
+
lazerStateId?: string;
|
|
696
|
+
}) => Promise<Transaction>;
|
|
243
697
|
supplyPlp: (owner: string, amountUsdc: number | string, options?: PlpSupplyOptions) => Transaction;
|
|
244
698
|
withdrawPlp: (owner: string, shares: bigint, options?: PlpWithdrawOptions) => Transaction;
|
|
245
699
|
cancelSupplyPlp: (owner: string, index: bigint) => Transaction;
|
|
@@ -258,10 +712,119 @@ declare class PredictClient {
|
|
|
258
712
|
pricer: (m: Pick<MarketDescriptor, "underlying" | "expiryMs">) => Promise<BoardPricer & {
|
|
259
713
|
asOf: PricerSnapshot["sources"];
|
|
260
714
|
}>;
|
|
261
|
-
|
|
715
|
+
/**
|
|
716
|
+
* Exact pre-trade quote for an exact-quantity mint. Requires a funded account.
|
|
717
|
+
*
|
|
718
|
+
* Where the config records the delayed-execution upgrade (`packages.predictDelayedExecution`),
|
|
719
|
+
* this reads Predict's own `quote_mint_for_account` (the immediate mint is retired there) and
|
|
720
|
+
* the order desk's fee, and previews a QUEUED fill at the clock: `queued: true`, no
|
|
721
|
+
* congestion penalty in `cost`, and the order fee in `orderFee`. The fill itself prices at
|
|
722
|
+
* its committed Pyth tick. It throws `PredictInputError` when that config lacks the
|
|
723
|
+
* order-flow package or its desk. Elsewhere it dry-runs the immediate mint and decodes its
|
|
724
|
+
* receipt, as before.
|
|
725
|
+
*/
|
|
726
|
+
quoteMint: (owner: string, m: MarketDescriptor, opts: Pick<MintOptions, "quantity">) => Promise<MintQuote>;
|
|
727
|
+
/**
|
|
728
|
+
* Quote the all-in budget mint against current account and market state. Where the config
|
|
729
|
+
* records the delayed-execution upgrade, it reads `quote_mint_exact_cost_for_account` at
|
|
730
|
+
* `min(spend, available − fee)`, the budget enqueue escrows, and previews a queued fill as
|
|
731
|
+
* `quoteMint` does (and throws as it does on a partial config). Elsewhere it simulates the
|
|
732
|
+
* immediate v2 mint.
|
|
733
|
+
*/
|
|
262
734
|
quoteMintCost: (owner: string, m: MarketDescriptor, opts: MintCostOptions) => Promise<MintQuote>;
|
|
735
|
+
/**
|
|
736
|
+
* Quote an early sell of an Open record (the queue's `quote_redeem_open`) at a fresh live
|
|
737
|
+
* pricer. `proceeds` is before the order fee, with no congestion penalty, and `net` takes the
|
|
738
|
+
* fee off. Throws `ERecordNotOpen` when the record isn't Open.
|
|
739
|
+
*/
|
|
740
|
+
quoteSell: (owner: string, m: MarketCoordinates, opts: {
|
|
741
|
+
recordId: bigint;
|
|
742
|
+
quantity: number;
|
|
743
|
+
}) => Promise<SellQuote>;
|
|
744
|
+
/**
|
|
745
|
+
* Which trade path the network is on, from `ProtocolConfig.version_watermark` and whether
|
|
746
|
+
* this config records delayed execution (the Predict upgrade, the order-flow companion and
|
|
747
|
+
* its desk). Flip the app between `mint*` and `enqueue*` on it, without a redeploy at the
|
|
748
|
+
* watermark bump.
|
|
749
|
+
*/
|
|
750
|
+
executionMode: () => Promise<ExecutionMode>;
|
|
751
|
+
/**
|
|
752
|
+
* A market's queue in one read: cash, the stuck gate ("pricing delayed"), cohorts, counters
|
|
753
|
+
* against capacity, the desk's policy, a τ/deadline/cutoff preview, and the largest mint
|
|
754
|
+
* spare cash admits now. With `owner` (who must have an account), also the account's
|
|
755
|
+
* waiting orders and balance. Throws `PredictPreflightError` `'no-queue'` while the market
|
|
756
|
+
* has no `MarketQueue`.
|
|
757
|
+
*/
|
|
758
|
+
queue: (m: MarketCoordinates, owner?: string) => Promise<MarketQueueView>;
|
|
759
|
+
/**
|
|
760
|
+
* Plan a queued mint for a purchase form: the quote at the current price, the payout and
|
|
761
|
+
* multiple, the order fee read from the desk, the escrow and debit, the balance, the most
|
|
762
|
+
* the market takes now, the timing and the queue gates, plus the enqueue options that carry
|
|
763
|
+
* the slippage. `amount` plans an all-in spend (`enqueueMintCost`, refunded below the payout
|
|
764
|
+
* floor), and `quantity` an exact payout (`enqueueMint`, capped by probability and cost).
|
|
765
|
+
* Works for a visitor without an account: the quote then comes from `quote_mint`.
|
|
766
|
+
*
|
|
767
|
+
* `slippageCents` is cents per contract, never a percentage: a 10¢ limit fills while the
|
|
768
|
+
* all-in price per contract stays within 10¢ of the quote's price without its fee subsidy.
|
|
769
|
+
*/
|
|
770
|
+
planMint: (owner: string, m: MarketDescriptor, opts: PlanMintOptions) => Promise<MintPlan>;
|
|
771
|
+
/**
|
|
772
|
+
* Plan a queued early sell of an Open record: the quote at the current price, net of the
|
|
773
|
+
* order fee, the floors at the worst price the slippage allows, the timing and the
|
|
774
|
+
* builder's preflight, plus the `enqueueSell` options that carry the floors. A record that
|
|
775
|
+
* isn't Open has no quote, so it throws `PredictPreflightError` `'record-not-open'` instead.
|
|
776
|
+
*/
|
|
777
|
+
planSell: (owner: string, m: MarketCoordinates, opts: PlanSellOptions) => Promise<SellPlan>; /** One queue record and its display state, or null when missing or cleaned up. */
|
|
778
|
+
order: (m: MarketCoordinates, recordId: bigint) => Promise<QueuedOrderView | null>;
|
|
779
|
+
/**
|
|
780
|
+
* Queue records by record ID, with their display states. The SDK has no indexer: the app
|
|
781
|
+
* supplies record IDs from its enqueue receipts or its indexer.
|
|
782
|
+
*/
|
|
783
|
+
orders: (m: MarketCoordinates, recordIds: readonly bigint[]) => Promise<(QueuedOrderView | null)[]>;
|
|
784
|
+
/**
|
|
785
|
+
* Poll a record until it is filled, refunded or closed (`pollMs`, default 250), or until
|
|
786
|
+
* `timeoutMs` (default 30 s). The fullnode a client reads can trail the enqueue's
|
|
787
|
+
* execution, so a record not seen yet is polled again until the timeout, and ends as
|
|
788
|
+
* `'gone'` only then. A record that disappears after it was seen ends as `'gone'` at once.
|
|
789
|
+
* The record's result is enough for the UI; the fee breakdown is in the
|
|
790
|
+
* `QueuedOrderFilled` event.
|
|
791
|
+
*/
|
|
792
|
+
waitForOutcome: (m: MarketCoordinates, recordId: bigint, opts?: {
|
|
793
|
+
pollMs?: number;
|
|
794
|
+
timeoutMs?: number;
|
|
795
|
+
signal?: AbortSignal;
|
|
796
|
+
}) => Promise<QueuedOrderOutcome>;
|
|
797
|
+
/**
|
|
798
|
+
* USDC sent to the owner's account wrapper that the account hasn't settled yet: refunds,
|
|
799
|
+
* sell proceeds and settled payouts of Open records. Already counted in `read.balance`; for
|
|
800
|
+
* display.
|
|
801
|
+
*/
|
|
802
|
+
pendingFunds: (owner: string) => Promise<number>; /** The current Pyth Lazer package, for a filler. Read it per batch and never cache it. */
|
|
803
|
+
lazerPackages: (stateId?: string) => Promise<LazerPackages>;
|
|
804
|
+
/**
|
|
805
|
+
* Exact pre-close quote for an ACCOUNT position: dry-runs the immediate redeem and decodes
|
|
806
|
+
* the receipt.
|
|
807
|
+
* @deprecated `redeem_live` is retired by delayed execution (DBU-885): Predict v4 always
|
|
808
|
+
* aborts it. Queued fills are Open records: quote them with `read.quoteSell`.
|
|
809
|
+
*/
|
|
263
810
|
quoteRedeem: (owner: string, m: MarketDescriptor, opts: CloseOptions) => Promise<RedeemQuote>;
|
|
264
811
|
market: (m: Pick<MarketDescriptor, "underlying" | "expiryMs">) => Promise<MarketSummary | null>;
|
|
812
|
+
/**
|
|
813
|
+
* The market's settlement price, or `null` until a keeper settles it. Unlike `market`,
|
|
814
|
+
* `price` and the quotes, which abort `ELivePricingExpired` once the market expires, it
|
|
815
|
+
* keeps working after expiry, when an app shows results. With delayed execution the
|
|
816
|
+
* keeper settles a market, pays its Open records and cleans them up within about a second
|
|
817
|
+
* of expiry, so `read.order` returns `null` by then. Keep each filled record's
|
|
818
|
+
* `position.orderId` and pass it to `cost.settledPayout` with this price.
|
|
819
|
+
*/
|
|
820
|
+
settlement: (m: MarketCoordinates) => Promise<MarketSettlement>;
|
|
821
|
+
/**
|
|
822
|
+
* The fee and exposure policy the market snapshotted at creation, ready to pass to the
|
|
823
|
+
* `cost` functions as `fees`. A market keeps it for its whole life, so it can differ from
|
|
824
|
+
* the protocol's current template, and neither recorded deployment's template matches
|
|
825
|
+
* `cost.SHIPPED_FEE_POLICY` any more. One object read.
|
|
826
|
+
*/
|
|
827
|
+
feePolicy: (m: MarketCoordinates) => Promise<FeePolicy>;
|
|
265
828
|
balance: (owner: string) => Promise<number>;
|
|
266
829
|
plpBalance: (owner: string) => Promise<bigint>;
|
|
267
830
|
pool: () => Promise<PoolSummary>;
|
|
@@ -278,9 +841,25 @@ declare class PredictClient {
|
|
|
278
841
|
withdraw: (r: DecodableTransactionResult) => BalanceChangeReceipt;
|
|
279
842
|
plpRequest: (r: DecodableTransactionResult) => PlpRequestReceipt;
|
|
280
843
|
plpCancel: (r: DecodableTransactionResult) => PlpCancelReceipt;
|
|
281
|
-
builderCode: (r: DecodableTransactionResult) => BuilderCodeReceipt;
|
|
844
|
+
builderCode: (r: DecodableTransactionResult) => BuilderCodeReceipt; /** The trader's `OrderEnqueued` receipt: the record ID, τ, deadline, escrow and fee. */
|
|
845
|
+
enqueue: (r: DecodableTransactionResult) => EnqueueReceipt;
|
|
846
|
+
enqueues: (r: DecodableTransactionResult) => EnqueueReceipt[]; /** Every queue event, tagged, in chain order: feed it to `queue.reduceOrderEvents`. */
|
|
847
|
+
queueEvents: (r: DecodableTransactionResult) => QueueEvent[];
|
|
848
|
+
cohortCommits: (r: DecodableTransactionResult) => CohortCommitReceipt[];
|
|
849
|
+
queuedFills: (r: DecodableTransactionResult) => QueuedFillReceipt[];
|
|
850
|
+
queuedRefunds: (r: DecodableTransactionResult) => QueuedRefundReceipt[];
|
|
851
|
+
openRecordPayouts: (r: DecodableTransactionResult) => OpenRecordPayoutReceipt[];
|
|
852
|
+
marketPayoutsCompleted: (r: DecodableTransactionResult) => MarketPayoutsCompletedReceipt[];
|
|
853
|
+
queueOps: (r: DecodableTransactionResult) => QueueOpsReceipt[]; /** `RecordFundsParked` and `RecordFundsClaimed`: USDC a record keeps until it can be sent. */
|
|
854
|
+
recordFunds: (r: DecodableTransactionResult) => RecordFundsReceipt[];
|
|
855
|
+
policyUpdates: (r: DecodableTransactionResult) => PolicyUpdateReceipt[];
|
|
856
|
+
/**
|
|
857
|
+
* `ExpiryPnlRealized` changes in the pool's gross realized result, for P&L reporting. Sum
|
|
858
|
+
* them with `realizedPnlRaw`.
|
|
859
|
+
*/
|
|
860
|
+
expiryPnlRealized: (r: DecodableTransactionResult) => ExpiryPnlRealizedReceipt[];
|
|
282
861
|
};
|
|
283
862
|
}
|
|
284
863
|
//#endregion
|
|
285
|
-
export { ActiveMarket, CloseOptions, MarketDescriptor, MarketSummary, MintAmountOptions, MintCostOptions, MintOptions, MintQuote, POSITION_LOT_SIZE, PlpSupplyOptions, PlpWithdrawOptions, PoolSummary, PredictClient, PredictCompatibleClient, RedeemQuote, predict };
|
|
864
|
+
export { ActiveMarket, AppliedSlippage, CloseOptions, EnqueueMintAmountOptions, EnqueueMintCostOptions, EnqueueMintOptions, EnqueueSellOptions, MarketCoordinates, MarketDescriptor, MarketQueueView, MarketSettlement, MarketSummary, MintAmountOptions, MintCostOptions, MintOptions, MintPlan, MintQuote, POSITION_LOT_SIZE, PlanMintOptions, PlanSellOptions, PlpSupplyOptions, PlpWithdrawOptions, PoolSummary, PredictClient, PredictCompatibleClient, QueuedOrderOutcome, QueuedOrderPlan, QueuedOrderPreview, QueuedOrderView, RedeemQuote, SellPlan, SellQuote, SlippageOptions, predict };
|
|
286
865
|
//# sourceMappingURL=client.d.mts.map
|