@mysten/deepbook-v3 1.3.6 → 1.4.1
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 +49 -0
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/transactions/deepbookAdmin.d.mts +29 -0
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.mjs +34 -2
- package/dist/transactions/deepbookAdmin.mjs.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +38 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +48 -0
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts +3 -3
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.mjs +4 -4
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts +116 -23
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +133 -1
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginRegistry.d.mts +15 -15
- package/dist/transactions/marginRegistry.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.d.mts +14 -11
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +5 -1
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +19 -9
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +31 -21
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/config.d.mts +1 -0
- package/dist/utils/config.d.mts.map +1 -1
- package/dist/utils/config.mjs +3 -0
- package/dist/utils/config.mjs.map +1 -1
- package/dist/utils/constants.d.mts +3 -0
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +5 -3
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +2 -2
- package/src/transactions/deepbookAdmin.ts +64 -2
- package/src/transactions/marginAdmin.ts +79 -0
- package/src/transactions/marginMaintainer.ts +4 -4
- package/src/transactions/marginManager.ts +244 -1
- package/src/transactions/marginTPSL.ts +10 -3
- package/src/transactions/poolProxy.ts +45 -21
- package/src/types/index.ts +1 -1
- package/src/utils/config.ts +4 -0
- package/src/utils/constants.ts +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# @mysten/deepbook-v3
|
|
2
2
|
|
|
3
|
+
## 1.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- bc99264: Bump mainnet `LIQUIDATION_PACKAGE_ID` to the latest published-at: `0x55718c06…41b8` →
|
|
8
|
+
`0xf17bff1bf21e9587acc5708714e520aa967f82f256f626938a33c4109b08adb9`.
|
|
9
|
+
|
|
10
|
+
## 1.4.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- e68bd36: Align margin SDK with `deepbook_margin` v5 on-chain source:
|
|
15
|
+
- Switch `pool_proxy` order placement builders (`placeLimitOrder`, `placeMarketOrder`,
|
|
16
|
+
`placeReduceOnlyLimitOrder`, `placeReduceOnlyMarketOrder`) to the `_v2` Move entries. The v1
|
|
17
|
+
entries are deprecated in the v5 package and abort with `EDeprecatedUseV2`. The v2 variants take
|
|
18
|
+
additional `base_margin_pool`, `quote_margin_pool`, `base_oracle`, and `quote_oracle` arguments
|
|
19
|
+
so the chain can enforce a post-trade `risk_ratio` invariant (borrow-floor for normal orders,
|
|
20
|
+
monotonic improvement for reduce-only).
|
|
21
|
+
- The reduce-only v2 entries dropped the `DebtAsset` generic and the explicit
|
|
22
|
+
`MarginPool<DebtAsset>` parameter; the package now dispatches on
|
|
23
|
+
`margin_manager.has_base_debt()` to pick the typed pool from the
|
|
24
|
+
`(base_margin_pool, quote_margin_pool)` pair. The SDK builders no longer take a debt-side margin
|
|
25
|
+
pool or third type argument.
|
|
26
|
+
- Switch `executeConditionalOrders` to `margin_manager::execute_conditional_orders_v2`, which adds
|
|
27
|
+
`base_margin_pool`/`quote_margin_pool` arguments and enforces the same post-fill solvency check.
|
|
28
|
+
- Fix `claimRebate` to target the actual Move entry name `pool_proxy::claim_rebates`. The previous
|
|
29
|
+
target did not exist on-chain.
|
|
30
|
+
- Rename `MarginPoolConfigParams.referralSpread` to `protocolSpread`. The Move field was renamed
|
|
31
|
+
upstream in the `protocol_config` module; the old SDK name was positionally correct but
|
|
32
|
+
misleading.
|
|
33
|
+
- Add `registerMarginManager` and `unregisterMarginManager` builders.
|
|
34
|
+
- Add read-only margin_manager builders exposed in newer source: `balanceManagerId`,
|
|
35
|
+
`getBalanceManagerReferralId`, `accountExists`, `account`, `accountOpenOrders`,
|
|
36
|
+
`getAccountOrderDetails`, `lockedBalance`, `canPlaceLimitOrder`, `canPlaceMarketOrder`.
|
|
37
|
+
- Add `MarginAdminContract.setPriceTolerance`, `setMaxPriceAge`, and `setMaxOrderTtl` builders for
|
|
38
|
+
the per-pool oracle and order-TTL admin entries on `margin_registry`. The `setMaxOrderTtl` entry
|
|
39
|
+
configures the per-pool `max_order_ttl_ms` cap that `pool_proxy::place_limit_order_v2` and
|
|
40
|
+
`place_reduce_only_limit_order_v2` use to clamp `expire_timestamp`.
|
|
41
|
+
- Add `DeepBookAdminContract.mintCorePauseCap`, `revokeCorePauseCap`,
|
|
42
|
+
`disableVersionWithCorePauseCap`, and `corePauseCaps` builders for the new
|
|
43
|
+
`DeepbookCorePauseCap` emergency-pause flow in the core spot `registry`. These mirror the
|
|
44
|
+
existing margin-side pause-cap builders.
|
|
45
|
+
- Bump mainnet `MARGIN_PACKAGE_ID` to
|
|
46
|
+
`0x124bb3d8105d6d301c0d40feaa54d65df6b301e4d8ddd5eb8475b0f8a18cff2e` to track the latest margin
|
|
47
|
+
package upgrade on mainnet.
|
|
48
|
+
- Bump mainnet `DEEPBOOK_PACKAGE_ID` to
|
|
49
|
+
`0x0e735f8c93a95722efd73521aca7a7652c0bb71ed1daf41b26dfd7d1ff71f748` to track the latest core
|
|
50
|
+
deepbook package upgrade on mainnet.
|
|
51
|
+
|
|
3
52
|
## 1.3.6
|
|
4
53
|
|
|
5
54
|
### Patch Changes
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_bcs44 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:
|
|
7
|
+
epoch: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
8
8
|
open_orders: MoveStruct<{
|
|
9
|
-
contents:
|
|
9
|
+
contents: _mysten_sui_bcs44.BcsType<string[], Iterable<string | number | bigint> & {
|
|
10
10
|
length: number;
|
|
11
11
|
}, string>;
|
|
12
12
|
}, "0x2::vec_set::VecSet<u128>">;
|
|
13
|
-
taker_volume:
|
|
14
|
-
maker_volume:
|
|
15
|
-
active_stake:
|
|
16
|
-
inactive_stake:
|
|
17
|
-
created_proposal:
|
|
18
|
-
voted_proposal:
|
|
13
|
+
taker_volume: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u128">;
|
|
14
|
+
maker_volume: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u128">;
|
|
15
|
+
active_stake: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
16
|
+
inactive_stake: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
17
|
+
created_proposal: _mysten_sui_bcs44.BcsType<boolean, boolean, "bool">;
|
|
18
|
+
voted_proposal: _mysten_sui_bcs44.BcsType<string | null, string | Uint8Array<ArrayBufferLike> | null | undefined, "Option<bytes[32]>">;
|
|
19
19
|
unclaimed_rebates: MoveStruct<{
|
|
20
|
-
base:
|
|
21
|
-
quote:
|
|
22
|
-
deep:
|
|
20
|
+
base: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
21
|
+
quote: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
22
|
+
deep: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
23
23
|
}, "@deepbook/core::balances::Balances">;
|
|
24
24
|
settled_balances: MoveStruct<{
|
|
25
|
-
base:
|
|
26
|
-
quote:
|
|
27
|
-
deep:
|
|
25
|
+
base: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
26
|
+
quote: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
27
|
+
deep: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
28
28
|
}, "@deepbook/core::balances::Balances">;
|
|
29
29
|
owed_balances: MoveStruct<{
|
|
30
|
-
base:
|
|
31
|
-
quote:
|
|
32
|
-
deep:
|
|
30
|
+
base: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
31
|
+
quote: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
32
|
+
deep: _mysten_sui_bcs44.BcsType<string, string | number | bigint, "u64">;
|
|
33
33
|
}, "@deepbook/core::balances::Balances">;
|
|
34
34
|
}, "@deepbook/core::account::Account">;
|
|
35
35
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account.d.mts","names":[],"sources":["../../../src/contracts/deepbook/account.ts"],"mappings":";;;;;cAYa,OAAA,EAAO,UAAA;SAelB,
|
|
1
|
+
{"version":3,"file":"account.d.mts","names":[],"sources":["../../../src/contracts/deepbook/account.ts"],"mappings":";;;;;cAYa,OAAA,EAAO,UAAA;SAelB,iBAAA,CAAA,OAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_bcs61 from "@mysten/sui/bcs";
|
|
3
3
|
|
|
4
4
|
//#region src/contracts/deepbook/balances.d.ts
|
|
5
5
|
declare const Balances: MoveStruct<{
|
|
6
|
-
base:
|
|
7
|
-
quote:
|
|
8
|
-
deep:
|
|
6
|
+
base: _mysten_sui_bcs61.BcsType<string, string | number | bigint, "u64">;
|
|
7
|
+
quote: _mysten_sui_bcs61.BcsType<string, string | number | bigint, "u64">;
|
|
8
|
+
deep: _mysten_sui_bcs61.BcsType<string, string | number | bigint, "u64">;
|
|
9
9
|
}, "@deepbook/core::balances::Balances">;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { Balances };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_bcs0 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:
|
|
8
|
-
deep_per_asset:
|
|
7
|
+
asset_is_base: _mysten_sui_bcs0.BcsType<boolean, boolean, "bool">;
|
|
8
|
+
deep_per_asset: _mysten_sui_bcs0.BcsType<string, string | number | bigint, "u64">;
|
|
9
9
|
}, "@deepbook/core::deep_price::OrderDeepPrice">;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { OrderDeepPrice };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deep_price.d.mts","names":[],"sources":["../../../src/contracts/deepbook/deep_price.ts"],"mappings":";;;;;cAuCa,cAAA,EAAc,UAAA;iBAMzB,
|
|
1
|
+
{"version":3,"file":"deep_price.d.mts","names":[],"sources":["../../../src/contracts/deepbook/deep_price.ts"],"mappings":";;;;;cAuCa,cAAA,EAAc,UAAA;iBAMzB,gBAAA,CAAA,OAAA"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { MoveStruct } from "../utils/index.mjs";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _mysten_sui_bcs12 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:
|
|
8
|
-
order_id:
|
|
9
|
-
client_order_id:
|
|
10
|
-
quantity:
|
|
11
|
-
filled_quantity:
|
|
12
|
-
fee_is_deep:
|
|
7
|
+
balance_manager_id: _mysten_sui_bcs12.BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
|
|
8
|
+
order_id: _mysten_sui_bcs12.BcsType<string, string | number | bigint, "u128">;
|
|
9
|
+
client_order_id: _mysten_sui_bcs12.BcsType<string, string | number | bigint, "u64">;
|
|
10
|
+
quantity: _mysten_sui_bcs12.BcsType<string, string | number | bigint, "u64">;
|
|
11
|
+
filled_quantity: _mysten_sui_bcs12.BcsType<string, string | number | bigint, "u64">;
|
|
12
|
+
fee_is_deep: _mysten_sui_bcs12.BcsType<boolean, boolean, "bool">;
|
|
13
13
|
order_deep_price: MoveStruct<{
|
|
14
|
-
asset_is_base:
|
|
15
|
-
deep_per_asset:
|
|
14
|
+
asset_is_base: _mysten_sui_bcs12.BcsType<boolean, boolean, "bool">;
|
|
15
|
+
deep_per_asset: _mysten_sui_bcs12.BcsType<string, string | number | bigint, "u64">;
|
|
16
16
|
}, "@deepbook/core::deep_price::OrderDeepPrice">;
|
|
17
|
-
epoch:
|
|
18
|
-
status:
|
|
19
|
-
expire_timestamp:
|
|
17
|
+
epoch: _mysten_sui_bcs12.BcsType<string, string | number | bigint, "u64">;
|
|
18
|
+
status: _mysten_sui_bcs12.BcsType<number, number, "u8">;
|
|
19
|
+
expire_timestamp: _mysten_sui_bcs12.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
|
//#endregion
|
|
110
139
|
export { DeepBookAdminContract };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deepbookAdmin.d.mts","names":[],"sources":["../../src/transactions/deepbookAdmin.ts"],"mappings":";;;;;;;;;cAaa,qBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAuD4B;;;;;EAlChD,eAAA,GAAmB,MAAA,EAAQ,qBAAA,MAA2B,EAAA,EAAI,WAAA;EAwIP;;;;;EAtGnD,mBAAA,GAAuB,OAAA,cAAqB,EAAA,EAAI,WAAA;EA0Na;;;;;EAtM7D,qBAAA,GAAyB,OAAA,cAAqB,EAAA,EAAI,WAAA
|
|
1
|
+
{"version":3,"file":"deepbookAdmin.d.mts","names":[],"sources":["../../src/transactions/deepbookAdmin.ts"],"mappings":";;;;;;;;;cAaa,qBAAA;EAAA;;;;cAMA,MAAA,EAAQ,cAAA;EAuD4B;;;;;EAlChD,eAAA,GAAmB,MAAA,EAAQ,qBAAA,MAA2B,EAAA,EAAI,WAAA;EAwIP;;;;;EAtGnD,mBAAA,GAAuB,OAAA,cAAqB,EAAA,EAAI,WAAA;EA0Na;;;;;EAtM7D,qBAAA,GAAyB,OAAA,cAAqB,EAAA,EAAI,WAAA;EAkQA;;;;;EA9OlD,aAAA,GAAiB,OAAA,cAAqB,EAAA,EAAI,WAAA;;;;;;EAgB1C,cAAA,GAAkB,OAAA,cAAqB,EAAA,EAAI,WAAA;EA1FxB;;;;;EA0GnB,kBAAA,GAAsB,eAAA,cAA6B,EAAA,EAAI,WAAA;EAxEX;;;;;EAwF5C,aAAA,GAAiB,aAAA,cAA2B,EAAA,EAAI,WAAA;EAhD/B;;;;;EA8DjB,gBAAA,GAAoB,aAAA,cAA2B,EAAA,EAAI,WAAA;EA9CZ;;;;;;EA6DvC,cAAA,GAAkB,OAAA,UAAiB,WAAA,cAAyB,EAAA,EAAI,WAAA;EA7BhB;;;;;;;EA2DhD,gBAAA,GACE,OAAA,UAAiB,UAAA,UAAoB,UAAA,cAAwB,EAAA,EAAI,WAAA;EA/BhC;;;;EA2DnC,qBAAA,SAA+B,EAAA,EAAI,WAAA;EA5BhB;;;;;;EAyCnB,aAAA,GAAiB,OAAA,UAAiB,MAAA,EAAQ,aAAA,MAAmB,EAAA,EAAI,WAAA;EAAjE;;;;;;EA6BA,eAAA,GAAmB,OAAA,UAAiB,MAAA,eAAqB,EAAA,EAAI,WAAA;EAA1C;;;;EAqBnB,kBAAA,SAA4B,EAAA,EAAI,WAAA;EAAA;;;;EAYhC,oBAAA,SAA8B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAAA;;;;;;;EAe7C,gBAAA,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.
|
|
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.
|
|
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"],"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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Y,MAAKA,OAAQ,QAAQ,KAAK,UAAU;AAEtD,MAAG,SAAS;IACX,QAAQ,GAAG,MAAKA,OAAQ,oBAAoB;IAC5C,WAAW;KACV,GAAG,OAAO,KAAK,QAAQ;KACvB,GAAG,OAAO,MAAKC,UAAW,CAAC;KAC3B,GAAG,KAAK,KAAK,OAAO;KACpB,GAAG,OAAO,OAAO;KACjB;IACD,eAAe,CAAC,SAAS,MAAM,UAAU,KAAK;IAC9C,CAAC;;mCAOyB,OAAoB;AAC/C,MAAG,SAAS;IACX,QAAQ,GAAG,MAAKD,OAAQ,oBAAoB;IAC5C,WAAW,CAAC,GAAG,OAAO,MAAKA,OAAQ,YAAY,EAAE,GAAG,OAAO,MAAKC,UAAW,CAAC,CAAC;IAC7E,eAAe,CAAC,GAAG,MAAKD,OAAQ,kBAAkB,6BAA6B;IAC/E,CAAC;;qCAO2B,OAAoB;AACjD,UAAO,GAAG,SAAS;IAClB,QAAQ,GAAG,MAAKA,OAAQ,oBAAoB;IAC5C,WAAW,CAAC,GAAG,OAAO,MAAKA,OAAQ,YAAY,EAAE,GAAG,OAAO,MAAKC,UAAW,CAAC,CAAC;IAC7E,eAAe,CAAC,GAAG,MAAKD,OAAQ,kBAAkB,6BAA6B;IAC/E,CAAC;;AAtTF,QAAKA,SAAU;;;;;;CAOhB,YAAY;EACX,MAAM,WAAW,MAAKA,OAAQ;AAC9B,MAAI,CAAC,SACJ,OAAM,IAAI,MAAM,yCAAyC;AAE1D,SAAO"}
|
|
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_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;GAEpD,MAAM,aAAa,SAAS;GAC5B,MAAM,cAAc,UAAU;GAE9B,MAAM,mBAAmB,aAAa,UAAU,cAAc,aAAa,WAAW;GACtF,MAAM,kBAAkB,gBAAgB,SAAS,WAAW;GAC5D,MAAM,kBAAkB,gBAAgB,SAAS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A,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
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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) =>
|
|
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,mBAAA;EAAA;EAMQ;;;cAAR,MAAA,EAAQ,cAAA;EAsDW;;;;EAlC/B,iBAAA,SAA2B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAmGoC;;;;EApF9E,mBAAA,GAAuB,eAAA,cAA6B,EAAA,EAAI,WAAA;
|
|
1
|
+
{"version":3,"file":"marginAdmin.d.mts","names":[],"sources":["../../src/transactions/marginAdmin.ts"],"mappings":";;;;;;;;AAeA;cAAa,mBAAA;EAAA;EAMQ;;;cAAR,MAAA,EAAQ,cAAA;EAsDW;;;;EAlC/B,iBAAA,SAA2B,EAAA,EAAI,WAAA,KAAW,0BAAA,CAAA,iBAAA;EAmGoC;;;;EApF9E,mBAAA,GAAuB,eAAA,cAA6B,EAAA,EAAI,WAAA;EA0LN;;;;;;EAxKlD,oBAAA,GACE,OAAA,UAAiB,UAAA,EAAY,mBAAA,MAAyB,EAAA,EAAI,WAAA;EAuQY;;;;;EAjPxE,kBAAA,GAAsB,OAAA,cAAqB,EAAA,EAAI,WAAA;EA6TrB;;;;;EAxS1B,mBAAA,GAAuB,OAAA,cAAqB,EAAA,EAAI,WAAA;EA2VwB;;;;;;EArUxE,gBAAA,GAAoB,OAAA,UAAiB,UAAA,EAAY,mBAAA,MAAyB,EAAA,EAAI,WAAA;EAnG/C;;;;;;;;;;EA8H/B,iBAAA,GAAqB,OAAA,UAAiB,SAAA,uBAAgC,EAAA,EAAI,WAAA;EA5Fd;;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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`,
|