@mysten/deepbook-v3 1.3.6 → 1.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/dist/contracts/deepbook/account.d.mts +18 -18
  3. package/dist/contracts/deepbook/balances.d.mts +4 -4
  4. package/dist/contracts/deepbook/balances.d.mts.map +1 -1
  5. package/dist/contracts/deepbook/deep_price.d.mts +3 -3
  6. package/dist/contracts/deepbook/order.d.mts +12 -12
  7. package/dist/transactions/deepbookAdmin.d.mts +29 -0
  8. package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
  9. package/dist/transactions/deepbookAdmin.mjs +34 -2
  10. package/dist/transactions/deepbookAdmin.mjs.map +1 -1
  11. package/dist/transactions/marginAdmin.d.mts +38 -7
  12. package/dist/transactions/marginAdmin.d.mts.map +1 -1
  13. package/dist/transactions/marginAdmin.mjs +48 -0
  14. package/dist/transactions/marginAdmin.mjs.map +1 -1
  15. package/dist/transactions/marginLiquidations.d.mts +3 -3
  16. package/dist/transactions/marginMaintainer.d.mts +5 -5
  17. package/dist/transactions/marginMaintainer.mjs +4 -4
  18. package/dist/transactions/marginMaintainer.mjs.map +1 -1
  19. package/dist/transactions/marginManager.d.mts +116 -23
  20. package/dist/transactions/marginManager.d.mts.map +1 -1
  21. package/dist/transactions/marginManager.mjs +133 -1
  22. package/dist/transactions/marginManager.mjs.map +1 -1
  23. package/dist/transactions/marginPool.d.mts +18 -18
  24. package/dist/transactions/marginRegistry.d.mts +15 -15
  25. package/dist/transactions/marginRegistry.d.mts.map +1 -1
  26. package/dist/transactions/marginTPSL.d.mts +14 -11
  27. package/dist/transactions/marginTPSL.d.mts.map +1 -1
  28. package/dist/transactions/marginTPSL.mjs +5 -1
  29. package/dist/transactions/marginTPSL.mjs.map +1 -1
  30. package/dist/transactions/poolProxy.d.mts +19 -9
  31. package/dist/transactions/poolProxy.d.mts.map +1 -1
  32. package/dist/transactions/poolProxy.mjs +31 -21
  33. package/dist/transactions/poolProxy.mjs.map +1 -1
  34. package/dist/types/index.d.mts +1 -1
  35. package/dist/types/index.mjs.map +1 -1
  36. package/dist/utils/config.d.mts +1 -0
  37. package/dist/utils/config.d.mts.map +1 -1
  38. package/dist/utils/config.mjs +3 -0
  39. package/dist/utils/config.mjs.map +1 -1
  40. package/dist/utils/constants.d.mts +3 -0
  41. package/dist/utils/constants.d.mts.map +1 -1
  42. package/dist/utils/constants.mjs +4 -2
  43. package/dist/utils/constants.mjs.map +1 -1
  44. package/package.json +2 -2
  45. package/src/transactions/deepbookAdmin.ts +64 -2
  46. package/src/transactions/marginAdmin.ts +79 -0
  47. package/src/transactions/marginMaintainer.ts +4 -4
  48. package/src/transactions/marginManager.ts +244 -1
  49. package/src/transactions/marginTPSL.ts +10 -3
  50. package/src/transactions/poolProxy.ts +45 -21
  51. package/src/types/index.ts +1 -1
  52. package/src/utils/config.ts +4 -0
  53. package/src/utils/constants.ts +5 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @mysten/deepbook-v3
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e68bd36: Align margin SDK with `deepbook_margin` v5 on-chain source:
8
+ - Switch `pool_proxy` order placement builders (`placeLimitOrder`, `placeMarketOrder`,
9
+ `placeReduceOnlyLimitOrder`, `placeReduceOnlyMarketOrder`) to the `_v2` Move entries. The v1
10
+ entries are deprecated in the v5 package and abort with `EDeprecatedUseV2`. The v2 variants take
11
+ additional `base_margin_pool`, `quote_margin_pool`, `base_oracle`, and `quote_oracle` arguments
12
+ so the chain can enforce a post-trade `risk_ratio` invariant (borrow-floor for normal orders,
13
+ monotonic improvement for reduce-only).
14
+ - The reduce-only v2 entries dropped the `DebtAsset` generic and the explicit
15
+ `MarginPool<DebtAsset>` parameter; the package now dispatches on
16
+ `margin_manager.has_base_debt()` to pick the typed pool from the
17
+ `(base_margin_pool, quote_margin_pool)` pair. The SDK builders no longer take a debt-side margin
18
+ pool or third type argument.
19
+ - Switch `executeConditionalOrders` to `margin_manager::execute_conditional_orders_v2`, which adds
20
+ `base_margin_pool`/`quote_margin_pool` arguments and enforces the same post-fill solvency check.
21
+ - Fix `claimRebate` to target the actual Move entry name `pool_proxy::claim_rebates`. The previous
22
+ target did not exist on-chain.
23
+ - Rename `MarginPoolConfigParams.referralSpread` to `protocolSpread`. The Move field was renamed
24
+ upstream in the `protocol_config` module; the old SDK name was positionally correct but
25
+ misleading.
26
+ - Add `registerMarginManager` and `unregisterMarginManager` builders.
27
+ - Add read-only margin_manager builders exposed in newer source: `balanceManagerId`,
28
+ `getBalanceManagerReferralId`, `accountExists`, `account`, `accountOpenOrders`,
29
+ `getAccountOrderDetails`, `lockedBalance`, `canPlaceLimitOrder`, `canPlaceMarketOrder`.
30
+ - Add `MarginAdminContract.setPriceTolerance`, `setMaxPriceAge`, and `setMaxOrderTtl` builders for
31
+ the per-pool oracle and order-TTL admin entries on `margin_registry`. The `setMaxOrderTtl` entry
32
+ configures the per-pool `max_order_ttl_ms` cap that `pool_proxy::place_limit_order_v2` and
33
+ `place_reduce_only_limit_order_v2` use to clamp `expire_timestamp`.
34
+ - Add `DeepBookAdminContract.mintCorePauseCap`, `revokeCorePauseCap`,
35
+ `disableVersionWithCorePauseCap`, and `corePauseCaps` builders for the new
36
+ `DeepbookCorePauseCap` emergency-pause flow in the core spot `registry`. These mirror the
37
+ existing margin-side pause-cap builders.
38
+ - Bump mainnet `MARGIN_PACKAGE_ID` to
39
+ `0x124bb3d8105d6d301c0d40feaa54d65df6b301e4d8ddd5eb8475b0f8a18cff2e` to track the latest margin
40
+ package upgrade on mainnet.
41
+ - Bump mainnet `DEEPBOOK_PACKAGE_ID` to
42
+ `0x0e735f8c93a95722efd73521aca7a7652c0bb71ed1daf41b26dfd7d1ff71f748` to track the latest core
43
+ deepbook package upgrade on mainnet.
44
+
3
45
  ## 1.3.6
