@mysten/deepbook-v3 2.5.0 → 2.6.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 +31 -0
- package/PREDICT.md +160 -12
- 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 +19 -19
- package/dist/contracts/account/account_registry.d.mts.map +1 -1
- 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_predict/admin.d.mts +4 -4
- package/dist/contracts/deepbook_predict/builder_code.d.mts +11 -11
- package/dist/contracts/deepbook_predict/builder_code.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/builder_code_events.d.mts +10 -10
- package/dist/contracts/deepbook_predict/config_events.d.mts +67 -67
- package/dist/contracts/deepbook_predict/config_events.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.d.mts +176 -96
- package/dist/contracts/deepbook_predict/expiry_market.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/expiry_market.mjs +114 -1
- package/dist/contracts/deepbook_predict/expiry_market.mjs.map +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/market_manager.d.mts.map +1 -1
- package/dist/contracts/deepbook_predict/order_events.d.mts +50 -50
- package/dist/contracts/deepbook_predict/pause_cap.d.mts +5 -5
- package/dist/contracts/deepbook_predict/plp.d.mts +72 -72
- package/dist/contracts/deepbook_predict/plp.d.mts.map +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 +53 -53
- package/dist/contracts/deepbook_predict/protocol_config.d.mts +64 -64
- 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 +12 -0
- package/dist/contracts/deepbook_predict/strike_exposure.mjs.map +1 -1
- package/dist/contracts/deepbook_predict/vault_events.d.mts +105 -105
- 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 +48 -23
- package/dist/contracts/deepbook_sessions/sessions.d.mts.map +1 -1
- package/dist/contracts/deepbook_sessions/sessions.mjs +44 -1
- package/dist/contracts/deepbook_sessions/sessions.mjs.map +1 -1
- package/dist/deployments/mainnet.d.mts.map +1 -1
- package/dist/deployments/mainnet.mjs +2 -0
- package/dist/deployments/mainnet.mjs.map +1 -1
- package/dist/deployments/testnet.d.mts.map +1 -1
- package/dist/deployments/testnet.mjs +4 -2
- package/dist/deployments/testnet.mjs.map +1 -1
- package/dist/deployments/types.d.mts +1 -1
- package/dist/predict/client.d.mts +12 -3
- package/dist/predict/client.d.mts.map +1 -1
- package/dist/predict/client.mjs +39 -18
- package/dist/predict/client.mjs.map +1 -1
- package/dist/predict/config/generated.d.mts +3 -2
- package/dist/predict/config/generated.d.mts.map +1 -1
- package/dist/predict/config/generated.mjs +1 -0
- package/dist/predict/config/generated.mjs.map +1 -1
- package/dist/predict/config/types.d.mts +3 -0
- package/dist/predict/config/types.d.mts.map +1 -1
- package/dist/predict/cost.d.mts +353 -0
- package/dist/predict/cost.d.mts.map +1 -0
- package/dist/predict/cost.mjs +555 -0
- package/dist/predict/cost.mjs.map +1 -0
- package/dist/predict/decode.mjs +6 -7
- package/dist/predict/decode.mjs.map +1 -1
- package/dist/predict/index.d.mts +3 -2
- package/dist/predict/index.mjs +2 -1
- package/dist/predict/pricing.mjs +1 -1
- package/dist/predict/reads/positions.mjs +1 -1
- package/dist/predict/reads/positions.mjs.map +1 -1
- package/dist/predict/tx/trade.d.mts.map +1 -1
- package/dist/predict/tx/trade.mjs +18 -2
- package/dist/predict/tx/trade.mjs.map +1 -1
- package/dist/sessions.d.mts +17 -1
- package/dist/sessions.d.mts.map +1 -1
- package/dist/sessions.mjs +22 -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/deepbookAdmin.d.mts +4 -4
- 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/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 +2 -2
- package/src/contracts/deepbook_predict/expiry_market.ts +160 -0
- package/src/contracts/deepbook_predict/strike_exposure.ts +14 -0
- package/src/contracts/deepbook_sessions/sessions.ts +68 -0
- package/src/deployments/mainnet.ts +4 -1
- package/src/deployments/testnet.ts +6 -3
- package/src/deployments/types.ts +4 -2
- package/src/predict/client.ts +80 -27
- package/src/predict/config/generated.ts +4 -2
- package/src/predict/config/types.ts +3 -0
- package/src/predict/cost.ts +1022 -0
- package/src/predict/decode.ts +8 -8
- package/src/predict/index.ts +9 -0
- package/src/predict/reads/positions.ts +1 -1
- package/src/predict/tx/trade.ts +30 -1
- package/src/sessions.ts +37 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MarginProposalParams, PlaceMarginLimitOrderParams, PlaceMarginMarketOrderParams } from "../types/index.mjs";
|
|
2
2
|
import { DeepBookConfig } from "../utils/config.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as _mysten_sui_transactions140 from "@mysten/sui/transactions";
|
|
4
4
|
import { Transaction } from "@mysten/sui/transactions";
|
|
5
5
|
|
|
6
6
|
//#region src/transactions/poolProxy.d.ts
|
|
@@ -20,7 +20,7 @@ declare class PoolProxyContract {
|
|
|
20
20
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a limit order
|
|
21
21
|
* @returns A function that takes a Transaction object
|
|
22
22
|
*/
|
|
23
|
-
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
23
|
+
placeLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions140.TransactionResult;
|
|
24
24
|
/**
|
|
25
25
|
* @description Place a market order. Enforces a post-trade `risk_ratio >=
|
|
26
26
|
* min_borrow_risk_ratio` invariant on the manager (skipped when the manager
|
|
@@ -28,7 +28,7 @@ declare class PoolProxyContract {
|
|
|
28
28
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
29
29
|
* @returns A function that takes a Transaction object
|
|
30
30
|
*/
|
|
31
|
-
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
31
|
+
placeMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions140.TransactionResult;
|
|
32
32
|
/**
|
|
33
33
|
* @description Place a reduce only limit order. Requires the manager to have
|
|
34
34
|
* debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -37,7 +37,7 @@ declare class PoolProxyContract {
|
|
|
37
37
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
38
38
|
* @returns A function that takes a Transaction object
|
|
39
39
|
*/
|
|
40
|
-
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
40
|
+
placeReduceOnlyLimitOrder: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions140.TransactionResult;
|
|
41
41
|
/**
|
|
42
42
|
* @description Place a reduce only market order. Requires the manager to
|
|
43
43
|
* have debt on the relevant side; enforces a monotonic `risk_ratio_after >=
|
|
@@ -46,7 +46,7 @@ declare class PoolProxyContract {
|
|
|
46
46
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
47
47
|
* @returns A function that takes a Transaction object
|
|
48
48
|
*/
|
|
49
|
-
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
49
|
+
placeReduceOnlyMarketOrder: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions140.TransactionResult;
|
|
50
50
|
/**
|
|
51
51
|
* @description Place a market order and repay the loan from the fill proceeds.
|
|
52
52
|
* The taker fill settles into the manager's balance, so the proceeds (plus any
|
|
@@ -58,7 +58,7 @@ declare class PoolProxyContract {
|
|
|
58
58
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a market order
|
|
59
59
|
* @returns A function that takes a Transaction object
|
|
60
60
|
*/
|
|
61
|
-
placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
61
|
+
placeMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions140.TransactionResult;
|
|
62
62
|
/**
|
|
63
63
|
* @description Place a reduce only limit order and repay the loan from the
|
|
64
64
|
* fill proceeds. Requires debt on the relevant side (a bid needs base debt; an
|
|
@@ -68,7 +68,7 @@ declare class PoolProxyContract {
|
|
|
68
68
|
* @param {PlaceMarginLimitOrderParams} params Parameters for placing a reduce only limit order
|
|
69
69
|
* @returns A function that takes a Transaction object
|
|
70
70
|
*/
|
|
71
|
-
placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) =>
|
|
71
|
+
placeReduceOnlyLimitOrderAndRepayLoan: (params: PlaceMarginLimitOrderParams) => (tx: Transaction) => _mysten_sui_transactions140.TransactionResult;
|
|
72
72
|
/**
|
|
73
73
|
* @description Place a reduce only market order and repay the loan from the
|
|
74
74
|
* fill proceeds. Same reduce-only direction guard as
|
|
@@ -78,7 +78,7 @@ declare class PoolProxyContract {
|
|
|
78
78
|
* @param {PlaceMarginMarketOrderParams} params Parameters for placing a reduce only market order
|
|
79
79
|
* @returns A function that takes a Transaction object
|
|
80
80
|
*/
|
|
81
|
-
placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) =>
|
|
81
|
+
placeReduceOnlyMarketOrderAndRepayLoan: (params: PlaceMarginMarketOrderParams) => (tx: Transaction) => _mysten_sui_transactions140.TransactionResult;
|
|
82
82
|
/**
|
|
83
83
|
* @description Modify an existing order
|
|
84
84
|
* @param {string} marginManagerKey The key to identify the MarginManager
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/transactions/poolProxy.ts"],"mappings":";;;;;;;;;cAmBa,iBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAoBuD;;;;;;;EAA3E,eAAA,GAAmB,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,
|
|
1
|
+
{"version":3,"file":"poolProxy.d.mts","names":[],"sources":["../../src/transactions/poolProxy.ts"],"mappings":";;;;;;;;;cAmBa,iBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAoBuD;;;;;;;EAA3E,eAAA,GAAmB,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EA0JC;;;;;;;EArG5E,gBAAA,GAAoB,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAgQnE;;;;;;;;EAjNV,yBAAA,GAA6B,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAsZxC;;;;;;;;EAhW7C,0BAAA,GAA8B,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;;;;;;;;;;;;EAkDvF,4BAAA,GAAgC,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAvJrE;;;;;;;;;EAuMpB,qCAAA,GACE,MAAA,EAAQ,2BAAA,MAAiC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAnG1D;;;;;;;;;EA0JA,sCAAA,GACE,MAAA,EAAQ,4BAAA,MAAkC,EAAA,EAAI,WAAA,KAAW,2BAAA,CAAA,iBAAA;EAzGe;;;;;;;EAuJ1E,WAAA,GACE,gBAAA,UAA0B,OAAA,UAAiB,WAAA,cAAyB,EAAA,EAAI,WAAA;EAhD1E;;;;;;EA4EA,WAAA,GAAe,gBAAA,UAA0B,OAAA,cAAqB,EAAA,EAAI,WAAA;EA5BhE;;;;;;EAqDF,YAAA,GAAgB,gBAAA,UAA0B,QAAA,gBAAwB,EAAA,EAAI,WAAA;EAzB7B;;;;;EAiDzC,eAAA,GAAmB,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAxBiB;;;;;EA+CtE,sBAAA,GAA0B,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAA5D;;;;;;EAwBA,KAAA,GAAS,gBAAA,UAA0B,WAAA,cAAyB,EAAA,EAAI,WAAA;EAAA;;;;;EA0BhE,OAAA,GAAW,gBAAA,cAA8B,EAAA,EAAI,WAAA;EAwB7C;;;;;;EAAA,cAAA,GACE,gBAAA,UAA0B,MAAA,EAAQ,oBAAA,MAA0B,EAAA,EAAI,WAAA;EA+B1D;;;;;;EAAR,IAAA,GAAQ,gBAAA,UAA0B,UAAA,cAAwB,EAAA,EAAI,WAAA;EAwBjB;;;;;EAA7C,WAAA,GAAe,gBAAA,cAA8B,EAAA,EAAI,WAAA;EA+CjD;;;;;;EAvBA,4BAAA,GACE,OAAA,UAAiB,eAAA,cAA6B,EAAA,EAAI,WAAA;;;;;;EAsBpD,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA;AAAA"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@mysten/deepbook-v3",
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "Sui Deepbook SDK",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.6.0",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"wait-on": "^9.1.0"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"@mysten/sui": "^2.31.
|
|
68
|
+
"@mysten/sui": "^2.31.3"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
@@ -923,6 +923,73 @@ export function quoteMintForAccount(options: QuoteMintForAccountOptions) {
|
|
|
923
923
|
),
|
|
924
924
|
});
|
|
925
925
|
}
|
|
926
|
+
export interface QuoteMintExactCostForAccountArguments {
|
|
927
|
+
market: RawTransactionArgument<string>;
|
|
928
|
+
wrapper: RawTransactionArgument<string>;
|
|
929
|
+
config?: RawTransactionArgument<string>;
|
|
930
|
+
pricer: TransactionArgument;
|
|
931
|
+
lowerTick: RawTransactionArgument<number | bigint>;
|
|
932
|
+
higherTick: RawTransactionArgument<number | bigint>;
|
|
933
|
+
maxCost: RawTransactionArgument<number | bigint>;
|
|
934
|
+
minQuantity: RawTransactionArgument<number | bigint>;
|
|
935
|
+
}
|
|
936
|
+
export interface QuoteMintExactCostForAccountOptions {
|
|
937
|
+
package?: string;
|
|
938
|
+
arguments: QuoteMintExactCostForAccountArguments;
|
|
939
|
+
config?: {
|
|
940
|
+
protocolConfig: ConfigValue;
|
|
941
|
+
predictPackageId?: string;
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Quote `mint_exact_cost` for one account: the fill that mint would size for
|
|
946
|
+
* `max_cost`, capped by total account balance including unsettled accumulator
|
|
947
|
+
* funds, with that fill's cost decomposition. Applies the mint's live-mint gates,
|
|
948
|
+
* sizing, `min_quantity` floor, and admission, but does not preflight
|
|
949
|
+
* exposure-index capacity or cash backing. `quantity` is the figure to derive a
|
|
950
|
+
* `min_quantity` slippage floor from. Public for SDK and devInspect pre-trade
|
|
951
|
+
* pricing.
|
|
952
|
+
*/
|
|
953
|
+
export function quoteMintExactCostForAccount(options: QuoteMintExactCostForAccountOptions) {
|
|
954
|
+
const packageAddress =
|
|
955
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
956
|
+
const argumentsTypes = [
|
|
957
|
+
null,
|
|
958
|
+
null,
|
|
959
|
+
null,
|
|
960
|
+
null,
|
|
961
|
+
'u64',
|
|
962
|
+
'u64',
|
|
963
|
+
'u64',
|
|
964
|
+
'u64',
|
|
965
|
+
'0x2::accumulator::AccumulatorRoot',
|
|
966
|
+
'0x2::clock::Clock',
|
|
967
|
+
] satisfies (string | null)[];
|
|
968
|
+
const parameterNames = [
|
|
969
|
+
'market',
|
|
970
|
+
'wrapper',
|
|
971
|
+
'config',
|
|
972
|
+
'pricer',
|
|
973
|
+
'lowerTick',
|
|
974
|
+
'higherTick',
|
|
975
|
+
'maxCost',
|
|
976
|
+
'minQuantity',
|
|
977
|
+
];
|
|
978
|
+
return (tx: Transaction) =>
|
|
979
|
+
tx.moveCall({
|
|
980
|
+
package: packageAddress,
|
|
981
|
+
module: 'expiry_market',
|
|
982
|
+
function: 'quote_mint_exact_cost_for_account',
|
|
983
|
+
arguments: normalizeMoveArguments(
|
|
984
|
+
{
|
|
985
|
+
...options.arguments,
|
|
986
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
987
|
+
},
|
|
988
|
+
argumentsTypes,
|
|
989
|
+
parameterNames,
|
|
990
|
+
),
|
|
991
|
+
});
|
|
992
|
+
}
|
|
926
993
|
export interface QuantityArguments {
|
|
927
994
|
quote: TransactionArgument;
|
|
928
995
|
}
|
|
@@ -1303,6 +1370,99 @@ export function mintExactAmount(options: MintExactAmountOptions) {
|
|
|
1303
1370
|
),
|
|
1304
1371
|
});
|
|
1305
1372
|
}
|
|
1373
|
+
export interface MintExactCostArguments {
|
|
1374
|
+
market: RawTransactionArgument<string>;
|
|
1375
|
+
wrapper: RawTransactionArgument<string>;
|
|
1376
|
+
auth: TransactionArgument;
|
|
1377
|
+
config?: RawTransactionArgument<string>;
|
|
1378
|
+
pricer: TransactionArgument;
|
|
1379
|
+
lowerTick: RawTransactionArgument<number | bigint>;
|
|
1380
|
+
higherTick: RawTransactionArgument<number | bigint>;
|
|
1381
|
+
maxCost: RawTransactionArgument<number | bigint>;
|
|
1382
|
+
minQuantity: RawTransactionArgument<number | bigint>;
|
|
1383
|
+
}
|
|
1384
|
+
export interface MintExactCostOptions {
|
|
1385
|
+
package?: string;
|
|
1386
|
+
arguments: MintExactCostArguments;
|
|
1387
|
+
config?: {
|
|
1388
|
+
protocolConfig: ConfigValue;
|
|
1389
|
+
predictPackageId?: string;
|
|
1390
|
+
};
|
|
1391
|
+
}
|
|
1392
|
+
/**
|
|
1393
|
+
* Mint a lot-rounded position within an all-in `max_cost` budget.
|
|
1394
|
+
*
|
|
1395
|
+
* Unlike `mint_exact_amount`, fees are sized inside the budget: the quantity
|
|
1396
|
+
* search evaluates the all-in withdrawal the mint charges
|
|
1397
|
+
* (`premium + trader-paid fee + builder_fee + EWMA penalty + inventory_impact_charge`)
|
|
1398
|
+
* against the fee-incentive, congestion, and book state at execution, so the debit
|
|
1399
|
+
* never exceeds `max_cost`. `max_cost` is first capped to the account's available
|
|
1400
|
+
* USDC after settlement, so `std::u64::max_value!()` sizes against the whole
|
|
1401
|
+
* balance.
|
|
1402
|
+
*
|
|
1403
|
+
* The budget search finds the largest fitting quantity. If that quantity costs
|
|
1404
|
+
* more than its maximum payout, a conservative search tries a smaller fill;
|
|
1405
|
+
* rounding can make that fallback miss a larger admissible fill. Only when the
|
|
1406
|
+
* budget is the limiting constraint is the remainder less than the incremental
|
|
1407
|
+
* all-in cost of one more lot. Payout-limited fills and lot-cap saturation can
|
|
1408
|
+
* leave more. Insufficient expiry cash backing aborts the mint; sizing does not
|
|
1409
|
+
* shrink the fill to available backing, and the quote does not preflight it.
|
|
1410
|
+
*
|
|
1411
|
+
* `min_quantity` is this entrypoint's slippage guard. The budget is fixed, so
|
|
1412
|
+
* every adverse move between building the transaction and executing it — the
|
|
1413
|
+
* price, the congestion surcharge, the sponsor subsidy, the inventory-impact
|
|
1414
|
+
* charge — shows up as fewer contracts, and a fill below `min_quantity` aborts
|
|
1415
|
+
* `EMintQuantityBelowMin`. It bounds the all-in price per contract at
|
|
1416
|
+
* `max_cost / min_quantity`, which is why the shape carries no separate
|
|
1417
|
+
* probability cap; passing `0` accepts any fill the budget buys. A budget too
|
|
1418
|
+
* small to admit `constants::min_premium` aborts `EPremiumBelowMinimum` rather
|
|
1419
|
+
* than minting nothing, and zero is such a budget: unlike `mint_exact_amount`
|
|
1420
|
+
* there is no `max_cost` cap to require, because here the budget IS the sizing
|
|
1421
|
+
* input. Other requirements match `mint_exact_quantity`. Returns the minted order
|
|
1422
|
+
* ID.
|
|
1423
|
+
*/
|
|
1424
|
+
export function mintExactCost(options: MintExactCostOptions) {
|
|
1425
|
+
const packageAddress =
|
|
1426
|
+
options.package ?? options.config?.predictPackageId ?? '@local-pkg/deepbook_predict';
|
|
1427
|
+
const argumentsTypes = [
|
|
1428
|
+
null,
|
|
1429
|
+
null,
|
|
1430
|
+
null,
|
|
1431
|
+
null,
|
|
1432
|
+
null,
|
|
1433
|
+
'u64',
|
|
1434
|
+
'u64',
|
|
1435
|
+
'u64',
|
|
1436
|
+
'u64',
|
|
1437
|
+
'0x2::accumulator::AccumulatorRoot',
|
|
1438
|
+
'0x2::clock::Clock',
|
|
1439
|
+
] satisfies (string | null)[];
|
|
1440
|
+
const parameterNames = [
|
|
1441
|
+
'market',
|
|
1442
|
+
'wrapper',
|
|
1443
|
+
'auth',
|
|
1444
|
+
'config',
|
|
1445
|
+
'pricer',
|
|
1446
|
+
'lowerTick',
|
|
1447
|
+
'higherTick',
|
|
1448
|
+
'maxCost',
|
|
1449
|
+
'minQuantity',
|
|
1450
|
+
];
|
|
1451
|
+
return (tx: Transaction) =>
|
|
1452
|
+
tx.moveCall({
|
|
1453
|
+
package: packageAddress,
|
|
1454
|
+
module: 'expiry_market',
|
|
1455
|
+
function: 'mint_exact_cost',
|
|
1456
|
+
arguments: normalizeMoveArguments(
|
|
1457
|
+
{
|
|
1458
|
+
...options.arguments,
|
|
1459
|
+
config: options.arguments?.config ?? options.config?.protocolConfig,
|
|
1460
|
+
},
|
|
1461
|
+
argumentsTypes,
|
|
1462
|
+
parameterNames,
|
|
1463
|
+
),
|
|
1464
|
+
});
|
|
1465
|
+
}
|
|
1306
1466
|
export interface RedeemLiveArguments {
|
|
1307
1467
|
market: RawTransactionArgument<string>;
|
|
1308
1468
|
wrapper: RawTransactionArgument<string>;
|
|
@@ -51,6 +51,20 @@ export const StrikeExposure = new MoveStruct({
|
|
|
51
51
|
payout: strike_payout_tree.StrikePayoutTree,
|
|
52
52
|
},
|
|
53
53
|
});
|
|
54
|
+
export const MintRange = new MoveStruct({
|
|
55
|
+
name: `${$moduleName}::MintRange`,
|
|
56
|
+
fields: {
|
|
57
|
+
expiry_market_id: bcs.Address,
|
|
58
|
+
lower_tick: U64,
|
|
59
|
+
higher_tick: U64,
|
|
60
|
+
price: pricing.RangePrice,
|
|
61
|
+
/** Pre-mint point-max and total live payout. */
|
|
62
|
+
max_payout: U64,
|
|
63
|
+
total_payout: U64,
|
|
64
|
+
/** Pre-mint payout peak inside `(lower_tick, higher_tick]`. */
|
|
65
|
+
range_max_payout: U64,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
54
68
|
export const MintTerms = new MoveStruct({
|
|
55
69
|
name: `${$moduleName}::MintTerms`,
|
|
56
70
|
fields: {
|
|
@@ -543,6 +543,74 @@ export function mintExactAmount(options: MintExactAmountOptions) {
|
|
|
543
543
|
),
|
|
544
544
|
});
|
|
545
545
|
}
|
|
546
|
+
export interface MintExactCostArguments {
|
|
547
|
+
market: RawTransactionArgument<string>;
|
|
548
|
+
accountRegistry: RawTransactionArgument<string>;
|
|
549
|
+
wrapper: RawTransactionArgument<string>;
|
|
550
|
+
sessionsConfig?: RawTransactionArgument<string>;
|
|
551
|
+
config: RawTransactionArgument<string>;
|
|
552
|
+
pricer: TransactionArgument;
|
|
553
|
+
lowerTick: RawTransactionArgument<number | bigint>;
|
|
554
|
+
higherTick: RawTransactionArgument<number | bigint>;
|
|
555
|
+
maxCost: RawTransactionArgument<number | bigint>;
|
|
556
|
+
minQuantity: RawTransactionArgument<number | bigint>;
|
|
557
|
+
}
|
|
558
|
+
export interface MintExactCostOptions {
|
|
559
|
+
package?: string;
|
|
560
|
+
arguments: MintExactCostArguments;
|
|
561
|
+
config?: {
|
|
562
|
+
sessionsConfig: ConfigValue;
|
|
563
|
+
sessionsPackageId?: string;
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Mint a Predict position sized to an all-in cost for an Account with an active
|
|
568
|
+
* session.
|
|
569
|
+
*/
|
|
570
|
+
export function mintExactCost(options: MintExactCostOptions) {
|
|
571
|
+
const packageAddress =
|
|
572
|
+
options.package ?? options.config?.sessionsPackageId ?? '@local-pkg/deepbook_sessions';
|
|
573
|
+
const argumentsTypes = [
|
|
574
|
+
null,
|
|
575
|
+
null,
|
|
576
|
+
null,
|
|
577
|
+
null,
|
|
578
|
+
null,
|
|
579
|
+
null,
|
|
580
|
+
'u64',
|
|
581
|
+
'u64',
|
|
582
|
+
'u64',
|
|
583
|
+
'u64',
|
|
584
|
+
'0x2::accumulator::AccumulatorRoot',
|
|
585
|
+
'0x2::clock::Clock',
|
|
586
|
+
] satisfies (string | null)[];
|
|
587
|
+
const parameterNames = [
|
|
588
|
+
'market',
|
|
589
|
+
'accountRegistry',
|
|
590
|
+
'wrapper',
|
|
591
|
+
'sessionsConfig',
|
|
592
|
+
'config',
|
|
593
|
+
'pricer',
|
|
594
|
+
'lowerTick',
|
|
595
|
+
'higherTick',
|
|
596
|
+
'maxCost',
|
|
597
|
+
'minQuantity',
|
|
598
|
+
];
|
|
599
|
+
return (tx: Transaction) =>
|
|
600
|
+
tx.moveCall({
|
|
601
|
+
package: packageAddress,
|
|
602
|
+
module: 'sessions',
|
|
603
|
+
function: 'mint_exact_cost',
|
|
604
|
+
arguments: normalizeMoveArguments(
|
|
605
|
+
{
|
|
606
|
+
...options.arguments,
|
|
607
|
+
sessionsConfig: options.arguments?.sessionsConfig ?? options.config?.sessionsConfig,
|
|
608
|
+
},
|
|
609
|
+
argumentsTypes,
|
|
610
|
+
parameterNames,
|
|
611
|
+
),
|
|
612
|
+
});
|
|
613
|
+
}
|
|
546
614
|
export interface RedeemLiveArguments {
|
|
547
615
|
market: RawTransactionArgument<string>;
|
|
548
616
|
accountRegistry: RawTransactionArgument<string>;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
// GENERATED by `pnpm sync-deployment` from the deploy tooling's own manifest
|
|
5
|
-
// (`packages/predict/deployment/deployment.mainnet.json`)
|
|
5
|
+
// (`packages/predict/deployment/deployment.mainnet.json`) and the Predict/Sessions
|
|
6
|
+
// `Published.toml` records for current call targets and original type IDs. Do not hand-edit:
|
|
6
7
|
// the next regeneration overwrites it, and a hand-patched id is exactly the drift this
|
|
7
8
|
// file exists to prevent. To move to a new deployment, check the sibling deepbookv3
|
|
8
9
|
// checkout out to the new anchor and re-run the script.
|
|
@@ -47,6 +48,7 @@ export const MAINNET_ACCOUNT: AccountIds = Object.freeze({
|
|
|
47
48
|
*/
|
|
48
49
|
export const MAINNET_SESSIONS: SessionsIds = Object.freeze({
|
|
49
50
|
sessionsPackageId: '0x9a068beffa019ae756f4a6d2611e9899d3c6dd888812dd9eca87535d2ac55e2a',
|
|
51
|
+
sessionsPackageIdV1: '0x9a068beffa019ae756f4a6d2611e9899d3c6dd888812dd9eca87535d2ac55e2a',
|
|
50
52
|
sessionsConfig: '0xb2fba483748aac7508676020d4e691d68239b66f8bf7c5e7634dd1a76a329317',
|
|
51
53
|
accountPackageId: '0x4e1dd01465713c9d832313fed5f45c222a4d5c62a533d6da96764c8b2a245d58',
|
|
52
54
|
accountRegistry: '0x8c52c6f5b2374e33f4a726d9c32337b1aee3a71410d41c18faa91d938d66e4bc',
|
|
@@ -74,6 +76,7 @@ export const MAINNET_PREDICT: PredictIds = Object.freeze({
|
|
|
74
76
|
network: 'mainnet',
|
|
75
77
|
packages: Object.freeze({
|
|
76
78
|
predict: '0x89aea622e7bb3bdd598bde87dde40ee31c9eed4971b9546e23ec83de3c48bbba',
|
|
79
|
+
predictV1: '0x89aea622e7bb3bdd598bde87dde40ee31c9eed4971b9546e23ec83de3c48bbba',
|
|
77
80
|
account: '0x4e1dd01465713c9d832313fed5f45c222a4d5c62a533d6da96764c8b2a245d58',
|
|
78
81
|
propbook: '0xa6c8f32015b5b41d34ee09995a2e9d7a21cdecf0e1910a50b264fd252cd33831',
|
|
79
82
|
}),
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
// GENERATED by `pnpm sync-deployment` from the deploy tooling's own manifest
|
|
5
|
-
// (`packages/predict/deployment/deployment.testnet.json`)
|
|
5
|
+
// (`packages/predict/deployment/deployment.testnet.json`) and the Predict/Sessions
|
|
6
|
+
// `Published.toml` records for current call targets and original type IDs. Do not hand-edit:
|
|
6
7
|
// the next regeneration overwrites it, and a hand-patched id is exactly the drift this
|
|
7
8
|
// file exists to prevent. To move to a new deployment, check the sibling deepbookv3
|
|
8
9
|
// checkout out to the new anchor and re-run the script.
|
|
@@ -46,7 +47,8 @@ export const TESTNET_ACCOUNT: AccountIds = Object.freeze({
|
|
|
46
47
|
* the package root for one id.
|
|
47
48
|
*/
|
|
48
49
|
export const TESTNET_SESSIONS: SessionsIds = Object.freeze({
|
|
49
|
-
sessionsPackageId: '
|
|
50
|
+
sessionsPackageId: '0xe9daa1e3f98659f45f0e589c0367c7c13877af9a6a1bf1eda40e33e944816b40',
|
|
51
|
+
sessionsPackageIdV1: '0x1908eee49d7a08d74a537d7f23766b363a145517fe0d3e0d85635d1682831ffd',
|
|
50
52
|
sessionsConfig: '0xc096b97289821b27badfdf758d614bbbfa386f93d3faa409ecc1fcc6075d1186',
|
|
51
53
|
accountPackageId: '0x1e57d6554b99e4ca68330322c3e5c409ba1b681642726b603bf1be92c1840ca9',
|
|
52
54
|
accountRegistry: '0x511e11f7f5d5c1043d795180657603d59e06e90fbfcafd3f90c67ff0836bbd0c',
|
|
@@ -73,7 +75,8 @@ export const TESTNET_UNITS: DeploymentUnits = Object.freeze({
|
|
|
73
75
|
export const TESTNET_PREDICT: PredictIds = Object.freeze({
|
|
74
76
|
network: 'testnet',
|
|
75
77
|
packages: Object.freeze({
|
|
76
|
-
predict: '
|
|
78
|
+
predict: '0x30a03c33eab1e79e0f891540dc00d4e213101b1efb6890f2232e77e36ddd25ce',
|
|
79
|
+
predictV1: '0x59d71119e990573a738dd3ff9c4c7d28d6893af69c87c1a7f3a2e90e280ce2f4',
|
|
77
80
|
account: '0x1e57d6554b99e4ca68330322c3e5c409ba1b681642726b603bf1be92c1840ca9',
|
|
78
81
|
propbook: '0xa83f9d7651de09672a40cea371c387bf954e0f3092947670d71428d4fbc9edd9',
|
|
79
82
|
}),
|
package/src/deployments/types.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface DeploymentInfo {
|
|
|
16
16
|
deployment: string;
|
|
17
17
|
network: string;
|
|
18
18
|
chainId: string;
|
|
19
|
-
/** The
|
|
19
|
+
/** The initial deployment's source commit; later package IDs come from Published.toml. */
|
|
20
20
|
sourceCommit: string;
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -45,6 +45,8 @@ export interface AccountIds {
|
|
|
45
45
|
/** Ids for time-limited sessions, including the spot- and Predict-only extras. */
|
|
46
46
|
export interface SessionsIds extends AccountIds {
|
|
47
47
|
sessionsPackageId: string;
|
|
48
|
+
/** Original package ID for existing structs and dynamic-field keys. */
|
|
49
|
+
sessionsPackageIdV1: string;
|
|
48
50
|
sessionsConfig: string;
|
|
49
51
|
/** Spot wrappers only. */
|
|
50
52
|
deepbookRegistry: string;
|
|
@@ -66,7 +68,7 @@ export interface UnderlyingIds {
|
|
|
66
68
|
/** Ids for DeepBook Predict. */
|
|
67
69
|
export interface PredictIds {
|
|
68
70
|
network: string;
|
|
69
|
-
packages: { predict: string; account: string; propbook: string };
|
|
71
|
+
packages: { predict: string; predictV1: string; account: string; propbook: string };
|
|
70
72
|
objects: {
|
|
71
73
|
registry: string;
|
|
72
74
|
protocolConfig: string;
|
package/src/predict/client.ts
CHANGED
|
@@ -55,7 +55,13 @@ import {
|
|
|
55
55
|
|
|
56
56
|
import { accountContract, deriveAccountWrapperIdFrom } from './tx/common.js';
|
|
57
57
|
import type { MarketFeeds } from './tx/trade.js';
|
|
58
|
-
import {
|
|
58
|
+
import {
|
|
59
|
+
mintExactAmount,
|
|
60
|
+
mintExactCost,
|
|
61
|
+
mintExactQuantity,
|
|
62
|
+
redeemLive,
|
|
63
|
+
redeemSettled,
|
|
64
|
+
} from './tx/trade.js';
|
|
59
65
|
import {
|
|
60
66
|
priceToRaw,
|
|
61
67
|
probabilityToRaw,
|
|
@@ -128,6 +134,14 @@ export interface MintAmountOptions {
|
|
|
128
134
|
maxCost?: number;
|
|
129
135
|
}
|
|
130
136
|
|
|
137
|
+
/** Options for `mintCost`: all-in budget. Requires Predict v2 (currently Testnet only). */
|
|
138
|
+
export interface MintCostOptions {
|
|
139
|
+
/** All-in USDC budget; the chain also caps it at the account balance. */
|
|
140
|
+
spend: number;
|
|
141
|
+
/** Minimum payout received. Zero disables this slippage floor. */
|
|
142
|
+
minQuantity: number;
|
|
143
|
+
}
|
|
144
|
+
|
|
131
145
|
/** Options for `redeem`: which order and how much to close. `claimSettled` takes only
|
|
132
146
|
* `orderId` — a settled claim closes the order in full. */
|
|
133
147
|
export interface CloseOptions {
|
|
@@ -499,6 +513,58 @@ export class PredictClient {
|
|
|
499
513
|
);
|
|
500
514
|
}
|
|
501
515
|
|
|
516
|
+
async #buildMintCost(
|
|
517
|
+
owner: string,
|
|
518
|
+
m: MarketDescriptor,
|
|
519
|
+
opts: MintCostOptions,
|
|
520
|
+
): Promise<Transaction> {
|
|
521
|
+
const feeds = this.#feeds(m.underlying);
|
|
522
|
+
const maxCostRaw = usdcToRaw(opts.spend);
|
|
523
|
+
const minQuantityRaw = usdcToRaw(opts.minQuantity);
|
|
524
|
+
const { id, state } = await this.#resolveMarket(m);
|
|
525
|
+
const { lowerTick, higherTick } = await this.#strikeTicks(m, id, state);
|
|
526
|
+
return txOf(
|
|
527
|
+
mintExactCost(this.#config, {
|
|
528
|
+
expiryMarketId: id,
|
|
529
|
+
wrapperId: this.wrapperIdFor(owner),
|
|
530
|
+
lowerTick,
|
|
531
|
+
higherTick,
|
|
532
|
+
maxCostRaw,
|
|
533
|
+
minQuantityRaw,
|
|
534
|
+
...feeds,
|
|
535
|
+
}),
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
async #quoteMintTransaction(owner: string, tx: Transaction): Promise<MintQuote> {
|
|
540
|
+
const events = await simulateWithEvents(this.#client, tx, owner);
|
|
541
|
+
const r = exactlyOne(decodeMints(this.cfg, { events }), 'OrderMinted');
|
|
542
|
+
// Mirrors the deployed `compute_mint_quote`'s all_in_cost exactly:
|
|
543
|
+
// premium + (trading − subsidy) + builder + penalty + inventory-impact.
|
|
544
|
+
// `referral_fee` is deliberately NOT added — it is a portion OF the
|
|
545
|
+
// trader-paid trading fee and congestion surcharge, not an extra debit.
|
|
546
|
+
const costRaw =
|
|
547
|
+
r.raw.premium +
|
|
548
|
+
(r.raw.tradingFee - r.raw.feeIncentiveSubsidy) +
|
|
549
|
+
r.raw.builderFee +
|
|
550
|
+
r.raw.penaltyFee +
|
|
551
|
+
r.raw.inventoryImpactCharge;
|
|
552
|
+
return {
|
|
553
|
+
entryProbability: r.entryProbability,
|
|
554
|
+
premium: r.premium,
|
|
555
|
+
fees: r.fees,
|
|
556
|
+
cost: rawToUsdc(costRaw),
|
|
557
|
+
quantity: r.quantity,
|
|
558
|
+
raw: {
|
|
559
|
+
premium: r.raw.premium,
|
|
560
|
+
cost: costRaw,
|
|
561
|
+
quantity: r.raw.quantity,
|
|
562
|
+
entryProbability: r.raw.entryProbability,
|
|
563
|
+
},
|
|
564
|
+
feesExact: true,
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
|
|
502
568
|
// Shared construction for tx.redeem and read.quoteRedeem.
|
|
503
569
|
async #buildRedeem(owner: string, m: MarketDescriptor, opts: CloseOptions): Promise<Transaction> {
|
|
504
570
|
const feeds = this.#feeds(m.underlying);
|
|
@@ -627,6 +693,10 @@ export class PredictClient {
|
|
|
627
693
|
mint: (owner: string, m: MarketDescriptor, opts: MintOptions): Promise<Transaction> =>
|
|
628
694
|
this.#buildMint(owner, m, opts),
|
|
629
695
|
|
|
696
|
+
/** V2 all-in budget mint; use minQuantity to protect the fill against slippage. */
|
|
697
|
+
mintCost: (owner: string, m: MarketDescriptor, opts: MintCostOptions): Promise<Transaction> =>
|
|
698
|
+
this.#buildMintCost(owner, m, opts),
|
|
699
|
+
|
|
630
700
|
mintAmount: async (
|
|
631
701
|
owner: string,
|
|
632
702
|
m: MarketDescriptor,
|
|
@@ -846,34 +916,17 @@ export class PredictClient {
|
|
|
846
916
|
opts: Pick<MintOptions, 'quantity'>,
|
|
847
917
|
): Promise<MintQuote> => {
|
|
848
918
|
const tx = await this.#buildMint(owner, m, opts);
|
|
849
|
-
|
|
850
|
-
const r = exactlyOne(decodeMints(this.cfg, { events }), 'OrderMinted');
|
|
851
|
-
// Mirrors the deployed `compute_mint_quote`'s all_in_cost exactly:
|
|
852
|
-
// premium + (trading − subsidy) + builder + penalty + inventory-impact.
|
|
853
|
-
// `referral_fee` is deliberately NOT added — it is a portion OF the
|
|
854
|
-
// trader-paid trading fee and congestion surcharge, not an extra debit.
|
|
855
|
-
const costRaw =
|
|
856
|
-
r.raw.premium +
|
|
857
|
-
(r.raw.tradingFee - r.raw.feeIncentiveSubsidy) +
|
|
858
|
-
r.raw.builderFee +
|
|
859
|
-
r.raw.penaltyFee +
|
|
860
|
-
r.raw.inventoryImpactCharge;
|
|
861
|
-
return {
|
|
862
|
-
entryProbability: r.entryProbability,
|
|
863
|
-
premium: r.premium,
|
|
864
|
-
fees: r.fees,
|
|
865
|
-
cost: rawToUsdc(costRaw),
|
|
866
|
-
quantity: r.quantity,
|
|
867
|
-
raw: {
|
|
868
|
-
premium: r.raw.premium,
|
|
869
|
-
cost: costRaw,
|
|
870
|
-
quantity: r.raw.quantity,
|
|
871
|
-
entryProbability: r.raw.entryProbability,
|
|
872
|
-
},
|
|
873
|
-
feesExact: true,
|
|
874
|
-
};
|
|
919
|
+
return this.#quoteMintTransaction(owner, tx);
|
|
875
920
|
},
|
|
876
921
|
|
|
922
|
+
/** Simulate the v2 all-in budget mint against current account and market state. */
|
|
923
|
+
quoteMintCost: async (
|
|
924
|
+
owner: string,
|
|
925
|
+
m: MarketDescriptor,
|
|
926
|
+
opts: MintCostOptions,
|
|
927
|
+
): Promise<MintQuote> =>
|
|
928
|
+
this.#quoteMintTransaction(owner, await this.#buildMintCost(owner, m, opts)),
|
|
929
|
+
|
|
877
930
|
// Exact pre-close quote: dry-runs the caller's own redeem and decodes
|
|
878
931
|
// the receipt — the informed close against the floor-less deployed redeem.
|
|
879
932
|
quoteRedeem: async (
|
|
@@ -14,14 +14,15 @@ import type { PredictConfig } from './types.js';
|
|
|
14
14
|
* wrong object.
|
|
15
15
|
*
|
|
16
16
|
* `predictPackageId` is narrowed to `string` because codegen types package ids as optional, while
|
|
17
|
-
* this projection always supplies one
|
|
18
|
-
*
|
|
17
|
+
* this projection always supplies one. `predictPackageIdV1` separately supplies the original
|
|
18
|
+
* identity for existing struct tags and dynamic-field keys. The two account ids restate a narrowing
|
|
19
19
|
* `AccountConfig` already applies, so they are redundant today; they are kept so this projection
|
|
20
20
|
* still compiles to plain ids if that package ever widens them back.
|
|
21
21
|
*/
|
|
22
22
|
export type GeneratedConfig = DeepbookPredictConfig &
|
|
23
23
|
AccountConfig & {
|
|
24
24
|
predictPackageId: string;
|
|
25
|
+
predictPackageIdV1: string;
|
|
25
26
|
accountPackageId: string;
|
|
26
27
|
accountRegistry: string;
|
|
27
28
|
};
|
|
@@ -29,6 +30,7 @@ export type GeneratedConfig = DeepbookPredictConfig &
|
|
|
29
30
|
export function toGeneratedConfig(cfg: PredictConfig): GeneratedConfig {
|
|
30
31
|
return {
|
|
31
32
|
predictPackageId: cfg.packages.predict,
|
|
33
|
+
predictPackageIdV1: cfg.packages.predictV1 ?? cfg.packages.predict,
|
|
32
34
|
accountPackageId: cfg.packages.account,
|
|
33
35
|
protocolConfig: cfg.objects.protocolConfig,
|
|
34
36
|
poolVault: cfg.objects.poolVault,
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
/** The three published Move packages a Predict deployment spans. */
|
|
4
4
|
export interface PredictPackages {
|
|
5
|
+
/** Latest published package ID, used for Move calls. */
|
|
5
6
|
predict: string;
|
|
7
|
+
/** Original ID for v1 structs/events. Omit only for an unupgraded custom deployment. */
|
|
8
|
+
predictV1?: string;
|
|
6
9
|
account: string;
|
|
7
10
|
propbook: string;
|
|
8
11
|
}
|