@mysten/deepbook-v3 1.6.6 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +54 -0
- package/dist/_virtual/rolldown_runtime.mjs +18 -0
- package/dist/client.d.mts +11 -8
- 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/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_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/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/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/deepbook.d.mts +20 -20
- package/dist/transactions/deepbookAdmin.d.mts +4 -4
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/marginAdmin.d.mts +7 -7
- package/dist/transactions/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 +3 -3
- 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/marginRegistry.d.mts +16 -16
- package/dist/transactions/marginTPSL.d.mts +10 -10
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +19 -10
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- 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 +54 -23
- package/dist/utils/constants.mjs.map +1 -1
- package/package.json +2 -2
- package/src/client.ts +9 -1
- package/src/contracts/deepbook_margin/margin_manager.ts +140 -10
- package/src/contracts/deepbook_margin/margin_manager_upgraded.ts +651 -0
- package/src/contracts/deepbook_margin/oracle.ts +59 -0
- package/src/contracts/deepbook_margin/pool_proxy.ts +600 -584
- package/src/contracts/deepbook_margin/pool_proxy_upgraded.ts +614 -0
- package/src/contracts/margin_liquidation/liquidation_vault.ts +142 -0
- 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 +16 -0
- package/src/utils/config.ts +69 -9
- package/src/utils/constants.ts +88 -25
|
@@ -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';
|
|
@@ -326,7 +327,8 @@ export interface ExecuteConditionalOrdersV2Options {
|
|
|
326
327
|
* v2 adds `base_margin_pool` + `quote_margin_pool` parameters and enforces a
|
|
327
328
|
* post-fill `risk_ratio >= min_borrow_risk_ratio` invariant inside the inner loop.
|
|
328
329
|
* If any single triggered fill would breach that floor, the entire txn aborts — no
|
|
329
|
-
* partial-state landing.
|
|
330
|
+
* partial-state landing. Twin:
|
|
331
|
+
* `margin_manager_upgraded::execute_conditional_orders_v2`. Edit both.
|
|
330
332
|
*/
|
|
331
333
|
export function executeConditionalOrdersV2(options: ExecuteConditionalOrdersV2Options) {
|
|
332
334
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -396,7 +398,8 @@ export interface ExecuteConditionalOrdersV3Options {
|
|
|
396
398
|
* This is what lets a stop-loss fire in the `liquidation..min_borrow` danger band:
|
|
397
399
|
* a swap alone only lowers the oracle-valued ratio (so the v2 borrow-floor gate
|
|
398
400
|
* 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.
|
|
401
|
+
* would worsen net solvency the whole txn aborts — no partial-state landing. Twin:
|
|
402
|
+
* `margin_manager_upgraded::execute_conditional_orders_v3`. Edit both.
|
|
400
403
|
*/
|
|
401
404
|
export function executeConditionalOrdersV3(options: ExecuteConditionalOrdersV3Options) {
|
|
402
405
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -618,6 +621,60 @@ export function unsetMarginManagerReferral(options: UnsetMarginManagerReferralOp
|
|
|
618
621
|
typeArguments: options.typeArguments,
|
|
619
622
|
});
|
|
620
623
|
}
|
|
624
|
+
export interface SetReferralArguments {
|
|
625
|
+
Self: RawTransactionArgument<string>;
|
|
626
|
+
ReferralCap: RawTransactionArgument<string>;
|
|
627
|
+
}
|
|
628
|
+
export interface SetReferralOptions {
|
|
629
|
+
package?: string;
|
|
630
|
+
arguments:
|
|
631
|
+
| SetReferralArguments
|
|
632
|
+
| [Self: RawTransactionArgument<string>, ReferralCap: RawTransactionArgument<string>];
|
|
633
|
+
typeArguments: [string, string];
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Superseded by `set_margin_manager_referral`, which takes a pool-scoped
|
|
637
|
+
* `DeepBookPoolReferral`. Retained as an aborting stub because it is public in the
|
|
638
|
+
* deployed package: a `compatible` upgrade cannot drop a public function.
|
|
639
|
+
*/
|
|
640
|
+
export function setReferral(options: SetReferralOptions) {
|
|
641
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
642
|
+
const argumentsTypes = [null, null] satisfies (string | null)[];
|
|
643
|
+
const parameterNames = ['Self', 'ReferralCap'];
|
|
644
|
+
return (tx: Transaction) =>
|
|
645
|
+
tx.moveCall({
|
|
646
|
+
package: packageAddress,
|
|
647
|
+
module: 'margin_manager',
|
|
648
|
+
function: 'set_referral',
|
|
649
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
650
|
+
typeArguments: options.typeArguments,
|
|
651
|
+
});
|
|
652
|
+
}
|
|
653
|
+
export interface UnsetReferralArguments {
|
|
654
|
+
Self: RawTransactionArgument<string>;
|
|
655
|
+
}
|
|
656
|
+
export interface UnsetReferralOptions {
|
|
657
|
+
package?: string;
|
|
658
|
+
arguments: UnsetReferralArguments | [Self: RawTransactionArgument<string>];
|
|
659
|
+
typeArguments: [string, string];
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Superseded by `unset_margin_manager_referral`, which is pool-scoped. Retained as
|
|
663
|
+
* an aborting stub for the same reason as `set_referral`.
|
|
664
|
+
*/
|
|
665
|
+
export function unsetReferral(options: UnsetReferralOptions) {
|
|
666
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
667
|
+
const argumentsTypes = [null] satisfies (string | null)[];
|
|
668
|
+
const parameterNames = ['Self'];
|
|
669
|
+
return (tx: Transaction) =>
|
|
670
|
+
tx.moveCall({
|
|
671
|
+
package: packageAddress,
|
|
672
|
+
module: 'margin_manager',
|
|
673
|
+
function: 'unset_referral',
|
|
674
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
675
|
+
typeArguments: options.typeArguments,
|
|
676
|
+
});
|
|
677
|
+
}
|
|
621
678
|
export interface DepositArguments {
|
|
622
679
|
self: RawTransactionArgument<string>;
|
|
623
680
|
registry: RawTransactionArgument<string>;
|
|
@@ -640,7 +697,8 @@ export interface DepositOptions {
|
|
|
640
697
|
}
|
|
641
698
|
/**
|
|
642
699
|
* Deposit a coin into the margin manager. The coin must be of the same type as
|
|
643
|
-
* either the base, quote, or DEEP.
|
|
700
|
+
* either the base, quote, or DEEP. Twin: `margin_manager_upgraded::deposit`. Edit
|
|
701
|
+
* both.
|
|
644
702
|
*/
|
|
645
703
|
export function deposit(options: DepositOptions) {
|
|
646
704
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -687,7 +745,8 @@ export interface WithdrawOptions {
|
|
|
687
745
|
/**
|
|
688
746
|
* Withdraw a specified amount of an asset from the margin manager. The asset must
|
|
689
747
|
* be of the same type as either the base, quote, or DEEP. The withdrawal is
|
|
690
|
-
* subject to the risk ratio limit.
|
|
748
|
+
* subject to the risk ratio limit. Twin: `margin_manager_upgraded::withdraw`. Edit
|
|
749
|
+
* both.
|
|
691
750
|
*/
|
|
692
751
|
export function withdraw(options: WithdrawOptions) {
|
|
693
752
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -745,7 +804,10 @@ export interface BorrowBaseOptions {
|
|
|
745
804
|
];
|
|
746
805
|
typeArguments: [string, string];
|
|
747
806
|
}
|
|
748
|
-
/**
|
|
807
|
+
/**
|
|
808
|
+
* Borrow the base asset using the margin manager. Twin:
|
|
809
|
+
* `margin_manager_upgraded::borrow_base`. Edit both.
|
|
810
|
+
*/
|
|
749
811
|
export function borrowBase(options: BorrowBaseOptions) {
|
|
750
812
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
751
813
|
const argumentsTypes = [
|
|
@@ -800,7 +862,10 @@ export interface BorrowQuoteOptions {
|
|
|
800
862
|
];
|
|
801
863
|
typeArguments: [string, string];
|
|
802
864
|
}
|
|
803
|
-
/**
|
|
865
|
+
/**
|
|
866
|
+
* Borrow the quote asset using the margin manager. Twin:
|
|
867
|
+
* `margin_manager_upgraded::borrow_quote`. Edit both.
|
|
868
|
+
*/
|
|
804
869
|
export function borrowQuote(options: BorrowQuoteOptions) {
|
|
805
870
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
806
871
|
const argumentsTypes = [
|
|
@@ -937,6 +1002,7 @@ export interface LiquidateOptions {
|
|
|
937
1002
|
];
|
|
938
1003
|
typeArguments: [string, string, string];
|
|
939
1004
|
}
|
|
1005
|
+
/** Twin: `margin_manager_upgraded::liquidate`. Edit both. */
|
|
940
1006
|
export function liquidate(options: LiquidateOptions) {
|
|
941
1007
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
942
1008
|
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
@@ -985,6 +1051,7 @@ export interface RiskRatioOptions {
|
|
|
985
1051
|
];
|
|
986
1052
|
typeArguments: [string, string];
|
|
987
1053
|
}
|
|
1054
|
+
/** Twin: `margin_manager_upgraded::risk_ratio`. Edit both. */
|
|
988
1055
|
export function riskRatio(options: RiskRatioOptions) {
|
|
989
1056
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
990
1057
|
const argumentsTypes = [null, null, null, null, null, null, null, '0x2::clock::Clock'] satisfies (
|
|
@@ -1034,8 +1101,10 @@ export interface RiskRatioUnsafeOptions {
|
|
|
1034
1101
|
typeArguments: [string, string];
|
|
1035
1102
|
}
|
|
1036
1103
|
/**
|
|
1037
|
-
* Returns the risk ratio without validating
|
|
1038
|
-
* Use for read-only queries where stale
|
|
1104
|
+
* Returns the risk ratio without validating staleness, EWMA divergence or
|
|
1105
|
+
* confidence - only the feed id is checked. Use for read-only queries where stale
|
|
1106
|
+
* prices are acceptable. Twin: `margin_manager_upgraded::risk_ratio_unsafe`. Edit
|
|
1107
|
+
* both.
|
|
1039
1108
|
*/
|
|
1040
1109
|
export function riskRatioUnsafe(options: RiskRatioUnsafeOptions) {
|
|
1041
1110
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -1223,7 +1292,8 @@ export interface ManagerStateOptions {
|
|
|
1223
1292
|
* (manager_id, deepbook_pool_id, risk_ratio, base_asset, quote_asset, base_debt,
|
|
1224
1293
|
* quote_debt, base_pyth_price, base_pyth_decimals, quote_pyth_price,
|
|
1225
1294
|
* quote_pyth_decimals, current_price, lowest_trigger_above_price,
|
|
1226
|
-
* highest_trigger_below_price)
|
|
1295
|
+
* highest_trigger_below_price) Twin: `margin_manager_upgraded::manager_state`.
|
|
1296
|
+
* Edit both.
|
|
1227
1297
|
*/
|
|
1228
1298
|
export function managerState(options: ManagerStateOptions) {
|
|
1229
1299
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -1249,6 +1319,66 @@ export function managerState(options: ManagerStateOptions) {
|
|
|
1249
1319
|
typeArguments: options.typeArguments,
|
|
1250
1320
|
});
|
|
1251
1321
|
}
|
|
1322
|
+
export interface ManagerStatesArguments {
|
|
1323
|
+
marginManagers: TransactionArgument;
|
|
1324
|
+
registry: RawTransactionArgument<string>;
|
|
1325
|
+
baseOracle: RawTransactionArgument<string>;
|
|
1326
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
1327
|
+
pool: RawTransactionArgument<string>;
|
|
1328
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
1329
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
1330
|
+
}
|
|
1331
|
+
export interface ManagerStatesOptions {
|
|
1332
|
+
package?: string;
|
|
1333
|
+
arguments:
|
|
1334
|
+
| ManagerStatesArguments
|
|
1335
|
+
| [
|
|
1336
|
+
marginManagers: TransactionArgument,
|
|
1337
|
+
registry: RawTransactionArgument<string>,
|
|
1338
|
+
baseOracle: RawTransactionArgument<string>,
|
|
1339
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
1340
|
+
pool: RawTransactionArgument<string>,
|
|
1341
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
1342
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
1343
|
+
];
|
|
1344
|
+
typeArguments: [string, string];
|
|
1345
|
+
}
|
|
1346
|
+
/**
|
|
1347
|
+
* Returns comprehensive state information for multiple margin managers. Same as
|
|
1348
|
+
* manager_state but takes a vector and returns vectors of all values. All managers
|
|
1349
|
+
* must be of the same type. Twin: `margin_manager_upgraded::manager_states`. Edit
|
|
1350
|
+
* both.
|
|
1351
|
+
*/
|
|
1352
|
+
export function managerStates(options: ManagerStatesOptions) {
|
|
1353
|
+
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1354
|
+
const argumentsTypes = [
|
|
1355
|
+
'vector<null>',
|
|
1356
|
+
null,
|
|
1357
|
+
null,
|
|
1358
|
+
null,
|
|
1359
|
+
null,
|
|
1360
|
+
null,
|
|
1361
|
+
null,
|
|
1362
|
+
'0x2::clock::Clock',
|
|
1363
|
+
] satisfies (string | null)[];
|
|
1364
|
+
const parameterNames = [
|
|
1365
|
+
'marginManagers',
|
|
1366
|
+
'registry',
|
|
1367
|
+
'baseOracle',
|
|
1368
|
+
'quoteOracle',
|
|
1369
|
+
'pool',
|
|
1370
|
+
'baseMarginPool',
|
|
1371
|
+
'quoteMarginPool',
|
|
1372
|
+
];
|
|
1373
|
+
return (tx: Transaction) =>
|
|
1374
|
+
tx.moveCall({
|
|
1375
|
+
package: packageAddress,
|
|
1376
|
+
module: 'margin_manager',
|
|
1377
|
+
function: 'manager_states',
|
|
1378
|
+
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1379
|
+
typeArguments: options.typeArguments,
|
|
1380
|
+
});
|
|
1381
|
+
}
|
|
1252
1382
|
export interface IdArguments {
|
|
1253
1383
|
self: RawTransactionArgument<string>;
|
|
1254
1384
|
}
|