@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
|
@@ -63,7 +63,7 @@ export const WithdrawRequested = new MoveStruct({
|
|
|
63
63
|
recipient: bcs.Address,
|
|
64
64
|
index: U64,
|
|
65
65
|
amount: U64,
|
|
66
|
-
|
|
66
|
+
min_usdc_out: U64,
|
|
67
67
|
requests_pending_after: U64,
|
|
68
68
|
},
|
|
69
69
|
});
|
|
@@ -107,20 +107,20 @@ export const SupplyFilled = new MoveStruct({
|
|
|
107
107
|
recipient: bcs.Address,
|
|
108
108
|
index: U64,
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* USDC actually taken into the pool, which is less than the request's escrow when
|
|
111
111
|
* the supply cap left only part of it room. Shares were priced on
|
|
112
|
-
* `
|
|
112
|
+
* `usdc_amount - fee_usdc`.
|
|
113
113
|
*/
|
|
114
|
-
|
|
114
|
+
usdc_amount: U64,
|
|
115
115
|
shares_minted: U64,
|
|
116
|
-
/** Supply fee withheld from `
|
|
117
|
-
|
|
116
|
+
/** Supply fee withheld from `usdc_amount` and retained by the pool. */
|
|
117
|
+
fee_usdc: U64,
|
|
118
118
|
/**
|
|
119
119
|
* Escrow still queued at the head after a partial fill; `0` on a full fill, in
|
|
120
|
-
* which case the request is gone. `
|
|
121
|
-
*
|
|
120
|
+
* which case the request is gone. `usdc_amount + usdc_remaining` is the amount the
|
|
121
|
+
* request carried into this flush.
|
|
122
122
|
*/
|
|
123
|
-
|
|
123
|
+
usdc_remaining: U64,
|
|
124
124
|
requests_pending_after: U64,
|
|
125
125
|
},
|
|
126
126
|
});
|
|
@@ -133,12 +133,12 @@ export const WithdrawFilled = new MoveStruct({
|
|
|
133
133
|
index: U64,
|
|
134
134
|
shares_burned: U64,
|
|
135
135
|
/**
|
|
136
|
-
* Net
|
|
137
|
-
*
|
|
136
|
+
* Net USDC delivered to `recipient`. The gross marked value of `shares_burned` was
|
|
137
|
+
* `usdc_amount + fee_usdc`.
|
|
138
138
|
*/
|
|
139
|
-
|
|
139
|
+
usdc_amount: U64,
|
|
140
140
|
/** Withdraw fee withheld from the payout and retained by the pool. */
|
|
141
|
-
|
|
141
|
+
fee_usdc: U64,
|
|
142
142
|
/**
|
|
143
143
|
* Escrowed PLP still queued at the head after a partial fill; `0` on a full fill,
|
|
144
144
|
* in which case the request is gone. `shares_burned + shares_remaining` is the
|
|
@@ -174,14 +174,45 @@ export const FlushExecuted = new MoveStruct({
|
|
|
174
174
|
active_market_nav: U64,
|
|
175
175
|
/** Number of active markets valued for this flush. */
|
|
176
176
|
market_count: U64,
|
|
177
|
-
/**
|
|
177
|
+
/**
|
|
178
|
+
* LIVE idle USDC read at finish time, immediately before the drain — NOT a mark
|
|
179
|
+
* input. It brackets the drain with `idle_balance_after`; because maintenance,
|
|
180
|
+
* settlement sweeps, and trading run mid-window, it can differ from
|
|
181
|
+
* `frozen_idle_balance` below. Drain telemetry, not the mark.
|
|
182
|
+
*/
|
|
178
183
|
idle_balance_before: U64,
|
|
184
|
+
/**
|
|
185
|
+
* The mark's idle component: idle USDC FROZEN at the seal. `frozen_idle_balance
|
|
186
|
+
*
|
|
187
|
+
* - active_market_nav`reconstructs the priced mark's gross; every fill in the flush is priced from this, never from`idle_balance_before`.
|
|
188
|
+
*/
|
|
189
|
+
frozen_idle_balance: U64,
|
|
179
190
|
supplies_filled: U64,
|
|
180
191
|
withdrawals_filled: U64,
|
|
181
192
|
requests_processed: U64,
|
|
182
193
|
idle_balance_after: U64,
|
|
183
194
|
/** PLP supply after the drain's completed mints and burns. */
|
|
184
195
|
total_supply_after: U64,
|
|
196
|
+
/**
|
|
197
|
+
* Each queue's `next_index` at this flush's snapshot instant; the drain filled
|
|
198
|
+
* only requests indexed strictly below these.
|
|
199
|
+
*/
|
|
200
|
+
supply_request_cutoff: U64,
|
|
201
|
+
withdraw_request_cutoff: U64,
|
|
202
|
+
/**
|
|
203
|
+
* Clock instant the snapshot stage froze every market's pricer — the moment the
|
|
204
|
+
* mark prices the pool at. Fills execute later in the same flush; this is the
|
|
205
|
+
* timestamp they were priced as of.
|
|
206
|
+
*/
|
|
207
|
+
snapshot_timestamp_ms: U64,
|
|
208
|
+
},
|
|
209
|
+
});
|
|
210
|
+
export const FlushRestarted = new MoveStruct({
|
|
211
|
+
name: `${$moduleName}::FlushRestarted`,
|
|
212
|
+
fields: {
|
|
213
|
+
pool_vault_id: bcs.Address,
|
|
214
|
+
expected_market_count: U64,
|
|
215
|
+
valued_market_count: U64,
|
|
185
216
|
},
|
|
186
217
|
});
|
|
187
218
|
export const CapitalLocked = new MoveStruct({
|
|
@@ -23,29 +23,16 @@ import { type Transaction, type TransactionArgument } from '@mysten/sui/transact
|
|
|
23
23
|
import * as table from './deps/sui/table.js';
|
|
24
24
|
const $moduleName = '@local-pkg/propbook::block_scholes_store';
|
|
25
25
|
/**
|
|
26
|
-
* One accepted observation
|
|
27
|
-
*
|
|
28
|
-
* not changed republishes under its original model time, so only
|
|
29
|
-
* `source_timestamp_ms` distinguishes a quiet feed from a stopped one.
|
|
26
|
+
* One accepted observation paired with its signed source time and on-chain
|
|
27
|
+
* recording time.
|
|
30
28
|
*/
|
|
31
29
|
export function BsRead<Value extends BcsType<any>>(...typeParameters: [Value]) {
|
|
32
30
|
return new MoveStruct({
|
|
33
31
|
name: `${$moduleName}::BsRead<${typeParameters[0].name as Value['name']}>`,
|
|
34
32
|
fields: {
|
|
35
33
|
/**
|
|
36
|
-
* Provider
|
|
37
|
-
*
|
|
38
|
-
* ordering keys on this first. The published VALUES are as-of the envelope time:
|
|
39
|
-
* per the provider contract, an SVI publish whose model time is unchanged carries
|
|
40
|
-
* the same calibration already rolled down to its new publish time, never
|
|
41
|
-
* duplicate data.
|
|
42
|
-
*/
|
|
43
|
-
model_timestamp_ms: U64,
|
|
44
|
-
/**
|
|
45
|
-
* Envelope time of the batch this observation arrived in, advancing on every
|
|
46
|
-
* provider flush and never regressing once stored (see `apply`). The economic
|
|
47
|
-
* clock: consumers gate freshness on it and the SVI roll-down anchors on it, so a
|
|
48
|
-
* republished unchanged value is re-asserted as current at its new envelope time.
|
|
34
|
+
* Provider value/SVI time in Unix milliseconds. Latest ordering, exact history,
|
|
35
|
+
* freshness, and SVI roll-down all key on this clock.
|
|
49
36
|
*/
|
|
50
37
|
source_timestamp_ms: U64,
|
|
51
38
|
/** Sui clock time when the accepting transaction executed. */
|
|
@@ -135,7 +122,7 @@ export const BlockScholesBatchIngested = new MoveStruct({
|
|
|
135
122
|
propbook_oracle_id: bcs.Address,
|
|
136
123
|
/** `0` = spot, `1` = forward, and `2` = SVI. */
|
|
137
124
|
series_kind: bcs.u8(),
|
|
138
|
-
|
|
125
|
+
batch_timestamp_ms: U64,
|
|
139
126
|
/** Sui clock time when the batch ingestion transaction executed. */
|
|
140
127
|
onchain_timestamp_ms: U64,
|
|
141
128
|
/** Verified observations carried by the batch. */
|
|
@@ -366,8 +353,8 @@ export interface SpotAtOptions {
|
|
|
366
353
|
];
|
|
367
354
|
}
|
|
368
355
|
/**
|
|
369
|
-
* Returns the canonical spot observation
|
|
370
|
-
* `source_timestamp_ms`.
|
|
356
|
+
* Returns the canonical spot observation whose provider source timestamp is
|
|
357
|
+
* exactly `source_timestamp_ms`.
|
|
371
358
|
*/
|
|
372
359
|
export function spotAt(options: SpotAtOptions) {
|
|
373
360
|
const packageAddress = options.package ?? '@local-pkg/propbook';
|
|
@@ -427,27 +414,6 @@ export function svi(options: SviOptions) {
|
|
|
427
414
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
428
415
|
});
|
|
429
416
|
}
|
|
430
|
-
export interface ReadModelTimestampMsArguments {
|
|
431
|
-
read: TransactionArgument;
|
|
432
|
-
}
|
|
433
|
-
export interface ReadModelTimestampMsOptions {
|
|
434
|
-
package?: string;
|
|
435
|
-
arguments: ReadModelTimestampMsArguments | [read: TransactionArgument];
|
|
436
|
-
typeArguments: [string];
|
|
437
|
-
}
|
|
438
|
-
export function readModelTimestampMs(options: ReadModelTimestampMsOptions) {
|
|
439
|
-
const packageAddress = options.package ?? '@local-pkg/propbook';
|
|
440
|
-
const argumentsTypes = [null] satisfies (string | null)[];
|
|
441
|
-
const parameterNames = ['read'];
|
|
442
|
-
return (tx: Transaction) =>
|
|
443
|
-
tx.moveCall({
|
|
444
|
-
package: packageAddress,
|
|
445
|
-
module: 'block_scholes_store',
|
|
446
|
-
function: 'read_model_timestamp_ms',
|
|
447
|
-
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
448
|
-
typeArguments: options.typeArguments,
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
417
|
export interface ReadSourceTimestampMsArguments {
|
|
452
418
|
read: TransactionArgument;
|
|
453
419
|
}
|
|
@@ -717,7 +683,7 @@ export interface InsertAtOptions {
|
|
|
717
683
|
}
|
|
718
684
|
/**
|
|
719
685
|
* Insert the canonical spot batch into exact minute-boundary history without
|
|
720
|
-
* changing `latest`. A valid batch whose
|
|
686
|
+
* changing `latest`. A valid batch whose spot update source timestamp is not a
|
|
721
687
|
* minute boundary, or whose spot is zero or wider than `u64`, is ignored without
|
|
722
688
|
* aborting. The first admissible observation at a boundary owns the key and cannot
|
|
723
689
|
* be replaced.
|
package/src/deployments/index.ts
CHANGED
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
|
|
13
13
|
import type { SuiClientTypes } from '@mysten/sui/client';
|
|
14
14
|
|
|
15
|
+
import {
|
|
16
|
+
MAINNET_ACCOUNT,
|
|
17
|
+
MAINNET_DEPLOYMENT,
|
|
18
|
+
MAINNET_PREDICT,
|
|
19
|
+
MAINNET_SESSIONS,
|
|
20
|
+
MAINNET_UNITS,
|
|
21
|
+
} from './mainnet.js';
|
|
15
22
|
import {
|
|
16
23
|
TESTNET_ACCOUNT,
|
|
17
24
|
TESTNET_DEPLOYMENT,
|
|
@@ -30,9 +37,10 @@ export type {
|
|
|
30
37
|
} from './types.js';
|
|
31
38
|
|
|
32
39
|
export { TESTNET_ACCOUNT, TESTNET_DEPLOYMENT, TESTNET_PREDICT, TESTNET_SESSIONS, TESTNET_UNITS };
|
|
40
|
+
export { MAINNET_ACCOUNT, MAINNET_DEPLOYMENT, MAINNET_PREDICT, MAINNET_SESSIONS, MAINNET_UNITS };
|
|
33
41
|
|
|
34
|
-
/** Networks this package carries ids for.
|
|
35
|
-
export type DeployedNetwork = 'testnet';
|
|
42
|
+
/** Networks this package carries ids for. */
|
|
43
|
+
export type DeployedNetwork = 'testnet' | 'mainnet';
|
|
36
44
|
|
|
37
45
|
/**
|
|
38
46
|
* Accepts the same wide network type the Sui client exposes, so `getUnits(client.network)`
|
|
@@ -45,7 +53,7 @@ export type NetworkArg = SuiClientTypes.Network;
|
|
|
45
53
|
function unrecorded(network: string, override: string): Error {
|
|
46
54
|
return new Error(
|
|
47
55
|
`@mysten/deepbook-v3: no deployment recorded for network '${network}'. ` +
|
|
48
|
-
'Predict, sessions and the account primitive are testnet
|
|
56
|
+
'Predict, sessions and the account primitive are recorded for testnet and mainnet. ' +
|
|
49
57
|
`For your own deployment, ${override}`,
|
|
50
58
|
);
|
|
51
59
|
}
|
|
@@ -58,6 +66,7 @@ function unrecorded(network: string, override: string): Error {
|
|
|
58
66
|
*/
|
|
59
67
|
export function getDeployment(network: NetworkArg): DeploymentInfo {
|
|
60
68
|
if (network === 'testnet') return TESTNET_DEPLOYMENT;
|
|
69
|
+
if (network === 'mainnet') return MAINNET_DEPLOYMENT;
|
|
61
70
|
throw unrecorded(network, 'read the deployment name and commit from your own deploy manifest.');
|
|
62
71
|
}
|
|
63
72
|
|
|
@@ -69,5 +78,6 @@ export function getDeployment(network: NetworkArg): DeploymentInfo {
|
|
|
69
78
|
*/
|
|
70
79
|
export function getUnits(network: NetworkArg): DeploymentUnits {
|
|
71
80
|
if (network === 'testnet') return TESTNET_UNITS;
|
|
81
|
+
if (network === 'mainnet') return MAINNET_UNITS;
|
|
72
82
|
throw unrecorded(network, 'read these scale constants from your own deploy manifest.');
|
|
73
83
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
// GENERATED by `pnpm sync-deployment` from the deploy tooling's own manifest
|
|
5
|
+
// (`packages/predict/deployment/deployment.mainnet.json`). Do not hand-edit:
|
|
6
|
+
// the next regeneration overwrites it, and a hand-patched id is exactly the drift this
|
|
7
|
+
// file exists to prevent. To move to a new deployment, check the sibling deepbookv3
|
|
8
|
+
// checkout out to the new anchor and re-run the script.
|
|
9
|
+
//
|
|
10
|
+
// Deployment: deepbook-predict-mainnet
|
|
11
|
+
// sourceCommit: 14a7e8f822e0397df2d61fbfbce3ef21086891c2
|
|
12
|
+
//
|
|
13
|
+
// Runtime-dependency-free — every subpath reads a slice of this, so a value import here
|
|
14
|
+
// would pull that module into all of their graphs. The type import below is erased.
|
|
15
|
+
//
|
|
16
|
+
// Frozen: these are shared module singletons, so an accessor handing one to a caller who
|
|
17
|
+
// mutates it would change what every other caller sees.
|
|
18
|
+
|
|
19
|
+
import type {
|
|
20
|
+
AccountIds,
|
|
21
|
+
DeploymentInfo,
|
|
22
|
+
DeploymentUnits,
|
|
23
|
+
PredictIds,
|
|
24
|
+
SessionsIds,
|
|
25
|
+
} from './types.js';
|
|
26
|
+
|
|
27
|
+
/** Which on-chain deployment the ids below came from. */
|
|
28
|
+
export const MAINNET_DEPLOYMENT: DeploymentInfo = Object.freeze({
|
|
29
|
+
deployment: 'deepbook-predict-mainnet',
|
|
30
|
+
network: 'mainnet',
|
|
31
|
+
chainId: '35834a8a',
|
|
32
|
+
sourceCommit: '14a7e8f822e0397df2d61fbfbce3ef21086891c2',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/** Ids for the shared `account` primitive — the `/account` subpath's slice. */
|
|
36
|
+
export const MAINNET_ACCOUNT: AccountIds = Object.freeze({
|
|
37
|
+
accountPackageId: '0xa6f1b22aaeb429f6fd8f01c13f605256e00876457fd122da8a0e2c1045c75929',
|
|
38
|
+
accountRegistry: '0x210ba485d973b5356e9078318837137efabdd5ffb9eeb3705ba7eef3340324fc',
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Ids for time-limited sessions — the `/sessions` subpath's slice.
|
|
43
|
+
*
|
|
44
|
+
* `deepbookRegistry` is only needed by the DeepBook **spot** session wrappers; the Predict
|
|
45
|
+
* wrappers never take it. It is carried here so a spot caller does not have to reach into
|
|
46
|
+
* the package root for one id.
|
|
47
|
+
*/
|
|
48
|
+
export const MAINNET_SESSIONS: SessionsIds = Object.freeze({
|
|
49
|
+
sessionsPackageId: '0xebfa125baee571c1f8c903c1dd54a5bc57949db82469b836c32eca251756c82a',
|
|
50
|
+
sessionsConfig: '0x0c5f64365b3bf1f67827d6975893190079cc048247f9ff0b08390aa9ee697c5c',
|
|
51
|
+
accountPackageId: '0xa6f1b22aaeb429f6fd8f01c13f605256e00876457fd122da8a0e2c1045c75929',
|
|
52
|
+
accountRegistry: '0x210ba485d973b5356e9078318837137efabdd5ffb9eeb3705ba7eef3340324fc',
|
|
53
|
+
deepbookRegistry: '0xaf16199a2dff736e9f07a845f23c5da6df6f756eddb631aed9d24a93efc4549d',
|
|
54
|
+
deepbookCoreAccountPackageId:
|
|
55
|
+
'0xebcd5b403ee78021e3f78d1c77e2117a676caa8a9754dedb99e7b102b0d81872',
|
|
56
|
+
/** Required by every Predict session wrapper — they all take `config: &ProtocolConfig`. */
|
|
57
|
+
protocolConfig: '0x55e8800bcb31b792683ca4385bd533716e2a9721364236a69ee2c3bee61dd8f2',
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Scale constants the deployment owns rather than the SDK. Deployment-wide:
|
|
62
|
+
* `quoteCoinDecimals` and `fixedPointScale` apply to any subpath formatting a custody
|
|
63
|
+
* balance, not just Predict.
|
|
64
|
+
*/
|
|
65
|
+
export const MAINNET_UNITS: DeploymentUnits = Object.freeze({
|
|
66
|
+
positionLotSize: 10000,
|
|
67
|
+
fixedPointScale: 1000000000,
|
|
68
|
+
quoteCoinDecimals: 6,
|
|
69
|
+
positionQuantityDecimals: 6,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/** Ids for DeepBook Predict — the `/predict` subpath's slice. */
|
|
73
|
+
export const MAINNET_PREDICT: PredictIds = Object.freeze({
|
|
74
|
+
network: 'mainnet',
|
|
75
|
+
packages: Object.freeze({
|
|
76
|
+
predict: '0x774f9555865a7b96e31ec982f62d5bdf9d74bf57a6468b5ed41340c231afd7df',
|
|
77
|
+
account: '0xa6f1b22aaeb429f6fd8f01c13f605256e00876457fd122da8a0e2c1045c75929',
|
|
78
|
+
propbook: '0x2a63e378ab0138cdcb12651a093f3799f8b8e4f6c927ce6de0e8bc7ded0ec49d',
|
|
79
|
+
}),
|
|
80
|
+
objects: Object.freeze({
|
|
81
|
+
registry: '0xc98e430d82bed9f777288061faa1988da705a97db7f0da9f215ab372c53a2362',
|
|
82
|
+
protocolConfig: '0x55e8800bcb31b792683ca4385bd533716e2a9721364236a69ee2c3bee61dd8f2',
|
|
83
|
+
poolVault: '0x3f80653bf9324162254d89724276aae7b36ba7c83d4650214afbf266da98f492',
|
|
84
|
+
oracleRegistry: '0x1ff67a8499b0af7c0fbb26ba82c319be25413af93d9a961ee60f8d1229e7de7c',
|
|
85
|
+
accountRegistry: '0x210ba485d973b5356e9078318837137efabdd5ffb9eeb3705ba7eef3340324fc',
|
|
86
|
+
}),
|
|
87
|
+
quoteCoinType: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC',
|
|
88
|
+
/**
|
|
89
|
+
* `plp` is the LP share coin type. It is NOT derivable from `packages.predict`: a Move
|
|
90
|
+
* type tag keeps the ORIGINAL package id across an upgrade, while `packages.predict`
|
|
91
|
+
* moves to the latest. They agree only while predict is at v1.
|
|
92
|
+
*/
|
|
93
|
+
coinTypes: Object.freeze({
|
|
94
|
+
plp: '0x774f9555865a7b96e31ec982f62d5bdf9d74bf57a6468b5ed41340c231afd7df::plp::PLP',
|
|
95
|
+
deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP',
|
|
96
|
+
}),
|
|
97
|
+
units: MAINNET_UNITS,
|
|
98
|
+
underlyings: Object.freeze({
|
|
99
|
+
BTC: Object.freeze({
|
|
100
|
+
symbol: 'BTC',
|
|
101
|
+
propbookUnderlyingId: 1,
|
|
102
|
+
pythFeed: '0x44bd2e00549973bb6a58785836e97ed80b4979e67dc3bf312c997e56053e5376',
|
|
103
|
+
blockScholesValueStore: '0xe7c83ee4ac0c300d68d8d4c3d265d78287b4767dcbc5f279cd6f210b6248d493',
|
|
104
|
+
blockScholesSviStore: '0x8e5568aebf490c2adfd4e010a9b4ddcf7c774183f58c98fcd438bae1fc68f561',
|
|
105
|
+
}),
|
|
106
|
+
}),
|
|
107
|
+
});
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
// file exists to prevent. To move to a new deployment, check the sibling deepbookv3
|
|
8
8
|
// checkout out to the new anchor and re-run the script.
|
|
9
9
|
//
|
|
10
|
-
// Deployment: predict-testnet
|
|
11
|
-
// sourceCommit:
|
|
10
|
+
// Deployment: deepbook-predict-testnet
|
|
11
|
+
// sourceCommit: a928bd2da4b71abf7c4ea6f66abec2763308331e
|
|
12
12
|
//
|
|
13
13
|
// Runtime-dependency-free — every subpath reads a slice of this, so a value import here
|
|
14
14
|
// would pull that module into all of their graphs. The type import below is erased.
|
|
@@ -26,16 +26,16 @@ import type {
|
|
|
26
26
|
|
|
27
27
|
/** Which on-chain deployment the ids below came from. */
|
|
28
28
|
export const TESTNET_DEPLOYMENT: DeploymentInfo = Object.freeze({
|
|
29
|
-
deployment: 'predict-testnet
|
|
29
|
+
deployment: 'deepbook-predict-testnet',
|
|
30
30
|
network: 'testnet',
|
|
31
31
|
chainId: '4c78adac',
|
|
32
|
-
sourceCommit: '
|
|
32
|
+
sourceCommit: 'a928bd2da4b71abf7c4ea6f66abec2763308331e',
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
/** Ids for the shared `account` primitive — the `/account` subpath's slice. */
|
|
36
36
|
export const TESTNET_ACCOUNT: AccountIds = Object.freeze({
|
|
37
|
-
accountPackageId: '
|
|
38
|
-
accountRegistry: '
|
|
37
|
+
accountPackageId: '0x543139156cb90d1a73df33b5dca37d7c8bdce62506c7874ebc854afd319b98f1',
|
|
38
|
+
accountRegistry: '0xb889caefe327cbdea58e529e3b9e10dc93f1e661ddef32824d28527edf8d6385',
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -46,15 +46,15 @@ export const TESTNET_ACCOUNT: AccountIds = Object.freeze({
|
|
|
46
46
|
* the package root for one id.
|
|
47
47
|
*/
|
|
48
48
|
export const TESTNET_SESSIONS: SessionsIds = Object.freeze({
|
|
49
|
-
sessionsPackageId: '
|
|
50
|
-
sessionsConfig: '
|
|
51
|
-
accountPackageId: '
|
|
52
|
-
accountRegistry: '
|
|
49
|
+
sessionsPackageId: '0x10c91d168dc4a04357f9d23795a204092ca46e5b97f8b9ef26fea95664d5bb38',
|
|
50
|
+
sessionsConfig: '0x63cde7c7d846f15c51802ec3d44ba44918658e3155b0d2e0cb26d6fc1b4dadd8',
|
|
51
|
+
accountPackageId: '0x543139156cb90d1a73df33b5dca37d7c8bdce62506c7874ebc854afd319b98f1',
|
|
52
|
+
accountRegistry: '0xb889caefe327cbdea58e529e3b9e10dc93f1e661ddef32824d28527edf8d6385',
|
|
53
53
|
deepbookRegistry: '0x7c256edbda983a2cd6f946655f4bf3f00a41043993781f8674a7046e8c0e11d1',
|
|
54
54
|
deepbookCoreAccountPackageId:
|
|
55
|
-
'
|
|
55
|
+
'0x2dbb8e6a5b9a8ac6201c7aeff6de0c7e7bca5dcd8d6c16538cb1a7447a298071',
|
|
56
56
|
/** Required by every Predict session wrapper — they all take `config: &ProtocolConfig`. */
|
|
57
|
-
protocolConfig: '
|
|
57
|
+
protocolConfig: '0xfeda745dfdef2cd9721c2ff1e1de538d103bc6012469d0eec10ea5de67f636d0',
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -73,25 +73,25 @@ export const TESTNET_UNITS: DeploymentUnits = Object.freeze({
|
|
|
73
73
|
export const TESTNET_PREDICT: PredictIds = Object.freeze({
|
|
74
74
|
network: 'testnet',
|
|
75
75
|
packages: Object.freeze({
|
|
76
|
-
predict: '
|
|
77
|
-
account: '
|
|
78
|
-
propbook: '
|
|
76
|
+
predict: '0x25d075d2de915feda7ab9b8f855afe59cbcd4b2ce96f75324940c810f84da018',
|
|
77
|
+
account: '0x543139156cb90d1a73df33b5dca37d7c8bdce62506c7874ebc854afd319b98f1',
|
|
78
|
+
propbook: '0xa04a43dbbfb123feec96691a22809d8a87e9ac37ae9356079c439750145aa92b',
|
|
79
79
|
}),
|
|
80
80
|
objects: Object.freeze({
|
|
81
|
-
registry: '
|
|
82
|
-
protocolConfig: '
|
|
83
|
-
poolVault: '
|
|
84
|
-
oracleRegistry: '
|
|
85
|
-
accountRegistry: '
|
|
81
|
+
registry: '0xd21fab5444128eb65c5f6299564f583db72ad84d17581a4febe68878127100d5',
|
|
82
|
+
protocolConfig: '0xfeda745dfdef2cd9721c2ff1e1de538d103bc6012469d0eec10ea5de67f636d0',
|
|
83
|
+
poolVault: '0xd6b96a77d5acfd4f4a660cbd1098ed62abf2317e85a01274d1a4eeef19603767',
|
|
84
|
+
oracleRegistry: '0xda71af88a8b9d01b6913937a84c5a63bb4e1015a7a2142185ec9ef73f675615f',
|
|
85
|
+
accountRegistry: '0xb889caefe327cbdea58e529e3b9e10dc93f1e661ddef32824d28527edf8d6385',
|
|
86
86
|
}),
|
|
87
|
-
quoteCoinType: '
|
|
87
|
+
quoteCoinType: '0xc028557a1ed49e42ed091e115aedefd70a442b184c18fbec5c48d5b6c0b8c184::usdc::USDC',
|
|
88
88
|
/**
|
|
89
89
|
* `plp` is the LP share coin type. It is NOT derivable from `packages.predict`: a Move
|
|
90
90
|
* type tag keeps the ORIGINAL package id across an upgrade, while `packages.predict`
|
|
91
91
|
* moves to the latest. They agree only while predict is at v1.
|
|
92
92
|
*/
|
|
93
93
|
coinTypes: Object.freeze({
|
|
94
|
-
plp: '
|
|
94
|
+
plp: '0x25d075d2de915feda7ab9b8f855afe59cbcd4b2ce96f75324940c810f84da018::plp::PLP',
|
|
95
95
|
deep: '0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP',
|
|
96
96
|
}),
|
|
97
97
|
units: TESTNET_UNITS,
|
|
@@ -99,9 +99,9 @@ export const TESTNET_PREDICT: PredictIds = Object.freeze({
|
|
|
99
99
|
BTC: Object.freeze({
|
|
100
100
|
symbol: 'BTC',
|
|
101
101
|
propbookUnderlyingId: 1,
|
|
102
|
-
pythFeed: '
|
|
103
|
-
blockScholesValueStore: '
|
|
104
|
-
blockScholesSviStore: '
|
|
102
|
+
pythFeed: '0x7179188b3a27758c53668a4ec09a81be114dea5ffabcf367f4e720a26db8ee59',
|
|
103
|
+
blockScholesValueStore: '0x77dee47fb870753c740439f436e0c30c00c60f13f171c901125b3d60f89518e5',
|
|
104
|
+
blockScholesSviStore: '0xe8aa80965d201e2cb18359c3aa315e3abc5bbf807a10a59d6e011ef41be5db7a',
|
|
105
105
|
}),
|
|
106
106
|
}),
|
|
107
107
|
});
|
package/src/deployments/types.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface DeploymentInfo {
|
|
|
25
25
|
*
|
|
26
26
|
* Only `positionLotSize` is currently read by the SDK (`PredictClient#assertLot`); the other
|
|
27
27
|
* three are shipped as the deployment's own record of its scales. `units.ts` still hardcodes
|
|
28
|
-
* the
|
|
28
|
+
* the USDC and fixed-point decimals, so do not read this as "the SDK derives its scaling
|
|
29
29
|
* from here" — wiring that up is separate work.
|
|
30
30
|
*/
|
|
31
31
|
export interface DeploymentUnits {
|
package/src/predict/client.ts
CHANGED
|
@@ -135,6 +135,29 @@ export interface CloseOptions {
|
|
|
135
135
|
quantity: number;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
/** Options for `supplyPlp`. */
|
|
139
|
+
export interface PlpSupplyOptions {
|
|
140
|
+
/**
|
|
141
|
+
* Floor on the PLP minted for the whole request, as raw `bigint` shares — PLP is raw
|
|
142
|
+
* everywhere in this SDK. It is a floor on the MARK, not a share count: a flush quoting
|
|
143
|
+
* less does not fill smaller, it declines. Omitted → `0n`, no floor.
|
|
144
|
+
*
|
|
145
|
+
* How a miss is handled is the deployment's `lp_request_limit_flush_attempts`: at the
|
|
146
|
+
* shipped count of one the first flush below the floor cancels and refunds the request.
|
|
147
|
+
*/
|
|
148
|
+
minPlpOut?: bigint;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Options for `withdrawPlp`. */
|
|
152
|
+
export interface PlpWithdrawOptions {
|
|
153
|
+
/**
|
|
154
|
+
* Floor on the USDC paid for the whole request, in USD decimals like every other amount
|
|
155
|
+
* here. A floor on the MARK, not an amount: a flush quoting less declines rather than
|
|
156
|
+
* paying out smaller. Omitted → no floor. Measured after the protocol's withdraw fee.
|
|
157
|
+
*/
|
|
158
|
+
minUsdcOut?: number | string;
|
|
159
|
+
}
|
|
160
|
+
|
|
138
161
|
/** One tradeable market as returned by read.markets(). */
|
|
139
162
|
export interface ActiveMarket {
|
|
140
163
|
id: string;
|
|
@@ -171,7 +194,7 @@ export interface MarketSummary {
|
|
|
171
194
|
|
|
172
195
|
/** Aggregate pool figures. Balances in human units (shares raw); the pending fields
|
|
173
196
|
* are request COUNTS, not amounts — the on-chain getters expose queue lengths, and
|
|
174
|
-
* the escrowed
|
|
197
|
+
* the escrowed USDC/PLP behind them is tracked separately. */
|
|
175
198
|
export interface PoolSummary {
|
|
176
199
|
plpTotalSupply: bigint;
|
|
177
200
|
idleUsdc: number;
|
|
@@ -267,8 +290,9 @@ export function predict<Name extends string = 'predict'>({
|
|
|
267
290
|
* The one object an app constructs. Wraps the config, a client for reads, and
|
|
268
291
|
* a derived-account model so callers pass owner addresses, decimal amounts, and
|
|
269
292
|
* human market coordinates — the facade converts to raw units, resolves markets
|
|
270
|
-
* (cached), and delegates to the internal tx primitives / reads.
|
|
271
|
-
*
|
|
293
|
+
* (cached), and delegates to the internal tx primitives / reads. Each `tx.*` builder
|
|
294
|
+
* returns a finished `Transaction`; callers composing their own PTBs use the generated
|
|
295
|
+
* move-call bindings this subpath exports (`plpMoveCalls`, `expiryMarketMoveCalls`, …).
|
|
272
296
|
*/
|
|
273
297
|
export class PredictClient {
|
|
274
298
|
readonly cfg: PredictConfig;
|
|
@@ -566,7 +590,7 @@ export class PredictClient {
|
|
|
566
590
|
},
|
|
567
591
|
|
|
568
592
|
// Withdraw `amountUsdc` from the account back to `owner`. By default the funds land
|
|
569
|
-
// in the owner's
|
|
593
|
+
// in the owner's USDC *address balance* (the versionless accumulator) via
|
|
570
594
|
// `0x2::coin::send_funds` — no coin-object churn, and they merge into the same
|
|
571
595
|
// balance `deposit` draws from, closing the loop. Pass `{ toCoinObject: true }` to
|
|
572
596
|
// instead receive a discrete `Coin<T>` object (for wallets/explorers that only
|
|
@@ -652,45 +676,52 @@ export class PredictClient {
|
|
|
652
676
|
},
|
|
653
677
|
|
|
654
678
|
// Queue a supply request pulling `amountUsdc` from the account's existing custody
|
|
655
|
-
// balance. `request_supply` auto-settles
|
|
679
|
+
// balance. `request_supply` auto-settles USDC then `account.withdraw`s the payment
|
|
656
680
|
// into queue escrow; the PLP fill is delivered at the next flush, not returned here.
|
|
657
681
|
// Command order is auth → request (auth is a hot potato consumed by this call). The
|
|
658
|
-
// `minPlpOut` slot is the per-request floor on PLP minted at flush —
|
|
659
|
-
// (no floor)
|
|
660
|
-
//
|
|
661
|
-
|
|
682
|
+
// `minPlpOut` slot is the per-request floor on PLP minted at flush — `options.minPlpOut`
|
|
683
|
+
// when given, otherwise 0 (no floor). At the shipped attempt count of one, the first
|
|
684
|
+
// flush whose mark quotes less cancels and refunds the request; three is the
|
|
685
|
+
// configurable maximum, not the default.
|
|
686
|
+
supplyPlp: (
|
|
687
|
+
owner: string,
|
|
688
|
+
amountUsdc: number | string,
|
|
689
|
+
options: PlpSupplyOptions = {},
|
|
690
|
+
): Transaction =>
|
|
662
691
|
txOf(
|
|
663
692
|
requestSupply({
|
|
664
693
|
config: this.#config,
|
|
665
694
|
arguments: {
|
|
666
695
|
wrapper: this.wrapperIdFor(owner),
|
|
667
696
|
amount: usdcToRaw(amountUsdc),
|
|
668
|
-
minPlpOut: 0n,
|
|
697
|
+
minPlpOut: options.minPlpOut ?? 0n,
|
|
669
698
|
},
|
|
670
699
|
}),
|
|
671
700
|
),
|
|
672
701
|
|
|
673
702
|
// Queue a withdraw request pulling `shares` (raw PLP u64) from account custody into
|
|
674
703
|
// queue escrow — the Move parameter is named `amount`, but on `request_withdraw` it
|
|
675
|
-
// counts PLP SHARES, not
|
|
704
|
+
// counts PLP SHARES, not USDC. Auto-settles flush-delivered PLP first; the USDC
|
|
676
705
|
// fill lands on the account at the next flush (no `withdraw_settled` entrypoint).
|
|
677
|
-
// Command order is auth → request. The `
|
|
678
|
-
// on
|
|
679
|
-
//
|
|
680
|
-
|
|
706
|
+
// Command order is auth → request. The `minUsdcOut` slot is the per-request floor
|
|
707
|
+
// on USDC paid at flush — `options.minUsdcOut` when given, otherwise 0 (no floor).
|
|
708
|
+
// At the shipped attempt count of one, the first flush whose mark quotes less
|
|
709
|
+
// cancels and refunds the request; three is the configurable maximum, not the
|
|
710
|
+
// default.
|
|
711
|
+
withdrawPlp: (owner: string, shares: bigint, options: PlpWithdrawOptions = {}): Transaction =>
|
|
681
712
|
txOf(
|
|
682
713
|
requestWithdraw({
|
|
683
714
|
config: this.#config,
|
|
684
715
|
arguments: {
|
|
685
716
|
wrapper: this.wrapperIdFor(owner),
|
|
686
717
|
amount: shares,
|
|
687
|
-
|
|
718
|
+
minUsdcOut: options.minUsdcOut === undefined ? 0n : usdcToRaw(options.minUsdcOut),
|
|
688
719
|
},
|
|
689
720
|
}),
|
|
690
721
|
),
|
|
691
722
|
|
|
692
723
|
// Cancel a still-pending supply request by queue `index`, refunding its escrowed
|
|
693
|
-
//
|
|
724
|
+
// USDC straight back into the requesting account. Command order is auth → cancel.
|
|
694
725
|
cancelSupplyPlp: (owner: string, index: bigint): Transaction =>
|
|
695
726
|
txOf(
|
|
696
727
|
cancelSupplyRequest({
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
// Copyright (c) Mysten Labs, Inc.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
import { MAINNET_CONFIG } from './mainnet.js';
|
|
3
4
|
import { TESTNET_CONFIG } from './testnet.js';
|
|
4
5
|
import type { PredictConfig } from './types.js';
|
|
5
6
|
import type { NetworkArg } from '../../deployments/index.js';
|
|
6
7
|
|
|
7
|
-
export { TESTNET_CONFIG };
|
|
8
|
+
export { TESTNET_CONFIG, MAINNET_CONFIG };
|
|
8
9
|
export type { PredictConfig, PredictPackages, UnderlyingConfig } from './types.js';
|
|
9
10
|
|
|
10
11
|
export function getConfig(network: NetworkArg): PredictConfig {
|
|
11
12
|
if (network === 'testnet') return TESTNET_CONFIG;
|
|
13
|
+
if (network === 'mainnet') return MAINNET_CONFIG;
|
|
12
14
|
throw new Error(
|
|
13
15
|
`@mysten/deepbook-v3/predict: no Predict deployment recorded for network '${network}'. ` +
|
|
14
|
-
'Predict is testnet
|
|
16
|
+
'Predict is recorded for testnet and mainnet; for your own deployment pass `config` to ' +
|
|
17
|
+
'PredictClient ' +
|
|
15
18
|
'or `predict({ config })`.',
|
|
16
19
|
);
|
|
17
20
|
}
|
|
@@ -20,6 +23,8 @@ export function getConfig(network: NetworkArg): PredictConfig {
|
|
|
20
23
|
export {
|
|
21
24
|
getDeployment,
|
|
22
25
|
getUnits,
|
|
26
|
+
MAINNET_DEPLOYMENT,
|
|
27
|
+
MAINNET_UNITS,
|
|
23
28
|
TESTNET_DEPLOYMENT,
|
|
24
29
|
TESTNET_UNITS,
|
|
25
30
|
} from '../../deployments/index.js';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { MAINNET_PREDICT } from '../../deployments/mainnet.js';
|
|
5
|
+
import type { PredictConfig } from './types.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Mainnet deployment constants, read from the shared generated record in
|
|
9
|
+
* `src/deployments/` rather than transcribed here. `/account` and `/sessions` read slices of
|
|
10
|
+
* that same record, so a redeploy (`pnpm sync-deployment`) moves every subpath together and
|
|
11
|
+
* they cannot end up addressing different deployments.
|
|
12
|
+
*
|
|
13
|
+
* The record is generated from the deploy tooling's `deployment.mainnet.json`; see
|
|
14
|
+
* `scripts/sync-deployment.ts`. `getDeployment('mainnet')` names the deployment and the
|
|
15
|
+
* deepbookv3 commit these ids came from.
|
|
16
|
+
*/
|
|
17
|
+
export const MAINNET_CONFIG: PredictConfig = Object.freeze({
|
|
18
|
+
// The record widens `network` to `string` so the published types don't pin a literal;
|
|
19
|
+
// this file is the mainnet config by construction.
|
|
20
|
+
network: 'mainnet',
|
|
21
|
+
packages: MAINNET_PREDICT.packages,
|
|
22
|
+
objects: MAINNET_PREDICT.objects,
|
|
23
|
+
quoteCoinType: MAINNET_PREDICT.quoteCoinType,
|
|
24
|
+
coinTypes: MAINNET_PREDICT.coinTypes,
|
|
25
|
+
units: MAINNET_PREDICT.units,
|
|
26
|
+
underlyings: MAINNET_PREDICT.underlyings,
|
|
27
|
+
});
|