4
46
 
5
47
  ### Patch Changes
@@ -1,35 +1,35 @@
1
1
  import { MoveStruct } from "../utils/index.mjs";
2
- import * as _mysten_sui_bcs0 from "@mysten/sui/bcs";
2
+ import * as _mysten_sui_bcs2 from "@mysten/sui/bcs";
3
3
  import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
4
4
 
5
5
  //#region src/contracts/deepbook/account.d.ts
6
6
  declare const Account: MoveStruct<{
7
- epoch: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
7
+ epoch: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
8
8
  open_orders: MoveStruct<{
9
- contents: _mysten_sui_bcs0.BcsType<string[], Iterable<string | number | bigint> & {
9
+ contents: _mysten_sui_bcs2.BcsType<string[], Iterable<string | number | bigint> & {
10
10
  length: number;
11
11
  }, string>;
12
12
  }, "0x2::vec_set::VecSet<u128>">;
13
- taker_volume: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u128">;
14
- maker_volume: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u128">;
15
- active_stake: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
16
- inactive_stake: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
17
- created_proposal: _mysten_sui_bcs0.BcsType<boolean, boolean, "bool">;
18
- voted_proposal: _mysten_sui_bcs0.BcsType<string | null, string | Uint8Array<ArrayBufferLike> | null | undefined, "Option<bytes[32]>">;
13
+ taker_volume: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u128">;
14
+ maker_volume: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u128">;
15
+ active_stake: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
16
+ inactive_stake: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
17
+ created_proposal: _mysten_sui_bcs2.BcsType<boolean, boolean, "bool">;
18
+ voted_proposal: _mysten_sui_bcs2.BcsType<string | null, string | Uint8Array<ArrayBufferLike> | null | undefined, "Option<bytes[32]>">;
19
19
  unclaimed_rebates: MoveStruct<{
20
- base: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
21
- quote: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
22
- deep: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
20
+ base: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
21
+ quote: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
22
+ deep: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
23
23
  }, "@deepbook/core::balances::Balances">;
24
24
  settled_balances: MoveStruct<{
25
- base: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
26
- quote: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
27
- deep: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
25
+ base: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
26
+ quote: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
27
+ deep: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
28
28
  }, "@deepbook/core::balances::Balances">;
29
29
  owed_balances: MoveStruct<{
30
- base: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
31
- quote: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
32
- deep: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
30
+ base: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
31
+ quote: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
32
+ deep: _mysten_sui_bcs2.BcsType<string, string | number | bigint, "u64">;
33
33
  }, "@deepbook/core::balances::Balances">;
34
34
  }, "@deepbook/core::account::Account">;
35
35
  //#endregion
@@ -1,11 +1,11 @@
1
1
  import { MoveStruct } from "../utils/index.mjs";
2
- import * as _mysten_sui_bcs16 from "@mysten/sui/bcs";
2
+ import * as _mysten_sui_bcs0 from "@mysten/sui/bcs";
3
3
 
4
4
  //#region src/contracts/deepbook/balances.d.ts
5
5
  declare const Balances: MoveStruct<{
6
- base: _mysten_sui_bcs16.BcsType<string, string | number | bigint, "u64">;
7
- quote: _mysten_sui_bcs16.BcsType<string, string | number | bigint, "u64">;
8
- deep: _mysten_sui_bcs16.BcsType<string, string | number | bigint, "u64">;
6
+ base: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
7
+ quote: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
8
+ deep: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
9
9
  }, "@deepbook/core::balances::Balances">;
10
10
  //#endregion
11
11
  export { Balances };
@@ -1 +1 @@
1
- {"version":3,"file":"balances.d.mts","names":[],"sources":["../../../src/contracts/deepbook/balances.ts"],"mappings":";;;;cAYa,QAAA,EAAQ,UAAA;QAOnB,iBAAA,CAAA,OAAA"}
1
+ {"version":3,"file":"balances.d.mts","names":[],"sources":["../../../src/contracts/deepbook/balances.ts"],"mappings":";;;;cAYa,QAAA,EAAQ,UAAA;QAOnB,gBAAA,CAAA,OAAA"}
@@ -1,11 +1,11 @@
1
1
  import { MoveStruct } from "../utils/index.mjs";
2
- import * as _mysten_sui_bcs51 from "@mysten/sui/bcs";
2
+ import * as _mysten_sui_bcs19 from "@mysten/sui/bcs";
3
3
  import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
4
4
 
5
5
  //#region src/contracts/deepbook/deep_price.d.ts
6
6
  declare const OrderDeepPrice: MoveStruct<{
7
- asset_is_base: _mysten_sui_bcs51.BcsType<boolean, boolean, "bool">;
8
- deep_per_asset: _mysten_sui_bcs51.BcsType<string, string | number | bigint, "u64">;
7
+ asset_is_base: _mysten_sui_bcs19.BcsType<boolean, boolean, "bool">;
8
+ deep_per_asset: _mysten_sui_bcs19.BcsType<string, string | number | bigint, "u64">;
9
9
  }, "@deepbook/core::deep_price::OrderDeepPrice">;
10
10
  //#endregion
11
11
  export { OrderDeepPrice };
@@ -1,22 +1,22 @@
1
1
  import { MoveStruct } from "../utils/index.mjs";
2
- import * as _mysten_sui_bcs19 from "@mysten/sui/bcs";
2
+ import * as _mysten_sui_bcs32 from "@mysten/sui/bcs";
3
3
  import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
4
4
 
5
5
  //#region src/contracts/deepbook/order.d.ts
6
6
  declare const Order: MoveStruct<{
7
- balance_manager_id: _mysten_sui_bcs19.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
8
- order_id: _mysten_sui_bcs19.BcsType<string, string | number | bigint, "u128">;
9
- client_order_id: _mysten_sui_bcs19.BcsType<string, string | number | bigint, "u64">;
10
- quantity: _mysten_sui_bcs19.BcsType<string, string | number | bigint, "u64">;
11
- filled_quantity: _mysten_sui_bcs19.BcsType<string, string | number | bigint, "u64">;
12
- fee_is_deep: _mysten_sui_bcs19.BcsType<boolean, boolean, "bool">;
7
+ balance_manager_id: _mysten_sui_bcs32.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
8
+ order_id: _mysten_sui_bcs32.BcsType<string, string | number | bigint, "u128">;
9
+ client_order_id: _mysten_sui_bcs32.BcsType<string, string | number | bigint, "u64">;
10
+ quantity: _mysten_sui_bcs32.BcsType<string, string | number | bigint, "u64">;
11
+ filled_quantity: _mysten_sui_bcs32.BcsType<string, string | number | bigint, "u64">;
12
+ fee_is_deep: _mysten_sui_bcs32.BcsType<boolean, boolean, "bool">;
13
13
  order_deep_price: MoveStruct<{
14
- asset_is_base: _mysten_sui_bcs19.BcsType<boolean, boolean, "bool">;
15
- deep_per_asset: _mysten_sui_bcs19.BcsType<string, string | number | bigint, "u64">;
14
+ asset_is_base: _mysten_sui_bcs32.BcsType<boolean, boolean, "bool">;
15
+ deep_per_asset: _mysten_sui_bcs32.BcsType<string, string | number | bigint, "u64">;
16
16
  }, "@deepbook/core::deep_price::OrderDeepPrice">;
17
- epoch: _mysten_sui_bcs19.BcsType<string, string | number | bigint, "u64">;
18
- status: _mysten_sui_bcs19.BcsType<number, number, "u8">;
19
- expire_timestamp: _mysten_sui_bcs19.BcsType<string, string | number | bigint, "u64">;
17
+ epoch: _mysten_sui_bcs32.BcsType<string, string | number | bigint, "u64">;
18
+ status: _mysten_sui_bcs32.BcsType<number, number, "u8">;
19
+ expire_timestamp: _mysten_sui_bcs32.BcsType<string, string | number | bigint, "u64">;
20
20
  }, "@deepbook/core::order::Order">;
21
21
  //#endregion
22
22
  export { Order };
@@ -105,6 +105,35 @@ declare class DeepBookAdminContract {
105
105
  * @returns A function that takes a Transaction object and returns a bool
106
106
  */
107
107
  deauthorizeMarginApp: () => (tx: Transaction) => _mysten_sui_transactions29.TransactionResult;
108
+ /**
109
+ * @description Mint a `DeepbookCorePauseCap`. The new cap's ID is recorded
110
+ * in the core registry so it can later disable any allowed package version
111
+ * via `disableVersionWithCorePauseCap`. Companion to the margin-side
112
+ * `MarginAdminContract.mintPauseCap`.
113
+ * @returns A function that takes a Transaction object and returns the new pause cap
114
+ */
115
+ mintCorePauseCap: () => (tx: Transaction) => _mysten_sui_transactions29.TransactionResult;
116
+ /**
117
+ * @description Revoke a previously minted `DeepbookCorePauseCap` by ID.
118
+ * @param {string} pauseCapId The ID of the core pause cap to revoke
119
+ * @returns A function that takes a Transaction object
120
+ */
121
+ revokeCorePauseCap: (pauseCapId: string) => (tx: Transaction) => void;
122
+ /**
123
+ * @description Emergency kill switch — disable any allowed core package
124
+ * version (including the current one) using a held `DeepbookCorePauseCap`.
125
+ * Re-enable later via `enableVersion`.
126
+ * @param {number | bigint} version The version to disable
127
+ * @param {string} pauseCapId The ID of the core pause cap to authorize the disable
128
+ * @returns A function that takes a Transaction object
129
+ */
130
+ disableVersionWithCorePauseCap: (version: number | bigint, pauseCapId: string) => (tx: Transaction) => void;
131
+ /**
132
+ * @description Get the set of allowed `DeepbookCorePauseCap` IDs from the
133
+ * core registry.
134
+ * @returns A function that takes a Transaction object and returns a `VecSet<ID>`
135
+ */
136
+ corePauseCaps: () => (tx: Transaction) => _mysten_sui_transactions29.TransactionResult;
108
137
  }
109
138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AAA,SAA0B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAYK;;;;;EAA9C,kBAAA,GAAsB,UAAA,cAAwB,EAAA,EAAI,WAAA;EAoClD;;;;;;;;EAjBA,8BAAA,GACE,OAAA,mBAA0B,UAAA,cAAwB,EAAA,EAAI,WAAA;;;;;;EAgBxD,aAAA,SAAuB,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;AAAA"}
@@ -194,14 +194,46 @@ var DeepBookAdminContract = class {
194
194
  tx.moveCall({
195
195
  target: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::authorize_app`,
196
196
  arguments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],
197
- typeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::margin_manager::MarginApp`]
197
+ typeArguments: [`${this.#config.MARGIN_V1}::margin_manager::MarginApp`]
198
198
  });
199
199
  };
