@mysten/deepbook-v3 1.6.7 → 2.0.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 +69 -0
- package/dist/_virtual/rolldown_runtime.mjs +18 -0
- package/dist/client.d.mts +9 -6
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +3 -2
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/deepbook/account.d.mts +18 -18
- package/dist/contracts/deepbook/account.d.mts.map +1 -1
- package/dist/contracts/deepbook/balance_manager.mjs.map +1 -1
- package/dist/contracts/deepbook/balances.d.mts +4 -4
- package/dist/contracts/deepbook/balances.d.mts.map +1 -1
- package/dist/contracts/deepbook/deep_price.d.mts +3 -3
- package/dist/contracts/deepbook/deep_price.d.mts.map +1 -1
- package/dist/contracts/deepbook/order.d.mts +12 -12
- package/dist/contracts/deepbook/pool.mjs.map +1 -1
- package/dist/contracts/deepbook/registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager.mjs +1 -319
- package/dist/contracts/deepbook_margin/margin_manager.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs +386 -0
- package/dist/contracts/deepbook_margin/margin_manager_upgraded.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/margin_pool.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/margin_registry.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/oracle.mjs +9 -0
- package/dist/contracts/deepbook_margin/oracle.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/pool_proxy.mjs +1 -383
- package/dist/contracts/deepbook_margin/pool_proxy.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/pool_proxy_upgraded.mjs +340 -0
- package/dist/contracts/deepbook_margin/pool_proxy_upgraded.mjs.map +1 -0
- package/dist/contracts/deepbook_margin/protocol_config.mjs.map +1 -1
- package/dist/contracts/deepbook_margin/tpsl.mjs.map +1 -1
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs +33 -17
- package/dist/contracts/margin_liquidation/liquidation_vault.mjs.map +1 -1
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +2 -2
- package/dist/pyth/PriceServiceConnection.d.mts +18 -3
- package/dist/pyth/PriceServiceConnection.d.mts.map +1 -1
- package/dist/pyth/PriceServiceConnection.mjs +35 -4
- package/dist/pyth/PriceServiceConnection.mjs.map +1 -1
- package/dist/queries/priceFeedQueries.mjs +50 -18
- package/dist/queries/priceFeedQueries.mjs.map +1 -1
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/deepbook.d.mts +20 -20
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/marginAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.mjs +2 -2
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.mjs +19 -7
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginManager.d.mts +32 -32
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +43 -34
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts +18 -18
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +19 -10
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts +8 -8
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +34 -27
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/types/index.d.mts +16 -1
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/config.d.mts +30 -10
- package/dist/utils/config.d.mts.map +1 -1
- package/dist/utils/config.mjs +33 -4
- package/dist/utils/config.mjs.map +1 -1
- package/dist/utils/constants.d.mts +32 -1
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +55 -24
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +10 -10
- package/src/client.ts +9 -1
- package/src/contracts/deepbook/balance_manager.ts +1 -2
- package/src/contracts/deepbook/pool.ts +12 -24
- package/src/contracts/deepbook/registry.ts +1 -2
- package/src/contracts/deepbook_margin/margin_manager.ts +149 -28
- package/src/contracts/deepbook_margin/margin_manager_upgraded.ts +646 -0
- package/src/contracts/deepbook_margin/margin_pool.ts +2 -4
- package/src/contracts/deepbook_margin/margin_registry.ts +3 -6
- package/src/contracts/deepbook_margin/oracle.ts +59 -0
- package/src/contracts/deepbook_margin/pool_proxy.ts +597 -584
- package/src/contracts/deepbook_margin/pool_proxy_upgraded.ts +614 -0
- package/src/contracts/deepbook_margin/protocol_config.ts +1 -2
- package/src/contracts/deepbook_margin/tpsl.ts +1 -2
- package/src/contracts/margin_liquidation/liquidation_vault.ts +144 -4
- package/src/contracts/pyth/pyth.ts +2 -4
- package/src/index.ts +4 -0
- package/src/pyth/PriceServiceConnection.ts +69 -8
- package/src/queries/priceFeedQueries.ts +74 -24
- package/src/transactions/marginAdmin.ts +2 -4
- package/src/transactions/marginLiquidations.ts +20 -6
- package/src/transactions/marginManager.ts +43 -33
- package/src/transactions/marginTPSL.ts +19 -9
- package/src/transactions/poolProxy.ts +34 -30
- package/src/types/index.ts +17 -2
- package/src/utils/config.ts +69 -9
- package/src/utils/constants.ts +83 -26
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@mysten/deepbook-v3",
|
|
3
3
|
"author": "Mysten Labs <build@mystenlabs.com>",
|
|
4
4
|
"description": "Sui Deepbook SDK",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "2.0.1",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/index.mjs",
|
|
@@ -30,25 +30,25 @@
|
|
|
30
30
|
"url": "https://github.com/MystenLabs/ts-sdks/issues/new"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@noble/hashes": "^2.
|
|
34
|
-
"axios": "^1.
|
|
33
|
+
"@noble/hashes": "^2.3.0",
|
|
34
|
+
"axios": "^1.19.0",
|
|
35
35
|
"axios-retry": "^4.5.0",
|
|
36
|
-
"@mysten/bcs": "^2.1.
|
|
36
|
+
"@mysten/bcs": "^2.1.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@iarna/toml": "^2.2.5",
|
|
40
|
-
"@types/node": "^
|
|
40
|
+
"@types/node": "^26.2.0",
|
|
41
41
|
"dotenv": "^17.4.2",
|
|
42
42
|
"tmp": "^0.2.7",
|
|
43
43
|
"ts-node": "^10.9.2",
|
|
44
44
|
"ts-retry-promise": "^0.8.1",
|
|
45
|
-
"typescript": "^
|
|
46
|
-
"vite": "^8.
|
|
47
|
-
"vitest": "^4.1.
|
|
48
|
-
"wait-on": "^9.0
|
|
45
|
+
"typescript": "^7.0.2",
|
|
46
|
+
"vite": "^8.2.1",
|
|
47
|
+
"vitest": "^4.1.10",
|
|
48
|
+
"wait-on": "^9.1.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
|
-
"@mysten/sui": "^2.26.
|
|
51
|
+
"@mysten/sui": "^2.26.2"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
package/src/client.ts
CHANGED
|
@@ -51,6 +51,7 @@ import type {
|
|
|
51
51
|
PoolBookParams,
|
|
52
52
|
PoolDeepPrice,
|
|
53
53
|
PoolTradeParams,
|
|
54
|
+
PythConfig,
|
|
54
55
|
QuantityOut,
|
|
55
56
|
QuoteQuantityIn,
|
|
56
57
|
QuoteQuantityOut,
|
|
@@ -73,7 +74,12 @@ export interface DeepBookOptions<Name = 'deepbook'> {
|
|
|
73
74
|
marginAdminCap?: string;
|
|
74
75
|
marginMaintainerCap?: string;
|
|
75
76
|
packageIds?: DeepbookPackageIds;
|
|
76
|
-
pyth?:
|
|
77
|
+
pyth?: PythConfig;
|
|
78
|
+
/**
|
|
79
|
+
* Bearer token for the Hermes serving Pyth's upgraded Core. Matches the option of the
|
|
80
|
+
* same name in `@mysten/suins`, which takes the same credential.
|
|
81
|
+
*/
|
|
82
|
+
pythAccessToken?: string;
|
|
77
83
|
name?: Name;
|
|
78
84
|
}
|
|
79
85
|
|
|
@@ -144,6 +150,7 @@ export class DeepBookClient {
|
|
|
144
150
|
marginMaintainerCap,
|
|
145
151
|
packageIds,
|
|
146
152
|
pyth,
|
|
153
|
+
pythAccessToken,
|
|
147
154
|
}: DeepBookClientOptions) {
|
|
148
155
|
const normalizedAddress = normalizeSuiAddress(address);
|
|
149
156
|
const config = new DeepBookConfig({
|
|
@@ -158,6 +165,7 @@ export class DeepBookClient {
|
|
|
158
165
|
marginMaintainerCap,
|
|
159
166
|
packageIds,
|
|
160
167
|
pyth,
|
|
168
|
+
pythAccessToken,
|
|
161
169
|
});
|
|
162
170
|
|
|
163
171
|
this.balanceManager = new BalanceManagerContract(config);
|
|
@@ -239,8 +239,7 @@ export function newWithCustomOwnerCapsV2<App extends BcsType<any>>(
|
|
|
239
239
|
) {
|
|
240
240
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
241
241
|
const argumentsTypes = [`${options.typeArguments[0]}`, null, 'address'] satisfies (
|
|
242
|
-
|
|
|
243
|
-
| null
|
|
242
|
+
string | null
|
|
244
243
|
)[];
|
|
245
244
|
const parameterNames = ['Witness', 'deepbookRegistry', 'owner'];
|
|
246
245
|
return (tx: Transaction) =>
|
|
@@ -573,8 +573,7 @@ export interface SwapExactQuantityOptions {
|
|
|
573
573
|
export function swapExactQuantity(options: SwapExactQuantityOptions) {
|
|
574
574
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
575
575
|
const argumentsTypes = [null, null, null, null, 'u64', '0x2::clock::Clock'] satisfies (
|
|
576
|
-
|
|
|
577
|
-
| null
|
|
576
|
+
string | null
|
|
578
577
|
)[];
|
|
579
578
|
const parameterNames = ['self', 'baseIn', 'quoteIn', 'deepIn', 'minOut'];
|
|
580
579
|
return (tx: Transaction) =>
|
|
@@ -676,8 +675,7 @@ export interface ModifyOrderOptions {
|
|
|
676
675
|
export function modifyOrder(options: ModifyOrderOptions) {
|
|
677
676
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
678
677
|
const argumentsTypes = [null, null, null, 'u128', 'u64', '0x2::clock::Clock'] satisfies (
|
|
679
|
-
|
|
|
680
|
-
| null
|
|
678
|
+
string | null
|
|
681
679
|
)[];
|
|
682
680
|
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderId', 'newQuantity'];
|
|
683
681
|
return (tx: Transaction) =>
|
|
@@ -716,8 +714,7 @@ export interface CancelOrderOptions {
|
|
|
716
714
|
export function cancelOrder(options: CancelOrderOptions) {
|
|
717
715
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
718
716
|
const argumentsTypes = [null, null, null, 'u128', '0x2::clock::Clock'] satisfies (
|
|
719
|
-
|
|
|
720
|
-
| null
|
|
717
|
+
string | null
|
|
721
718
|
)[];
|
|
722
719
|
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderId'];
|
|
723
720
|
return (tx: Transaction) =>
|
|
@@ -756,8 +753,7 @@ export interface CancelOrdersOptions {
|
|
|
756
753
|
export function cancelOrders(options: CancelOrdersOptions) {
|
|
757
754
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
758
755
|
const argumentsTypes = [null, null, null, 'vector<u128>', '0x2::clock::Clock'] satisfies (
|
|
759
|
-
|
|
|
760
|
-
| null
|
|
756
|
+
string | null
|
|
761
757
|
)[];
|
|
762
758
|
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderIds'];
|
|
763
759
|
return (tx: Transaction) =>
|
|
@@ -797,8 +793,7 @@ export interface CancelLiveOrderOptions {
|
|
|
797
793
|
export function cancelLiveOrder(options: CancelLiveOrderOptions) {
|
|
798
794
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
799
795
|
const argumentsTypes = [null, null, null, 'u128', '0x2::clock::Clock'] satisfies (
|
|
800
|
-
|
|
|
801
|
-
| null
|
|
796
|
+
string | null
|
|
802
797
|
)[];
|
|
803
798
|
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderId'];
|
|
804
799
|
return (tx: Transaction) =>
|
|
@@ -839,8 +834,7 @@ export interface CancelLiveOrdersOptions {
|
|
|
839
834
|
export function cancelLiveOrders(options: CancelLiveOrdersOptions) {
|
|
840
835
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
841
836
|
const argumentsTypes = [null, null, null, 'vector<u128>', '0x2::clock::Clock'] satisfies (
|
|
842
|
-
|
|
|
843
|
-
| null
|
|
837
|
+
string | null
|
|
844
838
|
)[];
|
|
845
839
|
const parameterNames = ['self', 'balanceManager', 'tradeProof', 'orderIds'];
|
|
846
840
|
return (tx: Transaction) =>
|
|
@@ -1495,8 +1489,7 @@ export interface CreatePoolAdminOptions {
|
|
|
1495
1489
|
export function createPoolAdmin(options: CreatePoolAdminOptions) {
|
|
1496
1490
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
1497
1491
|
const argumentsTypes = [null, 'u64', 'u64', 'u64', 'bool', 'bool', null] satisfies (
|
|
1498
|
-
|
|
|
1499
|
-
| null
|
|
1492
|
+
string | null
|
|
1500
1493
|
)[];
|
|
1501
1494
|
const parameterNames = [
|
|
1502
1495
|
'registry',
|
|
@@ -1663,8 +1656,7 @@ export interface AdjustMinLotSizeAdminOptions {
|
|
|
1663
1656
|
export function adjustMinLotSizeAdmin(options: AdjustMinLotSizeAdminOptions) {
|
|
1664
1657
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
1665
1658
|
const argumentsTypes = [null, 'u64', 'u64', null, '0x2::clock::Clock'] satisfies (
|
|
1666
|
-
|
|
|
1667
|
-
| null
|
|
1659
|
+
string | null
|
|
1668
1660
|
)[];
|
|
1669
1661
|
const parameterNames = ['self', 'newLotSize', 'newMinSize', 'Cap'];
|
|
1670
1662
|
return (tx: Transaction) =>
|
|
@@ -1733,8 +1725,7 @@ export interface SetEwmaParamsOptions {
|
|
|
1733
1725
|
export function setEwmaParams(options: SetEwmaParamsOptions) {
|
|
1734
1726
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
1735
1727
|
const argumentsTypes = [null, null, 'u64', 'u64', 'u64', '0x2::clock::Clock'] satisfies (
|
|
1736
|
-
|
|
|
1737
|
-
| null
|
|
1728
|
+
string | null
|
|
1738
1729
|
)[];
|
|
1739
1730
|
const parameterNames = ['self', 'Cap', 'alpha', 'zScoreThreshold', 'additionalTakerFee'];
|
|
1740
1731
|
return (tx: Transaction) =>
|
|
@@ -2194,8 +2185,7 @@ export interface GetLevel2RangeOptions {
|
|
|
2194
2185
|
export function getLevel2Range(options: GetLevel2RangeOptions) {
|
|
2195
2186
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
2196
2187
|
const argumentsTypes = [null, 'u64', 'u64', 'bool', '0x2::clock::Clock'] satisfies (
|
|
2197
|
-
|
|
|
2198
|
-
| null
|
|
2188
|
+
string | null
|
|
2199
2189
|
)[];
|
|
2200
2190
|
const parameterNames = ['self', 'priceLow', 'priceHigh', 'isBid'];
|
|
2201
2191
|
return (tx: Transaction) =>
|
|
@@ -2532,8 +2522,7 @@ export interface CanPlaceMarketOrderOptions {
|
|
|
2532
2522
|
export function canPlaceMarketOrder(options: CanPlaceMarketOrderOptions) {
|
|
2533
2523
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
2534
2524
|
const argumentsTypes = [null, null, 'u64', 'bool', 'bool', '0x2::clock::Clock'] satisfies (
|
|
2535
|
-
|
|
|
2536
|
-
| null
|
|
2525
|
+
string | null
|
|
2537
2526
|
)[];
|
|
2538
2527
|
const parameterNames = ['self', 'balanceManager', 'quantity', 'isBid', 'payWithDeep'];
|
|
2539
2528
|
return (tx: Transaction) =>
|
|
@@ -2598,8 +2587,7 @@ export interface CheckLimitOrderParamsOptions {
|
|
|
2598
2587
|
export function checkLimitOrderParams(options: CheckLimitOrderParamsOptions) {
|
|
2599
2588
|
const packageAddress = options.package ?? '@deepbook/core';
|
|
2600
2589
|
const argumentsTypes = [null, 'u64', 'u64', 'u64', '0x2::clock::Clock'] satisfies (
|
|
2601
|
-
|
|
|
2602
|
-
| null
|
|
2590
|
+
string | null
|
|
2603
2591
|
)[];
|
|
2604
2592
|
const parameterNames = ['self', 'price', 'quantity', 'expireTimestamp'];
|
|
2605
2593
|
return (tx: Transaction) =>
|
|
@@ -470,8 +470,7 @@ export interface IsStablecoinArguments {
|
|
|
470
470
|
export interface IsStablecoinOptions {
|
|
471
471
|
package?: string;
|
|
472
472
|
arguments:
|
|
473
|
-
|
|
|
474
|
-
| [self: RawTransactionArgument<string>, stableType: TransactionArgument];
|
|
473
|
+
IsStablecoinArguments | [self: RawTransactionArgument<string>, stableType: TransactionArgument];
|
|
475
474
|
}
|
|
476
475
|
/** Returns whether the given coin is whitelisted */
|
|
477
476
|
export function isStablecoin(options: IsStablecoinOptions) {
|
|
@@ -155,7 +155,8 @@ export interface AddConditionalOrderOptions {
|
|
|
155
155
|
* _limit_ pending order is intentionally transient — when it triggers, the resting
|
|
156
156
|
* order it places is clamped to `max_order_ttl_ms` (default 3 days) by
|
|
157
157
|
* `clamp_expire_timestamp`, the same stale-price guard as any margin limit order.
|
|
158
|
-
* For a permanent stop, use a market pending order.
|
|
158
|
+
* For a permanent stop, use a market pending order. Twin:
|
|
159
|
+
* `margin_manager_upgraded::add_conditional_order`. Edit both.
|
|
159
160
|
*/
|
|
160
161
|
export function addConditionalOrder(options: AddConditionalOrderOptions) {
|
|
161
162
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -273,8 +274,7 @@ export interface ExecuteConditionalOrdersOptions {
|
|
|
273
274
|
export function executeConditionalOrders(options: ExecuteConditionalOrdersOptions) {
|
|
274
275
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
275
276
|
const argumentsTypes = [null, null, null, null, null, 'u64', '0x2::clock::Clock'] satisfies (
|
|
276
|
-
|
|
|
277
|
-
| null
|
|
277
|
+
string | null
|
|
278
278
|
)[];
|
|
279
279
|
const parameterNames = [
|
|
280
280
|
'Self',
|
|
@@ -326,7 +326,8 @@ export interface ExecuteConditionalOrdersV2Options {
|
|
|
326
326
|
* v2 adds `base_margin_pool` + `quote_margin_pool` parameters and enforces a
|
|
327
327
|
* post-fill `risk_ratio >= min_borrow_risk_ratio` invariant inside the inner loop.
|
|
328
328
|
* If any single triggered fill would breach that floor, the entire txn aborts — no
|
|
329
|
-
* partial-state landing.
|
|
329
|
+
* partial-state landing. Twin:
|
|
330
|
+
* `margin_manager_upgraded::execute_conditional_orders_v2`. Edit both.
|
|
330
331
|
*/
|
|
331
332
|
export function executeConditionalOrdersV2(options: ExecuteConditionalOrdersV2Options) {
|
|
332
333
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -396,7 +397,8 @@ export interface ExecuteConditionalOrdersV3Options {
|
|
|
396
397
|
* This is what lets a stop-loss fire in the `liquidation..min_borrow` danger band:
|
|
397
398
|
* a swap alone only lowers the oracle-valued ratio (so the v2 borrow-floor gate
|
|
398
399
|
* rejects it), while repaying actually improves it. If a single triggered fill
|
|
399
|
-
* would worsen net solvency the whole txn aborts — no partial-state landing.
|
|
400
|
+
* would worsen net solvency the whole txn aborts — no partial-state landing. Twin:
|
|
401
|
+
* `margin_manager_upgraded::execute_conditional_orders_v3`. Edit both.
|
|
400
402
|
*/
|
|
401
403
|
export function executeConditionalOrdersV3(options: ExecuteConditionalOrdersV3Options) {
|
|
402
404
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -500,8 +502,7 @@ export interface ShareArguments {
|
|
|
500
502
|
export interface ShareOptions {
|
|
501
503
|
package?: string;
|
|
502
504
|
arguments:
|
|
503
|
-
|
|
|
504
|
-
| [manager: RawTransactionArgument<string>, initializer: TransactionArgument];
|
|
505
|
+
ShareArguments | [manager: RawTransactionArgument<string>, initializer: TransactionArgument];
|
|
505
506
|
typeArguments: [string, string];
|
|
506
507
|
}
|
|
507
508
|
/** Shares the margin manager. The initializer is dropped in the process. */
|
|
@@ -618,6 +619,60 @@ export function unsetMarginManagerReferral(options: UnsetMarginManagerReferralOp
|
|
|
618
619
|
typeArguments: options.typeArguments,
|
|
619
620
|
});
|
|
620
621
|
}
|
|
622
|
+
export interface SetReferralArguments {
|
|
623
|
+
Self: RawTransactionArgument<string>;
|
|
624
|
+
ReferralCap: RawTransactionArgument<string>;
|
|
625
|
+
}
|
|
626
|
+
export interface SetReferralOptions {
|
|
627
|
+
package?: string;
|
|
628
|
+
arguments:
|
|
629
|
+
| SetReferralArguments
|
|
630
|
+
| [Self: RawTransactionArgument<string>, ReferralCap: RawTransactionArgument<string>];
|
|
631
|
+
typeArguments: [string, string];
|
|
632
|
+
}
|
|
633
|
+
/**
|
|
634
|
+
* Superseded by `set_margin_manager_referral`, which takes a pool-scoped
|
|
635
|
+
* `DeepBookPoolReferral`. Retained as an aborting stub because it is public in the
|
|
636
|
+
* deployed package: a `compatible` upgrade cannot drop a public function.
|
|
637
|
+
*/
|
|
638
|
+
export function setReferral(options: SetReferralOptions) {
|
|
639
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
640
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
641
|
+
const parameterNames = ['Self', 'ReferralCap'];
|
|
642
|
+
return (tx: Transaction) =>
|
|
643
|
+
tx.moveCall({
|
|
644
|
+
package: packageAddress,
|
|
645
|
+
module: 'margin_manager',
|
|
646
|
+
function: 'set_referral',
|
|
647
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
648
|
+
typeArguments: options.typeArguments,
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
export interface UnsetReferralArguments {
|
|
652
|
+
Self: RawTransactionArgument<string>;
|
|
653
|
+
}
|
|
654
|
+
export interface UnsetReferralOptions {
|
|
655
|
+
package?: string;
|
|
656
|
+
arguments: UnsetReferralArguments | [Self: RawTransactionArgument<string>];
|
|
657
|
+
typeArguments: [string, string];
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Superseded by `unset_margin_manager_referral`, which is pool-scoped. Retained as
|
|
661
|
+
* an aborting stub for the same reason as `set_referral`.
|
|
662
|
+
*/
|
|
663
|
+
export function unsetReferral(options: UnsetReferralOptions) {
|
|
664
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
665
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
666
|
+
const parameterNames = ['Self'];
|
|
667
|
+
return (tx: Transaction) =>
|
|
668
|
+
tx.moveCall({
|
|
669
|
+
package: packageAddress,
|
|
670
|
+
module: 'margin_manager',
|
|
671
|
+
function: 'unset_referral',
|
|
672
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
673
|
+
typeArguments: options.typeArguments,
|
|
674
|
+
});
|
|
675
|
+
}
|
|
621
676
|
export interface DepositArguments {
|
|
622
677
|
self: RawTransactionArgument<string>;
|
|
623
678
|
registry: RawTransactionArgument<string>;
|
|
@@ -640,13 +695,13 @@ export interface DepositOptions {
|
|
|
640
695
|
}
|
|
641
696
|
/**
|
|
642
697
|
* Deposit a coin into the margin manager. The coin must be of the same type as
|
|
643
|
-
* either the base, quote, or DEEP.
|
|
698
|
+
* either the base, quote, or DEEP. Twin: `margin_manager_upgraded::deposit`. Edit
|
|
699
|
+
* both.
|
|
644
700
|
*/
|
|
645
701
|
export function deposit(options: DepositOptions) {
|
|
646
702
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
647
703
|
const argumentsTypes = [null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
648
|
-
|
|
|
649
|
-
| null
|
|
704
|
+
string | null
|
|
650
705
|
)[];
|
|
651
706
|
const parameterNames = ['self', 'registry', 'baseOracle', 'quoteOracle', 'coin'];
|
|
652
707
|
return (tx: Transaction) =>
|
|
@@ -687,7 +742,8 @@ export interface WithdrawOptions {
|
|
|
687
742
|
/**
|
|
688
743
|
* Withdraw a specified amount of an asset from the margin manager. The asset must
|
|
689
744
|
* be of the same type as either the base, quote, or DEEP. The withdrawal is
|
|
690
|
-
* subject to the risk ratio limit.
|
|
745
|
+
* subject to the risk ratio limit. Twin: `margin_manager_upgraded::withdraw`. Edit
|
|
746
|
+
* both.
|
|
691
747
|
*/
|
|
692
748
|
export function withdraw(options: WithdrawOptions) {
|
|
693
749
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -745,7 +801,10 @@ export interface BorrowBaseOptions {
|
|
|
745
801
|
];
|
|
746
802
|
typeArguments: [string, string];
|
|
747
803
|
}
|
|
748
|
-
/**
|
|
804
|
+
/**
|
|
805
|
+
* Borrow the base asset using the margin manager. Twin:
|
|
806
|
+
* `margin_manager_upgraded::borrow_base`. Edit both.
|
|
807
|
+
*/
|
|
749
808
|
export function borrowBase(options: BorrowBaseOptions) {
|
|
750
809
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
751
810
|
const argumentsTypes = [
|
|
@@ -800,7 +859,10 @@ export interface BorrowQuoteOptions {
|
|
|
800
859
|
];
|
|
801
860
|
typeArguments: [string, string];
|
|
802
861
|
}
|
|
803
|
-
/**
|
|
862
|
+
/**
|
|
863
|
+
* Borrow the quote asset using the margin manager. Twin:
|
|
864
|
+
* `margin_manager_upgraded::borrow_quote`. Edit both.
|
|
865
|
+
*/
|
|
804
866
|
export function borrowQuote(options: BorrowQuoteOptions) {
|
|
805
867
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
806
868
|
const argumentsTypes = [
|
|
@@ -937,11 +999,11 @@ export interface LiquidateOptions {
|
|
|
937
999
|
];
|
|
938
1000
|
typeArguments: [string, string, string];
|
|
939
1001
|
}
|
|
1002
|
+
/** Twin: `margin_manager_upgraded::liquidate`. Edit both. */
|
|
940
1003
|
export function liquidate(options: LiquidateOptions) {
|
|
941
1004
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
942
1005
|
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
943
|
-
|
|
|
944
|
-
| null
|
|
1006
|
+
string | null
|
|
945
1007
|
)[];
|
|
946
1008
|
const parameterNames = [
|
|
947
1009
|
'self',
|
|
@@ -985,11 +1047,11 @@ export interface RiskRatioOptions {
|
|
|
985
1047
|
];
|
|
986
1048
|
typeArguments: [string, string];
|
|
987
1049
|
}
|
|
1050
|
+
/** Twin: `margin_manager_upgraded::risk_ratio`. Edit both. */
|
|
988
1051
|
export function riskRatio(options: RiskRatioOptions) {
|
|
989
1052
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
990
1053
|
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
991
|
-
|
|
|
992
|
-
| null
|
|
1054
|
+
string | null
|
|
993
1055
|
)[];
|
|
994
1056
|
const parameterNames = [
|
|
995
1057
|
'self',
|
|
@@ -1034,14 +1096,15 @@ export interface RiskRatioUnsafeOptions {
|
|
|
1034
1096
|
typeArguments: [string, string];
|
|
1035
1097
|
}
|
|
1036
1098
|
/**
|
|
1037
|
-
* Returns the risk ratio without validating
|
|
1038
|
-
* Use for read-only queries where stale
|
|
1099
|
+
* Returns the risk ratio without validating staleness, EWMA divergence or
|
|
1100
|
+
* confidence - only the feed id is checked. Use for read-only queries where stale
|
|
1101
|
+
* prices are acceptable. Twin: `margin_manager_upgraded::risk_ratio_unsafe`. Edit
|
|
1102
|
+
* both.
|
|
1039
1103
|
*/
|
|
1040
1104
|
export function riskRatioUnsafe(options: RiskRatioUnsafeOptions) {
|
|
1041
1105
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1042
1106
|
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
1043
|
-
|
|
|
1044
|
-
| null
|
|
1107
|
+
string | null
|
|
1045
1108
|
)[];
|
|
1046
1109
|
const parameterNames = [
|
|
1047
1110
|
'self',
|
|
@@ -1223,13 +1286,13 @@ export interface ManagerStateOptions {
|
|
|
1223
1286
|
* (manager_id, deepbook_pool_id, risk_ratio, base_asset, quote_asset, base_debt,
|
|
1224
1287
|
* quote_debt, base_pyth_price, base_pyth_decimals, quote_pyth_price,
|
|
1225
1288
|
* quote_pyth_decimals, current_price, lowest_trigger_above_price,
|
|
1226
|
-
* highest_trigger_below_price)
|
|
1289
|
+
* highest_trigger_below_price) Twin: `margin_manager_upgraded::manager_state`.
|
|
1290
|
+
* Edit both.
|
|
1227
1291
|
*/
|
|
1228
1292
|
export function managerState(options: ManagerStateOptions) {
|
|
1229
1293
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1230
1294
|
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
1231
|
-
|
|
|
1232
|
-
| null
|
|
1295
|
+
string | null
|
|
1233
1296
|
)[];
|
|
1234
1297
|
const parameterNames = [
|
|
1235
1298
|
'self',
|
|
@@ -1249,6 +1312,66 @@ export function managerState(options: ManagerStateOptions) {
|
|
|
1249
1312
|
typeArguments: options.typeArguments,
|
|
1250
1313
|
});
|
|
1251
1314
|
}
|
|
1315
|
+
export interface ManagerStatesArguments {
|
|
1316
|
+
marginManagers: TransactionArgument;
|
|
1317
|
+
registry: RawTransactionArgument<string>;
|
|
1318
|
+
baseOracle: RawTransactionArgument<string>;
|
|
1319
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
1320
|
+
pool: RawTransactionArgument<string>;
|
|
1321
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
1322
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
1323
|
+
}
|
|
1324
|
+
export interface ManagerStatesOptions {
|
|
1325
|
+
package?: string;
|
|
1326
|
+
arguments:
|
|
1327
|
+
| ManagerStatesArguments
|
|
1328
|
+
| [
|
|
1329
|
+
marginManagers: TransactionArgument,
|
|
1330
|
+
registry: RawTransactionArgument<string>,
|
|
1331
|
+
baseOracle: RawTransactionArgument<string>,
|
|
1332
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
1333
|
+
pool: RawTransactionArgument<string>,
|
|
1334
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
1335
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
1336
|
+
];
|
|
1337
|
+
typeArguments: [string, string];
|
|
1338
|
+
}
|
|
1339
|
+
/**
|
|
1340
|
+
* Returns comprehensive state information for multiple margin managers. Same as
|
|
1341
|
+
* manager_state but takes a vector and returns vectors of all values. All managers
|
|
1342
|
+
* must be of the same type. Twin: `margin_manager_upgraded::manager_states`. Edit
|
|
1343
|
+
* both.
|
|
1344
|
+
*/
|
|
1345
|
+
export function managerStates(options: ManagerStatesOptions) {
|
|
1346
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1347
|
+
const argumentsTypes = [
|
|
1348
|
+
'vector<null>',
|
|
1349
|
+
null,
|
|
1350
|
+
null,
|
|
1351
|
+
null,
|
|
1352
|
+
null,
|
|
1353
|
+
null,
|
|
1354
|
+
null,
|
|
1355
|
+
'0x2::clock::Clock',
|
|
1356
|
+
] satisfies (string | null)[];
|
|
1357
|
+
const parameterNames = [
|
|
1358
|
+
'marginManagers',
|
|
1359
|
+
'registry',
|
|
1360
|
+
'baseOracle',
|
|
1361
|
+
'quoteOracle',
|
|
1362
|
+
'pool',
|
|
1363
|
+
'baseMarginPool',
|
|
1364
|
+
'quoteMarginPool',
|
|
1365
|
+
];
|
|
1366
|
+
return (tx: Transaction) =>
|
|
1367
|
+
tx.moveCall({
|
|
1368
|
+
package: packageAddress,
|
|
1369
|
+
module: 'margin_manager',
|
|
1370
|
+
function: 'manager_states',
|
|
1371
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1372
|
+
typeArguments: options.typeArguments,
|
|
1373
|
+
});
|
|
1374
|
+
}
|
|
1252
1375
|
export interface IdArguments {
|
|
1253
1376
|
self: RawTransactionArgument<string>;
|
|
1254
1377
|
}
|
|
@@ -1663,8 +1786,7 @@ export interface AccountArguments {
|
|
|
1663
1786
|
export interface AccountOptions {
|
|
1664
1787
|
package?: string;
|
|
1665
1788
|
arguments:
|
|
1666
|
-
|
|
|
1667
|
-
| [self: RawTransactionArgument<string>, pool: RawTransactionArgument<string>];
|
|
1789
|
+
AccountArguments | [self: RawTransactionArgument<string>, pool: RawTransactionArgument<string>];
|
|
1668
1790
|
typeArguments: [string, string];
|
|
1669
1791
|
}
|
|
1670
1792
|
export function account(options: AccountOptions) {
|
|
@@ -1757,8 +1879,7 @@ export interface CanPlaceMarketOrderOptions {
|
|
|
1757
1879
|
export function canPlaceMarketOrder(options: CanPlaceMarketOrderOptions) {
|
|
1758
1880
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1759
1881
|
const argumentsTypes = [null, null, 'u64', 'bool', 'bool', '0x2::clock::Clock'] satisfies (
|
|
1760
|
-
|
|
|
1761
|
-
| null
|
|
1882
|
+
string | null
|
|
1762
1883
|
)[];
|
|
1763
1884
|
const parameterNames = ['self', 'pool', 'quantity', 'isBid', 'payWithDeep'];
|
|
1764
1885
|
return (tx: Transaction) =>
|