200
200
  this.deauthorizeMarginApp = () => (tx) => {
201
201
  return tx.moveCall({
202
202
  target: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::deauthorize_app`,
203
203
  arguments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],
204
- typeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::margin_manager::MarginApp`]
204
+ typeArguments: [`${this.#config.MARGIN_V1}::margin_manager::MarginApp`]
205
+ });
206
+ };
207
+ this.mintCorePauseCap = () => (tx) => {
208
+ return tx.moveCall({
209
+ target: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::mint_pause_cap`,
210
+ arguments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())]
211
+ });
212
+ };
213
+ this.revokeCorePauseCap = (pauseCapId) => (tx) => {
214
+ tx.moveCall({
215
+ target: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::revoke_pause_cap`,
216
+ arguments: [
217
+ tx.object(this.#config.REGISTRY_ID),
218
+ tx.object(this.#adminCap()),
219
+ tx.pure.id(pauseCapId)
220
+ ]
221
+ });
222
+ };
223
+ this.disableVersionWithCorePauseCap = (version, pauseCapId) => (tx) => {
224
+ tx.moveCall({
225
+ target: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::disable_version_pause_cap`,
226
+ arguments: [
227
+ tx.object(this.#config.REGISTRY_ID),
228
+ tx.pure.u64(version),
229
+ tx.object(pauseCapId)
230
+ ]
231
+ });
232
+ };
233
+ this.corePauseCaps = () => (tx) => {
234
+ return tx.moveCall({
235
+ target: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::allowed_pause_caps`,
236
+ arguments: [tx.object(this.#config.REGISTRY_ID)]
205
237
  });
206
238
  };
207
239
  this.#config = config;
@@ -1 +1 @@
1
- {"version":3,"file":"deepbookAdmin.mjs","names":["#config","#adminCap"],"sources":["../../src/transactions/deepbookAdmin.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { CreatePoolAdminParams, SetEwmaParams } from '../types/index.js';\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { convertQuantity, convertPrice, convertRate } from '../utils/conversion.js';\n\n/**\n * DeepBookAdminContract class for managing admin actions.\n */\nexport class DeepBookAdminContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for DeepBookAdminContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @returns The admin capability required for admin operations\n\t * @throws Error if the admin capability is not set\n\t */\n\t#adminCap() {\n\t\tconst adminCap = this.#config.adminCap;\n\t\tif (!adminCap) {\n\t\t\tthrow new Error('ADMIN_CAP environment variable not set');\n\t\t}\n\t\treturn adminCap;\n\t}\n\n\t/**\n\t * @description Create a new pool as admin\n\t * @param {CreatePoolAdminParams} params Parameters for creating pool as admin\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreatePoolAdmin = (params: CreatePoolAdminParams) => (tx: Transaction) => {\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\tconst { baseCoinKey, quoteCoinKey, tickSize, lotSize, minSize, whitelisted, stablePool } =\n\t\t\tparams;\n\t\tconst baseCoin = this.#config.getCoin(baseCoinKey);\n\t\tconst quoteCoin = this.#config.getCoin(quoteCoinKey);\n\n\t\tconst baseScalar = baseCoin.scalar;\n\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\tconst adjustedTickSize = convertPrice(tickSize, FLOAT_SCALAR, quoteScalar, baseScalar);\n\t\tconst adjustedLotSize = convertQuantity(lotSize, baseScalar);\n\t\tconst adjustedMinSize = convertQuantity(minSize, baseScalar);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::create_pool_admin`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.REGISTRY_ID), // registry_id\n\t\t\t\ttx.pure.u64(adjustedTickSize), // adjusted tick_size\n\t\t\t\ttx.pure.u64(adjustedLotSize), // adjusted lot_size\n\t\t\t\ttx.pure.u64(adjustedMinSize), // adjusted min_size\n\t\t\t\ttx.pure.bool(whitelisted),\n\t\t\t\ttx.pure.bool(stablePool),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Unregister a pool as admin\n\t * @param {string} poolKey The key of the pool to be unregistered by admin\n\t * @returns A function that takes a Transaction object\n\t */\n\tunregisterPoolAdmin = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::unregister_pool_admin`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Update the allowed versions for a pool\n\t * @param {string} poolKey The key of the pool to be updated\n\t * @returns A function that takes a Transaction object\n\t */\n\tupdateAllowedVersions = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::update_allowed_versions`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Enable a specific version\n\t * @param {number} version The version to be enabled\n\t * @returns A function that takes a Transaction object\n\t */\n\tenableVersion = (version: number) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::enable_version`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.pure.u64(version),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Disable a specific version\n\t * @param {number} version The version to be disabled\n\t * @returns A function that takes a Transaction object\n\t */\n\tdisableVersion = (version: number) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::disable_version`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.pure.u64(version),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Sets the treasury address where pool creation fees will be sent\n\t * @param {string} treasuryAddress The treasury address\n\t * @returns A function that takes a Transaction object\n\t */\n\tsetTreasuryAddress = (treasuryAddress: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::set_treasury_address`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.pure.address(treasuryAddress),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Add a coin to whitelist of stable coins\n\t * @param {string} stableCoinKey The name of the stable coin to be added\n\t * @returns A function that takes a Transaction object\n\t */\n\taddStableCoin = (stableCoinKey: string) => (tx: Transaction) => {\n\t\tconst stableCoinType = this.#config.getCoin(stableCoinKey).type;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::add_stablecoin`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t\ttypeArguments: [stableCoinType],\n\t\t});\n\t};\n\n\t/**\n\t * @description Remove a coin from whitelist of stable coins\n\t * @param {string} stableCoinKey The name of the stable coin to be removed\n\t * @returns A function that takes a Transaction object\n\t */\n\tremoveStableCoin = (stableCoinKey: string) => (tx: Transaction) => {\n\t\tconst stableCoinType = this.#config.getCoin(stableCoinKey).type;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::remove_stablecoin`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t\ttypeArguments: [stableCoinType],\n\t\t});\n\t};\n\n\t/**\n\t * @description Adjust the tick size of a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} newTickSize The new tick size\n\t * @returns A function that takes a Transaction object\n\t */\n\tadjustTickSize = (poolKey: string, newTickSize: number) => (tx: Transaction) => {\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst baseScalar = baseCoin.scalar;\n\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\tconst adjustedTickSize = convertPrice(newTickSize, FLOAT_SCALAR, quoteScalar, baseScalar);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::adjust_tick_size_admin`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address), // pool address\n\t\t\t\ttx.pure.u64(adjustedTickSize), // adjusted tick_size\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Adjust the lot size and min size of a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} newLotSize The new lot size\n\t * @param {number} newMinSize The new min size\n\t * @returns A function that takes a Transaction object\n\t */\n\tadjustMinLotSize =\n\t\t(poolKey: string, newLotSize: number, newMinSize: number) => (tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t\tconst baseScalar = baseCoin.scalar;\n\n\t\t\tconst adjustedLotSize = convertQuantity(newLotSize, baseScalar);\n\t\t\tconst adjustedMinSize = convertQuantity(newMinSize, baseScalar);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::adjust_min_lot_size_admin`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address), // pool address\n\t\t\t\t\ttx.pure.u64(adjustedLotSize),\n\t\t\t\t\ttx.pure.u64(adjustedMinSize),\n\t\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Initialize the balance manager map\n\t * @returns A function that takes a Transaction object\n\t */\n\tinitBalanceManagerMap = () => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::init_balance_manager_map`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t});\n\t};\n\n\t/**\n\t * @description Set the EWMA parameters for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {SetEwmaParamsParams} params The parameters to set\n\t * @returns A function that takes a Transaction object\n\t */\n\tsetEwmaParams = (poolKey: string, params: SetEwmaParams) => (tx: Transaction) => {\n\t\tconst { alpha, zScoreThreshold, additionalTakerFee } = params;\n\t\tconst adjustedAlpha = convertRate(alpha, FLOAT_SCALAR);\n\t\tconst adjustedZScoreThreshold = convertRate(zScoreThreshold, FLOAT_SCALAR);\n\t\tconst adjustedAdditionalTakerFee = convertRate(additionalTakerFee, FLOAT_SCALAR);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::set_ewma_params`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t\ttx.pure.u64(adjustedAlpha),\n\t\t\t\ttx.pure.u64(adjustedZScoreThreshold),\n\t\t\t\ttx.pure.u64(adjustedAdditionalTakerFee),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Enable or disable the EWMA state for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} enable Whether to enable or disable the EWMA state\n\t * @returns A function that takes a Transaction object\n\t */\n\tenableEwmaState = (poolKey: string, enable: boolean) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::enable_ewma_state`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t\ttx.pure.bool(enable),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Authorize the MarginApp to access protected features of DeepBook\n\t * @returns A function that takes a Transaction object\n\t */\n\tauthorizeMarginApp = () => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::authorize_app`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t\ttypeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::margin_manager::MarginApp`],\n\t\t});\n\t};\n\n\t/**\n\t * @description Deauthorize the MarginApp by removing its authorization key\n\t * @returns A function that takes a Transaction object and returns a bool\n\t */\n\tdeauthorizeMarginApp = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::deauthorize_app`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t\ttypeArguments: [`${this.#config.MARGIN_PACKAGE_ID}::margin_manager::MarginApp`],\n\t\t});\n\t};\n}\n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ier: Apache-2.0\n\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { CreatePoolAdminParams, SetEwmaParams } from '../types/index.js';\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { FLOAT_SCALAR } from '../utils/config.js';\nimport { convertQuantity, convertPrice, convertRate } from '../utils/conversion.js';\n\n/**\n * DeepBookAdminContract class for managing admin actions.\n */\nexport class DeepBookAdminContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for DeepBookAdminContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @returns The admin capability required for admin operations\n\t * @throws Error if the admin capability is not set\n\t */\n\t#adminCap() {\n\t\tconst adminCap = this.#config.adminCap;\n\t\tif (!adminCap) {\n\t\t\tthrow new Error('ADMIN_CAP environment variable not set');\n\t\t}\n\t\treturn adminCap;\n\t}\n\n\t/**\n\t * @description Create a new pool as admin\n\t * @param {CreatePoolAdminParams} params Parameters for creating pool as admin\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreatePoolAdmin = (params: CreatePoolAdminParams) => (tx: Transaction) => {\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\tconst { baseCoinKey, quoteCoinKey, tickSize, lotSize, minSize, whitelisted, stablePool } =\n\t\t\tparams;\n\t\tconst baseCoin = this.#config.getCoin(baseCoinKey);\n\t\tconst quoteCoin = this.#config.getCoin(quoteCoinKey);\n\n\t\tconst baseScalar = baseCoin.scalar;\n\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\tconst adjustedTickSize = convertPrice(tickSize, FLOAT_SCALAR, quoteScalar, baseScalar);\n\t\tconst adjustedLotSize = convertQuantity(lotSize, baseScalar);\n\t\tconst adjustedMinSize = convertQuantity(minSize, baseScalar);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::create_pool_admin`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.REGISTRY_ID), // registry_id\n\t\t\t\ttx.pure.u64(adjustedTickSize), // adjusted tick_size\n\t\t\t\ttx.pure.u64(adjustedLotSize), // adjusted lot_size\n\t\t\t\ttx.pure.u64(adjustedMinSize), // adjusted min_size\n\t\t\t\ttx.pure.bool(whitelisted),\n\t\t\t\ttx.pure.bool(stablePool),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Unregister a pool as admin\n\t * @param {string} poolKey The key of the pool to be unregistered by admin\n\t * @returns A function that takes a Transaction object\n\t */\n\tunregisterPoolAdmin = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::unregister_pool_admin`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Update the allowed versions for a pool\n\t * @param {string} poolKey The key of the pool to be updated\n\t * @returns A function that takes a Transaction object\n\t */\n\tupdateAllowedVersions = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::update_allowed_versions`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Enable a specific version\n\t * @param {number} version The version to be enabled\n\t * @returns A function that takes a Transaction object\n\t */\n\tenableVersion = (version: number) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::enable_version`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.pure.u64(version),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Disable a specific version\n\t * @param {number} version The version to be disabled\n\t * @returns A function that takes a Transaction object\n\t */\n\tdisableVersion = (version: number) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::disable_version`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.pure.u64(version),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Sets the treasury address where pool creation fees will be sent\n\t * @param {string} treasuryAddress The treasury address\n\t * @returns A function that takes a Transaction object\n\t */\n\tsetTreasuryAddress = (treasuryAddress: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::set_treasury_address`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.pure.address(treasuryAddress),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Add a coin to whitelist of stable coins\n\t * @param {string} stableCoinKey The name of the stable coin to be added\n\t * @returns A function that takes a Transaction object\n\t */\n\taddStableCoin = (stableCoinKey: string) => (tx: Transaction) => {\n\t\tconst stableCoinType = this.#config.getCoin(stableCoinKey).type;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::add_stablecoin`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t\ttypeArguments: [stableCoinType],\n\t\t});\n\t};\n\n\t/**\n\t * @description Remove a coin from whitelist of stable coins\n\t * @param {string} stableCoinKey The name of the stable coin to be removed\n\t * @returns A function that takes a Transaction object\n\t */\n\tremoveStableCoin = (stableCoinKey: string) => (tx: Transaction) => {\n\t\tconst stableCoinType = this.#config.getCoin(stableCoinKey).type;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::remove_stablecoin`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t\ttypeArguments: [stableCoinType],\n\t\t});\n\t};\n\n\t/**\n\t * @description Adjust the tick size of a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} newTickSize The new tick size\n\t * @returns A function that takes a Transaction object\n\t */\n\tadjustTickSize = (poolKey: string, newTickSize: number) => (tx: Transaction) => {\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst baseScalar = baseCoin.scalar;\n\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\tconst adjustedTickSize = convertPrice(newTickSize, FLOAT_SCALAR, quoteScalar, baseScalar);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::adjust_tick_size_admin`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address), // pool address\n\t\t\t\ttx.pure.u64(adjustedTickSize), // adjusted tick_size\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Adjust the lot size and min size of a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} newLotSize The new lot size\n\t * @param {number} newMinSize The new min size\n\t * @returns A function that takes a Transaction object\n\t */\n\tadjustMinLotSize =\n\t\t(poolKey: string, newLotSize: number, newMinSize: number) => (tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t\tconst baseScalar = baseCoin.scalar;\n\n\t\t\tconst adjustedLotSize = convertQuantity(newLotSize, baseScalar);\n\t\t\tconst adjustedMinSize = convertQuantity(newMinSize, baseScalar);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::adjust_min_lot_size_admin`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address), // pool address\n\t\t\t\t\ttx.pure.u64(adjustedLotSize),\n\t\t\t\t\ttx.pure.u64(adjustedMinSize),\n\t\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t\t\ttx.object.clock(),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Initialize the balance manager map\n\t * @returns A function that takes a Transaction object\n\t */\n\tinitBalanceManagerMap = () => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::init_balance_manager_map`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t});\n\t};\n\n\t/**\n\t * @description Set the EWMA parameters for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {SetEwmaParamsParams} params The parameters to set\n\t * @returns A function that takes a Transaction object\n\t */\n\tsetEwmaParams = (poolKey: string, params: SetEwmaParams) => (tx: Transaction) => {\n\t\tconst { alpha, zScoreThreshold, additionalTakerFee } = params;\n\t\tconst adjustedAlpha = convertRate(alpha, FLOAT_SCALAR);\n\t\tconst adjustedZScoreThreshold = convertRate(zScoreThreshold, FLOAT_SCALAR);\n\t\tconst adjustedAdditionalTakerFee = convertRate(additionalTakerFee, FLOAT_SCALAR);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::set_ewma_params`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t\ttx.pure.u64(adjustedAlpha),\n\t\t\t\ttx.pure.u64(adjustedZScoreThreshold),\n\t\t\t\ttx.pure.u64(adjustedAdditionalTakerFee),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Enable or disable the EWMA state for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {boolean} enable Whether to enable or disable the EWMA state\n\t * @returns A function that takes a Transaction object\n\t */\n\tenableEwmaState = (poolKey: string, enable: boolean) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::enable_ewma_state`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t\ttx.pure.bool(enable),\n\t\t\t\ttx.object.clock(),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Authorize the MarginApp to access protected features of DeepBook\n\t * @returns A function that takes a Transaction object\n\t */\n\tauthorizeMarginApp = () => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::authorize_app`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t\ttypeArguments: [`${this.#config.MARGIN_V1}::margin_manager::MarginApp`],\n\t\t});\n\t};\n\n\t/**\n\t * @description Deauthorize the MarginApp by removing its authorization key\n\t * @returns A function that takes a Transaction object and returns a bool\n\t */\n\tdeauthorizeMarginApp = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::deauthorize_app`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t\ttypeArguments: [`${this.#config.MARGIN_V1}::margin_manager::MarginApp`],\n\t\t});\n\t};\n\n\t/**\n\t * @description Mint a `DeepbookCorePauseCap`. The new cap's ID is recorded\n\t * in the core registry so it can later disable any allowed package version\n\t * via `disableVersionWithCorePauseCap`. Companion to the margin-side\n\t * `MarginAdminContract.mintPauseCap`.\n\t * @returns A function that takes a Transaction object and returns the new pause cap\n\t */\n\tmintCorePauseCap = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::mint_pause_cap`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID), tx.object(this.#adminCap())],\n\t\t});\n\t};\n\n\t/**\n\t * @description Revoke a previously minted `DeepbookCorePauseCap` by ID.\n\t * @param {string} pauseCapId The ID of the core pause cap to revoke\n\t * @returns A function that takes a Transaction object\n\t */\n\trevokeCorePauseCap = (pauseCapId: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::revoke_pause_cap`,\n\t\t\targuments: [\n\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\ttx.object(this.#adminCap()),\n\t\t\t\ttx.pure.id(pauseCapId),\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Emergency kill switch — disable any allowed core package\n\t * version (including the current one) using a held `DeepbookCorePauseCap`.\n\t * Re-enable later via `enableVersion`.\n\t * @param {number | bigint} version The version to disable\n\t * @param {string} pauseCapId The ID of the core pause cap to authorize the disable\n\t * @returns A function that takes a Transaction object\n\t */\n\tdisableVersionWithCorePauseCap =\n\t\t(version: number | bigint, pauseCapId: string) => (tx: Transaction) => {\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::disable_version_pause_cap`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(this.#config.REGISTRY_ID),\n\t\t\t\t\ttx.pure.u64(version),\n\t\t\t\t\ttx.object(pauseCapId),\n\t\t\t\t],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Get the set of allowed `DeepbookCorePauseCap` IDs from the\n\t * core registry.\n\t * @returns A function that takes a Transaction object and returns a `VecSet<ID>`\n\t */\n\tcorePauseCaps = () => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::registry::allowed_pause_caps`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID)],\n\t\t});\n\t};\n}\n"],"mappings":";;;;;;;AAaA,IAAa,wBAAb,MAAmC;CAClC;;;;CAKA,YAAY,QAAwB;0BAqBjB,YAAmC,OAAoB;AACzE,MAAG,kBAAkB,MAAKA,OAAQ,QAAQ;GAC1C,MAAM,EAAE,aAAa,cAAc,UAAU,SAAS,SAAS,aAAa,eAC3E;GACD,MAAM,WAAW,MAAKA,OAAQ,QAAQ,YAAY;GAClD,MAAM,YAAY,MAAKA,OAAQ,QAAQ,aAAa;GAEp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AAI,QAAQ;KACpB,GAAG,OAAO,WAAW;KACrB;IACD,CAAC;;8BAQmB,OAAoB;AAC1C,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,oBAAoB;IAC5C,WAAW,CAAC,GAAG,OAAO,MAAKA,OAAQ,YAAY,CAAC;IAChD,CAAC;;AApXF,QAAKA,SAAU;;;;;;CAOhB,YAAY;EACX,MAAM,WAAW,MAAKA,OAAQ;AAC9B,MAAI,CAAC,SACJ,OAAM,IAAI,MAAM,yCAAyC;AAE1D,SAAO"}
@@ -1,6 +1,6 @@
1
1
  import { PoolConfigParams } from "../types/index.mjs";
2
2
  import { DeepBookConfig } from "../utils/config.mjs";
3
- import * as _mysten_sui_transactions30 from "@mysten/sui/transactions";
3
+ import * as _mysten_sui_transactions32 from "@mysten/sui/transactions";
4
4
  import { Transaction, TransactionArgument } from "@mysten/sui/transactions";
5
5
 
6
6
  //#region src/transactions/marginAdmin.d.ts
@@ -17,7 +17,7 @@ declare class MarginAdminContract {
17
17
  * @description Mint a maintainer cap
18
18
  * @returns A function that takes a Transaction object
19
19
  */
20
- mintMaintainerCap: () => (tx: Transaction) => _mysten_sui_transactions30.TransactionResult;
20
+ mintMaintainerCap: () => (tx: Transaction) => _mysten_sui_transactions32.TransactionResult;
21
21
  /**
22
22
  * @description Revoke a maintainer cap
23
23
  * @returns A function that takes a Transaction object
@@ -49,6 +49,37 @@ declare class MarginAdminContract {
49
49
  * @returns A function that takes a Transaction object
50
50
  */
51
51
  updateRiskParams: (poolKey: string, poolConfig: TransactionArgument) => (tx: Transaction) => void;
52
+ /**
53
+ * @description Set the price deviation tolerance for a pool. `tolerance` is
54
+ * in 9-decimal float scaling (1.0 = `FLOAT_SCALAR`); the SDK applies the
55
+ * scaling, so callers pass a human-readable fraction (e.g. `0.1` for 10%).
56
+ * Requires the pool's current price to have been initialized via
57
+ * `PoolProxyContract.updateCurrentPrice` first.
58
+ * @param {string} poolKey The key of the pool to update
59
+ * @param {number | bigint} tolerance Tolerance as a fraction (e.g. 0.1 for 10%)
60
+ * @returns A function that takes a Transaction object
61
+ */
62
+ setPriceTolerance: (poolKey: string, tolerance: number | bigint) => (tx: Transaction) => void;
63
+ /**
64
+ * @description Set the maximum acceptable Pyth price age (in milliseconds)
65
+ * for a pool. Requires the pool's current price to have been initialized
66
+ * via `PoolProxyContract.updateCurrentPrice` first.
67
+ * @param {string} poolKey The key of the pool to update
68
+ * @param {number | bigint} maxAgeMs Max age in milliseconds (raw u64)
69
+ * @returns A function that takes a Transaction object
70
+ */
71
+ setMaxPriceAge: (poolKey: string, maxAgeMs: number | bigint) => (tx: Transaction) => void;
72
+ /**
73
+ * @description Set the maximum lifetime (in milliseconds) of margin limit
74
+ * orders for a pool. `pool_proxy::place_limit_order_v2` and
75
+ * `place_reduce_only_limit_order_v2` clamp the user-supplied
76
+ * `expire_timestamp` to at most `now + max_order_ttl_ms`, bounding margin
77
+ * orders' exposure to stale-price exploitation.
78
+ * @param {string} poolKey The key of the pool to update
79
+ * @param {number | bigint} maxOrderTtlMs Max order TTL in milliseconds (raw u64)
80
+ * @returns A function that takes a Transaction object
81
+ */
82
+ setMaxOrderTtl: (poolKey: string, maxOrderTtlMs: number | bigint) => (tx: Transaction) => void;
52
83
  /**
53
84
  * @description Add the PythConfig to the margin registry
54
85
  * @param {Transaction} tx The transaction object
@@ -80,7 +111,7 @@ declare class MarginAdminContract {
80
111
  * @param {PoolConfigParams} poolConfigParams The parameters for the pool config
81
112
  * @returns A function that takes a Transaction object
82
113
  */
83
- newPoolConfig: (poolKey: string, poolConfigParams: PoolConfigParams) => (tx: Transaction) => _mysten_sui_transactions30.TransactionResult;
114
+ newPoolConfig: (poolKey: string, poolConfigParams: PoolConfigParams) => (tx: Transaction) => _mysten_sui_transactions32.TransactionResult;
84
115
  /**
85
116
  * @description Create a new pool config with leverage
86
117
  * @param {string} poolKey The key to identify the pool
@@ -95,7 +126,7 @@ declare class MarginAdminContract {
95
126
  * @param {number} maxEwmaDifferenceBps The maximum EWMA difference in basis points
96
127
  * @returns A function that takes a Transaction object
97
128
  */
98
- newCoinTypeData: (coinKey: string, maxConfBps: number, maxEwmaDifferenceBps: number) => (tx: Transaction) => _mysten_sui_transactions30.TransactionResult;
129
+ newCoinTypeData: (coinKey: string, maxConfBps: number, maxEwmaDifferenceBps: number) => (tx: Transaction) => _mysten_sui_transactions32.TransactionResult;
99
130
  /**
100
131
  * @description Create a new Pyth config
101
132
  * @param {Array<{coinKey: string, maxConfBps: number, maxEwmaDifferenceBps: number}>} coinSetups The coins with their oracle config to be added to the Pyth config
@@ -106,12 +137,12 @@ declare class MarginAdminContract {
106
137
  coinKey: string;
107
138
  maxConfBps: number;
108
139
  maxEwmaDifferenceBps: number;
109
- }>, maxAgeSeconds: number) => (tx: Transaction) => _mysten_sui_transactions30.TransactionResult;
140
+ }>, maxAgeSeconds: number) => (tx: Transaction) => _mysten_sui_transactions32.TransactionResult;
110
141
  /**
111
142
  * @description Mint a pause cap
112
143
  * @returns A function that takes a Transaction object
113
144
  */
114
- mintPauseCap: () => (tx: Transaction) => _mysten_sui_transactions30.TransactionResult;
145
+ mintPauseCap: () => (tx: Transaction) => _mysten_sui_transactions32.TransactionResult;
115
146
  /**
116
147
  * @description Revoke a pause cap
117
148
  * @param {string} pauseCapId The ID of the pause cap to revoke
@@ -131,7 +162,7 @@ declare class MarginAdminContract {
131
162
  * @param {string} coinKey The key to identify the margin pool
132
163
  * @returns A function that takes a Transaction object and returns a Coin<Asset>
133
164
  */
134
- adminWithdrawDefaultReferralFees: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions30.TransactionResult;
165
+ adminWithdrawDefaultReferralFees: (coinKey: string) => (tx: Transaction) => _mysten_sui_transactions32.TransactionResult;
135
166
  }
136
167
  //#endregion
137
168
  export { MarginAdminContract };
@@ -1 +1 @@
1
- {"version":3,"file":"marginAdmin.d.mts","names":[],"sources":["../../src/transactions/marginAdmin.ts"],"mappings":";;;;;;;;AAeA;cAAa,mBAA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Aa,MAAA,EAAQ,mBAAA,MAAyB,EAAA,EAAI,WAAA;EAvBhC;;;;;EAwClB,YAAA,SAAsB,EAAA,EAAI,WAAA;EAjBb;;;;;EA8Bb,aAAA,GAAiB,OAAA,cAAqB,EAAA,EAAI,WAAA;EAA1C;;;;;EAgBA,cAAA,GAAkB,OAAA,cAAqB,EAAA,EAAI,WAAA;EAAA;;;;;;EAiB3C,aAAA,GAAiB,OAAA,UAAiB,gBAAA,EAAkB,gBAAA,MAAsB,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAAf;;;;;;EAiC1E,yBAAA,GAA6B,OAAA,UAAiB,QAAA,cAAsB,EAAA,EAAI,WAAA;EAqBxE;;;;;;;EAAA,eAAA,GACE,OAAA,UAAiB,UAAA,UAAoB,oBAAA,cAAkC,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EA4B1E;;;;;;EAFd,aAAA,GAEE,UAAA,EAAY,KAAA;IAAQ,OAAA;IAAiB,UAAA;IAAoB,oBAAA;EAAA,IACzD,aAAA,cAEA,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAuBK;;;;EAAtB,YAAA,SAAsB,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAgBK;;;;;EAA1C,cAAA,GAAkB,UAAA,cAAwB,EAAA,EAAI,WAAA;EAmC9C;;;;;;EAjBA,sBAAA,GAA0B,OAAA,UAAiB,UAAA,cAAwB,EAAA,EAAI,WAAA;;;;;;;EAiBvE,gCAAA,GAAoC,OAAA,cAAqB,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;AAAA"}
@@ -95,6 +95,54 @@ var MarginAdminContract = class {
95
95
  typeArguments: [baseCoin.type, quoteCoin.type]
96
96
  });
97
97
  };
98
+ this.setPriceTolerance = (poolKey, tolerance) => (tx) => {
99
+ const pool = this.#config.getPool(poolKey);
100
+ const baseCoin = this.#config.getCoin(pool.baseCoin);
101
+ const quoteCoin = this.#config.getCoin(pool.quoteCoin);
102
+ tx.moveCall({
103
+ target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::set_price_tolerance`,
104
+ arguments: [
105
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
106
+ tx.object(this.#marginAdminCap()),
107
+ tx.object(pool.address),
108
+ tx.pure.u64(convertRate(tolerance, FLOAT_SCALAR)),
109
+ tx.object.clock()
110
+ ],
111
+ typeArguments: [baseCoin.type, quoteCoin.type]
112
+ });
113
+ };
114
+ this.setMaxPriceAge = (poolKey, maxAgeMs) => (tx) => {
115
+ const pool = this.#config.getPool(poolKey);
116
+ const baseCoin = this.#config.getCoin(pool.baseCoin);
117
+ const quoteCoin = this.#config.getCoin(pool.quoteCoin);
118
+ tx.moveCall({
119
+ target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::set_max_price_age`,
120
+ arguments: [
121
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
122
+ tx.object(this.#marginAdminCap()),
123
+ tx.object(pool.address),
124
+ tx.pure.u64(maxAgeMs),
125
+ tx.object.clock()
126
+ ],
127
+ typeArguments: [baseCoin.type, quoteCoin.type]
128
+ });
129
+ };
130
+ this.setMaxOrderTtl = (poolKey, maxOrderTtlMs) => (tx) => {
131
+ const pool = this.#config.getPool(poolKey);
132
+ const baseCoin = this.#config.getCoin(pool.baseCoin);
133
+ const quoteCoin = this.#config.getCoin(pool.quoteCoin);
134
+ tx.moveCall({
135
+ target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::set_max_order_ttl`,
136
+ arguments: [
137
+ tx.object(this.#config.MARGIN_REGISTRY_ID),
138
+ tx.object(this.#marginAdminCap()),
139
+ tx.object(pool.address),
140
+ tx.pure.u64(maxOrderTtlMs),
141
+ tx.object.clock()
142
+ ],
143
+ typeArguments: [baseCoin.type, quoteCoin.type]
144
+ });
145
+ };
98
146
  this.addConfig = (config$1) => (tx) => {
99
147
  tx.moveCall({
100
148
  target: `${this.#config.MARGIN_PACKAGE_ID}::margin_registry::add_config`,