@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
|
@@ -23,7 +23,10 @@ export interface UpdateCurrentPriceOptions {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Updates the current price for a pool using safe oracle price calculation. Anyone
|
|
26
|
-
* can call this to update the price oracle used for order validation.
|
|
26
|
+
* can call this to update the price oracle used for order validation. Updates the
|
|
27
|
+
* current price for a pool using safe oracle price calculation. Anyone can call
|
|
28
|
+
* this to update the price oracle used for order validation. Twin:
|
|
29
|
+
* `pool_proxy_upgraded::update_current_price`. Edit both.
|
|
27
30
|
*/
|
|
28
31
|
export function updateCurrentPrice(options: UpdateCurrentPriceOptions) {
|
|
29
32
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
@@ -306,744 +309,351 @@ export function placeReduceOnlyMarketOrder(options: PlaceReduceOnlyMarketOrderOp
|
|
|
306
309
|
typeArguments: options.typeArguments,
|
|
307
310
|
});
|
|
308
311
|
}
|
|
309
|
-
export interface
|
|
312
|
+
export interface ModifyOrderArguments {
|
|
310
313
|
registry: RawTransactionArgument<string>;
|
|
311
314
|
marginManager: RawTransactionArgument<string>;
|
|
312
315
|
pool: RawTransactionArgument<string>;
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
baseOracle: RawTransactionArgument<string>;
|
|
316
|
-
quoteOracle: RawTransactionArgument<string>;
|
|
317
|
-
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
318
|
-
orderType: RawTransactionArgument<number>;
|
|
319
|
-
selfMatchingOption: RawTransactionArgument<number>;
|
|
320
|
-
price: RawTransactionArgument<number | bigint>;
|
|
321
|
-
quantity: RawTransactionArgument<number | bigint>;
|
|
322
|
-
isBid: RawTransactionArgument<boolean>;
|
|
323
|
-
payWithDeep: RawTransactionArgument<boolean>;
|
|
324
|
-
expireTimestamp: RawTransactionArgument<number | bigint>;
|
|
316
|
+
orderId: RawTransactionArgument<number | bigint>;
|
|
317
|
+
newQuantity: RawTransactionArgument<number | bigint>;
|
|
325
318
|
}
|
|
326
|
-
export interface
|
|
319
|
+
export interface ModifyOrderOptions {
|
|
327
320
|
package?: string;
|
|
328
321
|
arguments:
|
|
329
|
-
|
|
|
322
|
+
| ModifyOrderArguments
|
|
330
323
|
| [
|
|
331
324
|
registry: RawTransactionArgument<string>,
|
|
332
325
|
marginManager: RawTransactionArgument<string>,
|
|
333
326
|
pool: RawTransactionArgument<string>,
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
baseOracle: RawTransactionArgument<string>,
|
|
337
|
-
quoteOracle: RawTransactionArgument<string>,
|
|
338
|
-
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
339
|
-
orderType: RawTransactionArgument<number>,
|
|
340
|
-
selfMatchingOption: RawTransactionArgument<number>,
|
|
341
|
-
price: RawTransactionArgument<number | bigint>,
|
|
342
|
-
quantity: RawTransactionArgument<number | bigint>,
|
|
343
|
-
isBid: RawTransactionArgument<boolean>,
|
|
344
|
-
payWithDeep: RawTransactionArgument<boolean>,
|
|
345
|
-
expireTimestamp: RawTransactionArgument<number | bigint>,
|
|
327
|
+
orderId: RawTransactionArgument<number | bigint>,
|
|
328
|
+
newQuantity: RawTransactionArgument<number | bigint>,
|
|
346
329
|
];
|
|
347
330
|
typeArguments: [string, string];
|
|
348
331
|
}
|
|
349
|
-
/**
|
|
350
|
-
export function
|
|
332
|
+
/** Modifies an order */
|
|
333
|
+
export function modifyOrder(options: ModifyOrderOptions) {
|
|
351
334
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
352
|
-
const argumentsTypes = [
|
|
353
|
-
null
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
null,
|
|
357
|
-
null,
|
|
358
|
-
null,
|
|
359
|
-
null,
|
|
360
|
-
'u64',
|
|
361
|
-
'u8',
|
|
362
|
-
'u8',
|
|
363
|
-
'u64',
|
|
364
|
-
'u64',
|
|
365
|
-
'bool',
|
|
366
|
-
'bool',
|
|
367
|
-
'u64',
|
|
368
|
-
'0x2::clock::Clock',
|
|
369
|
-
] satisfies (string | null)[];
|
|
370
|
-
const parameterNames = [
|
|
371
|
-
'registry',
|
|
372
|
-
'marginManager',
|
|
373
|
-
'pool',
|
|
374
|
-
'baseMarginPool',
|
|
375
|
-
'quoteMarginPool',
|
|
376
|
-
'baseOracle',
|
|
377
|
-
'quoteOracle',
|
|
378
|
-
'clientOrderId',
|
|
379
|
-
'orderType',
|
|
380
|
-
'selfMatchingOption',
|
|
381
|
-
'price',
|
|
382
|
-
'quantity',
|
|
383
|
-
'isBid',
|
|
384
|
-
'payWithDeep',
|
|
385
|
-
'expireTimestamp',
|
|
386
|
-
];
|
|
335
|
+
const argumentsTypes = [null, null, null, 'u128', 'u64', '0x2::clock::Clock'] satisfies (
|
|
336
|
+
string | null
|
|
337
|
+
)[];
|
|
338
|
+
const parameterNames = ['registry', 'marginManager', 'pool', 'orderId', 'newQuantity'];
|
|
387
339
|
return (tx: Transaction) =>
|
|
388
340
|
tx.moveCall({
|
|
389
341
|
package: packageAddress,
|
|
390
342
|
module: 'pool_proxy',
|
|
391
|
-
function: '
|
|
343
|
+
function: 'modify_order',
|
|
392
344
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
393
345
|
typeArguments: options.typeArguments,
|
|
394
346
|
});
|
|
395
347
|
}
|
|
396
|
-
export interface
|
|
348
|
+
export interface CancelOrderArguments {
|
|
397
349
|
registry: RawTransactionArgument<string>;
|
|
398
350
|
marginManager: RawTransactionArgument<string>;
|
|
399
351
|
pool: RawTransactionArgument<string>;
|
|
400
|
-
|
|
401
|
-
quoteMarginPool: RawTransactionArgument<string>;
|
|
402
|
-
baseOracle: RawTransactionArgument<string>;
|
|
403
|
-
quoteOracle: RawTransactionArgument<string>;
|
|
404
|
-
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
405
|
-
selfMatchingOption: RawTransactionArgument<number>;
|
|
406
|
-
quantity: RawTransactionArgument<number | bigint>;
|
|
407
|
-
isBid: RawTransactionArgument<boolean>;
|
|
408
|
-
payWithDeep: RawTransactionArgument<boolean>;
|
|
352
|
+
orderId: RawTransactionArgument<number | bigint>;
|
|
409
353
|
}
|
|
410
|
-
export interface
|
|
354
|
+
export interface CancelOrderOptions {
|
|
411
355
|
package?: string;
|
|
412
356
|
arguments:
|
|
413
|
-
|
|
|
357
|
+
| CancelOrderArguments
|
|
414
358
|
| [
|
|
415
359
|
registry: RawTransactionArgument<string>,
|
|
416
360
|
marginManager: RawTransactionArgument<string>,
|
|
417
361
|
pool: RawTransactionArgument<string>,
|
|
418
|
-
|
|
419
|
-
quoteMarginPool: RawTransactionArgument<string>,
|
|
420
|
-
baseOracle: RawTransactionArgument<string>,
|
|
421
|
-
quoteOracle: RawTransactionArgument<string>,
|
|
422
|
-
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
423
|
-
selfMatchingOption: RawTransactionArgument<number>,
|
|
424
|
-
quantity: RawTransactionArgument<number | bigint>,
|
|
425
|
-
isBid: RawTransactionArgument<boolean>,
|
|
426
|
-
payWithDeep: RawTransactionArgument<boolean>,
|
|
362
|
+
orderId: RawTransactionArgument<number | bigint>,
|
|
427
363
|
];
|
|
428
364
|
typeArguments: [string, string];
|
|
429
365
|
}
|
|
430
|
-
/**
|
|
431
|
-
export function
|
|
366
|
+
/** Cancels an order */
|
|
367
|
+
export function cancelOrder(options: CancelOrderOptions) {
|
|
432
368
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
433
|
-
const argumentsTypes = [
|
|
434
|
-
null
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
null,
|
|
438
|
-
null,
|
|
439
|
-
null,
|
|
440
|
-
null,
|
|
441
|
-
'u64',
|
|
442
|
-
'u8',
|
|
443
|
-
'u64',
|
|
444
|
-
'bool',
|
|
445
|
-
'bool',
|
|
446
|
-
'0x2::clock::Clock',
|
|
447
|
-
] satisfies (string | null)[];
|
|
448
|
-
const parameterNames = [
|
|
449
|
-
'registry',
|
|
450
|
-
'marginManager',
|
|
451
|
-
'pool',
|
|
452
|
-
'baseMarginPool',
|
|
453
|
-
'quoteMarginPool',
|
|
454
|
-
'baseOracle',
|
|
455
|
-
'quoteOracle',
|
|
456
|
-
'clientOrderId',
|
|
457
|
-
'selfMatchingOption',
|
|
458
|
-
'quantity',
|
|
459
|
-
'isBid',
|
|
460
|
-
'payWithDeep',
|
|
461
|
-
];
|
|
369
|
+
const argumentsTypes = [null, null, null, 'u128', '0x2::clock::Clock'] satisfies (
|
|
370
|
+
string | null
|
|
371
|
+
)[];
|
|
372
|
+
const parameterNames = ['registry', 'marginManager', 'pool', 'orderId'];
|
|
462
373
|
return (tx: Transaction) =>
|
|
463
374
|
tx.moveCall({
|
|
464
375
|
package: packageAddress,
|
|
465
376
|
module: 'pool_proxy',
|
|
466
|
-
function: '
|
|
377
|
+
function: 'cancel_order',
|
|
467
378
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
468
379
|
typeArguments: options.typeArguments,
|
|
469
380
|
});
|
|
470
381
|
}
|
|
471
|
-
export interface
|
|
382
|
+
export interface CancelOrdersArguments {
|
|
472
383
|
registry: RawTransactionArgument<string>;
|
|
473
384
|
marginManager: RawTransactionArgument<string>;
|
|
474
385
|
pool: RawTransactionArgument<string>;
|
|
475
|
-
|
|
476
|
-
quoteMarginPool: RawTransactionArgument<string>;
|
|
477
|
-
baseOracle: RawTransactionArgument<string>;
|
|
478
|
-
quoteOracle: RawTransactionArgument<string>;
|
|
479
|
-
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
480
|
-
orderType: RawTransactionArgument<number>;
|
|
481
|
-
selfMatchingOption: RawTransactionArgument<number>;
|
|
482
|
-
price: RawTransactionArgument<number | bigint>;
|
|
483
|
-
quantity: RawTransactionArgument<number | bigint>;
|
|
484
|
-
isBid: RawTransactionArgument<boolean>;
|
|
485
|
-
payWithDeep: RawTransactionArgument<boolean>;
|
|
486
|
-
expireTimestamp: RawTransactionArgument<number | bigint>;
|
|
386
|
+
orderIds: RawTransactionArgument<Array<number | bigint>>;
|
|
487
387
|
}
|
|
488
|
-
export interface
|
|
388
|
+
export interface CancelOrdersOptions {
|
|
489
389
|
package?: string;
|
|
490
390
|
arguments:
|
|
491
|
-
|
|
|
391
|
+
| CancelOrdersArguments
|
|
492
392
|
| [
|
|
493
393
|
registry: RawTransactionArgument<string>,
|
|
494
394
|
marginManager: RawTransactionArgument<string>,
|
|
495
395
|
pool: RawTransactionArgument<string>,
|
|
496
|
-
|
|
497
|
-
quoteMarginPool: RawTransactionArgument<string>,
|
|
498
|
-
baseOracle: RawTransactionArgument<string>,
|
|
499
|
-
quoteOracle: RawTransactionArgument<string>,
|
|
500
|
-
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
501
|
-
orderType: RawTransactionArgument<number>,
|
|
502
|
-
selfMatchingOption: RawTransactionArgument<number>,
|
|
503
|
-
price: RawTransactionArgument<number | bigint>,
|
|
504
|
-
quantity: RawTransactionArgument<number | bigint>,
|
|
505
|
-
isBid: RawTransactionArgument<boolean>,
|
|
506
|
-
payWithDeep: RawTransactionArgument<boolean>,
|
|
507
|
-
expireTimestamp: RawTransactionArgument<number | bigint>,
|
|
396
|
+
orderIds: RawTransactionArgument<Array<number | bigint>>,
|
|
508
397
|
];
|
|
509
398
|
typeArguments: [string, string];
|
|
510
399
|
}
|
|
511
|
-
/**
|
|
512
|
-
export function
|
|
400
|
+
/** Cancel multiple orders within a vector. */
|
|
401
|
+
export function cancelOrders(options: CancelOrdersOptions) {
|
|
513
402
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
514
|
-
const argumentsTypes = [
|
|
515
|
-
null
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
null,
|
|
519
|
-
null,
|
|
520
|
-
null,
|
|
521
|
-
null,
|
|
522
|
-
'u64',
|
|
523
|
-
'u8',
|
|
524
|
-
'u8',
|
|
525
|
-
'u64',
|
|
526
|
-
'u64',
|
|
527
|
-
'bool',
|
|
528
|
-
'bool',
|
|
529
|
-
'u64',
|
|
530
|
-
'0x2::clock::Clock',
|
|
531
|
-
] satisfies (string | null)[];
|
|
532
|
-
const parameterNames = [
|
|
533
|
-
'registry',
|
|
534
|
-
'marginManager',
|
|
535
|
-
'pool',
|
|
536
|
-
'baseMarginPool',
|
|
537
|
-
'quoteMarginPool',
|
|
538
|
-
'baseOracle',
|
|
539
|
-
'quoteOracle',
|
|
540
|
-
'clientOrderId',
|
|
541
|
-
'orderType',
|
|
542
|
-
'selfMatchingOption',
|
|
543
|
-
'price',
|
|
544
|
-
'quantity',
|
|
545
|
-
'isBid',
|
|
546
|
-
'payWithDeep',
|
|
547
|
-
'expireTimestamp',
|
|
548
|
-
];
|
|
403
|
+
const argumentsTypes = [null, null, null, 'vector<u128>', '0x2::clock::Clock'] satisfies (
|
|
404
|
+
string | null
|
|
405
|
+
)[];
|
|
406
|
+
const parameterNames = ['registry', 'marginManager', 'pool', 'orderIds'];
|
|
549
407
|
return (tx: Transaction) =>
|
|
550
408
|
tx.moveCall({
|
|
551
409
|
package: packageAddress,
|
|
552
410
|
module: 'pool_proxy',
|
|
553
|
-
function: '
|
|
411
|
+
function: 'cancel_orders',
|
|
554
412
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
555
413
|
typeArguments: options.typeArguments,
|
|
556
414
|
});
|
|
557
415
|
}
|
|
558
|
-
export interface
|
|
416
|
+
export interface CancelAllOrdersArguments {
|
|
559
417
|
registry: RawTransactionArgument<string>;
|
|
560
418
|
marginManager: RawTransactionArgument<string>;
|
|
561
419
|
pool: RawTransactionArgument<string>;
|
|
562
|
-
baseMarginPool: RawTransactionArgument<string>;
|
|
563
|
-
quoteMarginPool: RawTransactionArgument<string>;
|
|
564
|
-
baseOracle: RawTransactionArgument<string>;
|
|
565
|
-
quoteOracle: RawTransactionArgument<string>;
|
|
566
|
-
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
567
|
-
selfMatchingOption: RawTransactionArgument<number>;
|
|
568
|
-
quantity: RawTransactionArgument<number | bigint>;
|
|
569
|
-
isBid: RawTransactionArgument<boolean>;
|
|
570
|
-
payWithDeep: RawTransactionArgument<boolean>;
|
|
571
420
|
}
|
|
572
|
-
export interface
|
|
421
|
+
export interface CancelAllOrdersOptions {
|
|
573
422
|
package?: string;
|
|
574
423
|
arguments:
|
|
575
|
-
|
|
|
424
|
+
| CancelAllOrdersArguments
|
|
576
425
|
| [
|
|
577
426
|
registry: RawTransactionArgument<string>,
|
|
578
427
|
marginManager: RawTransactionArgument<string>,
|
|
579
428
|
pool: RawTransactionArgument<string>,
|
|
580
|
-
baseMarginPool: RawTransactionArgument<string>,
|
|
581
|
-
quoteMarginPool: RawTransactionArgument<string>,
|
|
582
|
-
baseOracle: RawTransactionArgument<string>,
|
|
583
|
-
quoteOracle: RawTransactionArgument<string>,
|
|
584
|
-
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
585
|
-
selfMatchingOption: RawTransactionArgument<number>,
|
|
586
|
-
quantity: RawTransactionArgument<number | bigint>,
|
|
587
|
-
isBid: RawTransactionArgument<boolean>,
|
|
588
|
-
payWithDeep: RawTransactionArgument<boolean>,
|
|
589
429
|
];
|
|
590
430
|
typeArguments: [string, string];
|
|
591
431
|
}
|
|
592
|
-
/**
|
|
593
|
-
|
|
594
|
-
* disabled.
|
|
595
|
-
*
|
|
596
|
-
* Superseded by `place_reduce_only_market_order_and_repay_loan`. A market (taker)
|
|
597
|
-
* fill always pays the spread, which lowers the oracle-valued `risk_ratio` while
|
|
598
|
-
* the debt is unchanged, so the swap-only monotonic check here rejects essentially
|
|
599
|
-
* every taker fill. The `_and_repay` variant deleverages with the proceeds so the
|
|
600
|
-
* net-state ratio actually improves. Kept callable for existing integrators; its
|
|
601
|
-
* reduce-only _direction_ guard matches the other entries — a bid needs base
|
|
602
|
-
* (short-side) debt, the ask needs quote (long-side) debt and sells up to gross
|
|
603
|
-
* base held — with no size cap.
|
|
604
|
-
*/
|
|
605
|
-
export function placeReduceOnlyMarketOrderV2(options: PlaceReduceOnlyMarketOrderV2Options) {
|
|
432
|
+
/** Cancels all orders for the given account. */
|
|
433
|
+
export function cancelAllOrders(options: CancelAllOrdersOptions) {
|
|
606
434
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
607
|
-
const argumentsTypes = [
|
|
608
|
-
|
|
609
|
-
null,
|
|
610
|
-
null,
|
|
611
|
-
null,
|
|
612
|
-
null,
|
|
613
|
-
null,
|
|
614
|
-
null,
|
|
615
|
-
'u64',
|
|
616
|
-
'u8',
|
|
617
|
-
'u64',
|
|
618
|
-
'bool',
|
|
619
|
-
'bool',
|
|
620
|
-
'0x2::clock::Clock',
|
|
621
|
-
] satisfies (string | null)[];
|
|
622
|
-
const parameterNames = [
|
|
623
|
-
'registry',
|
|
624
|
-
'marginManager',
|
|
625
|
-
'pool',
|
|
626
|
-
'baseMarginPool',
|
|
627
|
-
'quoteMarginPool',
|
|
628
|
-
'baseOracle',
|
|
629
|
-
'quoteOracle',
|
|
630
|
-
'clientOrderId',
|
|
631
|
-
'selfMatchingOption',
|
|
632
|
-
'quantity',
|
|
633
|
-
'isBid',
|
|
634
|
-
'payWithDeep',
|
|
635
|
-
];
|
|
435
|
+
const argumentsTypes = [null, null, null, '0x2::clock::Clock'] satisfies (string | null)[];
|
|
436
|
+
const parameterNames = ['registry', 'marginManager', 'pool'];
|
|
636
437
|
return (tx: Transaction) =>
|
|
637
438
|
tx.moveCall({
|
|
638
439
|
package: packageAddress,
|
|
639
440
|
module: 'pool_proxy',
|
|
640
|
-
function: '
|
|
441
|
+
function: 'cancel_all_orders',
|
|
641
442
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
642
443
|
typeArguments: options.typeArguments,
|
|
643
444
|
});
|
|
644
445
|
}
|
|
645
|
-
export interface
|
|
446
|
+
export interface WithdrawSettledAmountsArguments {
|
|
646
447
|
registry: RawTransactionArgument<string>;
|
|
647
448
|
marginManager: RawTransactionArgument<string>;
|
|
648
449
|
pool: RawTransactionArgument<string>;
|
|
649
|
-
baseMarginPool: RawTransactionArgument<string>;
|
|
650
|
-
quoteMarginPool: RawTransactionArgument<string>;
|
|
651
|
-
baseOracle: RawTransactionArgument<string>;
|
|
652
|
-
quoteOracle: RawTransactionArgument<string>;
|
|
653
|
-
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
654
|
-
selfMatchingOption: RawTransactionArgument<number>;
|
|
655
|
-
quantity: RawTransactionArgument<number | bigint>;
|
|
656
|
-
isBid: RawTransactionArgument<boolean>;
|
|
657
|
-
payWithDeep: RawTransactionArgument<boolean>;
|
|
658
450
|
}
|
|
659
|
-
export interface
|
|
451
|
+
export interface WithdrawSettledAmountsOptions {
|
|
660
452
|
package?: string;
|
|
661
453
|
arguments:
|
|
662
|
-
|
|
|
454
|
+
| WithdrawSettledAmountsArguments
|
|
663
455
|
| [
|
|
664
456
|
registry: RawTransactionArgument<string>,
|
|
665
457
|
marginManager: RawTransactionArgument<string>,
|
|
666
458
|
pool: RawTransactionArgument<string>,
|
|
667
|
-
baseMarginPool: RawTransactionArgument<string>,
|
|
668
|
-
quoteMarginPool: RawTransactionArgument<string>,
|
|
669
|
-
baseOracle: RawTransactionArgument<string>,
|
|
670
|
-
quoteOracle: RawTransactionArgument<string>,
|
|
671
|
-
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
672
|
-
selfMatchingOption: RawTransactionArgument<number>,
|
|
673
|
-
quantity: RawTransactionArgument<number | bigint>,
|
|
674
|
-
isBid: RawTransactionArgument<boolean>,
|
|
675
|
-
payWithDeep: RawTransactionArgument<boolean>,
|
|
676
459
|
];
|
|
677
460
|
typeArguments: [string, string];
|
|
678
461
|
}
|
|
679
|
-
/**
|
|
680
|
-
|
|
681
|
-
* repays the loan with the proceeds, then requires the net (post-repay) risk ratio
|
|
682
|
-
* to be at least the pre-trade ratio.
|
|
683
|
-
*
|
|
684
|
-
* The post-repay check is the point. A market close pays the spread, which alone
|
|
685
|
-
* lowers the oracle-valued ratio (debt is unchanged until repay) and would abort
|
|
686
|
-
* the plain reduce-only path. Repaying first deleverages and absorbs the slippage
|
|
687
|
-
* (still bounded by the `assert_price` band), and lets a manager in the
|
|
688
|
-
* `liquidation..min_borrow` band climb out — it cannot reach the borrow floor in a
|
|
689
|
-
* single swap.
|
|
690
|
-
*/
|
|
691
|
-
export function placeReduceOnlyMarketOrderAndRepayLoan(
|
|
692
|
-
options: PlaceReduceOnlyMarketOrderAndRepayLoanOptions,
|
|
693
|
-
) {
|
|
462
|
+
/** Withdraw settled amounts to balance_manager. */
|
|
463
|
+
export function withdrawSettledAmounts(options: WithdrawSettledAmountsOptions) {
|
|
694
464
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
695
|
-
const argumentsTypes = [
|
|
696
|
-
|
|
697
|
-
null,
|
|
698
|
-
null,
|
|
699
|
-
null,
|
|
700
|
-
null,
|
|
701
|
-
null,
|
|
702
|
-
null,
|
|
703
|
-
'u64',
|
|
704
|
-
'u8',
|
|
705
|
-
'u64',
|
|
706
|
-
'bool',
|
|
707
|
-
'bool',
|
|
708
|
-
'0x2::clock::Clock',
|
|
709
|
-
] satisfies (string | null)[];
|
|
710
|
-
const parameterNames = [
|
|
711
|
-
'registry',
|
|
712
|
-
'marginManager',
|
|
713
|
-
'pool',
|
|
714
|
-
'baseMarginPool',
|
|
715
|
-
'quoteMarginPool',
|
|
716
|
-
'baseOracle',
|
|
717
|
-
'quoteOracle',
|
|
718
|
-
'clientOrderId',
|
|
719
|
-
'selfMatchingOption',
|
|
720
|
-
'quantity',
|
|
721
|
-
'isBid',
|
|
722
|
-
'payWithDeep',
|
|
723
|
-
];
|
|
465
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
466
|
+
const parameterNames = ['registry', 'marginManager', 'pool'];
|
|
724
467
|
return (tx: Transaction) =>
|
|
725
468
|
tx.moveCall({
|
|
726
469
|
package: packageAddress,
|
|
727
470
|
module: 'pool_proxy',
|
|
728
|
-
function: '
|
|
471
|
+
function: 'withdraw_settled_amounts',
|
|
729
472
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
730
473
|
typeArguments: options.typeArguments,
|
|
731
474
|
});
|
|
732
475
|
}
|
|
733
|
-
export interface
|
|
476
|
+
export interface WithdrawSettledAmountsPermissionlessArguments {
|
|
734
477
|
registry: RawTransactionArgument<string>;
|
|
735
478
|
marginManager: RawTransactionArgument<string>;
|
|
736
479
|
pool: RawTransactionArgument<string>;
|
|
737
|
-
baseMarginPool: RawTransactionArgument<string>;
|
|
738
|
-
quoteMarginPool: RawTransactionArgument<string>;
|
|
739
|
-
baseOracle: RawTransactionArgument<string>;
|
|
740
|
-
quoteOracle: RawTransactionArgument<string>;
|
|
741
|
-
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
742
|
-
orderType: RawTransactionArgument<number>;
|
|
743
|
-
selfMatchingOption: RawTransactionArgument<number>;
|
|
744
|
-
price: RawTransactionArgument<number | bigint>;
|
|
745
|
-
quantity: RawTransactionArgument<number | bigint>;
|
|
746
|
-
isBid: RawTransactionArgument<boolean>;
|
|
747
|
-
payWithDeep: RawTransactionArgument<boolean>;
|
|
748
|
-
expireTimestamp: RawTransactionArgument<number | bigint>;
|
|
749
480
|
}
|
|
750
|
-
export interface
|
|
481
|
+
export interface WithdrawSettledAmountsPermissionlessOptions {
|
|
751
482
|
package?: string;
|
|
752
483
|
arguments:
|
|
753
|
-
|
|
|
484
|
+
| WithdrawSettledAmountsPermissionlessArguments
|
|
754
485
|
| [
|
|
755
486
|
registry: RawTransactionArgument<string>,
|
|
756
487
|
marginManager: RawTransactionArgument<string>,
|
|
757
488
|
pool: RawTransactionArgument<string>,
|
|
758
|
-
baseMarginPool: RawTransactionArgument<string>,
|
|
759
|
-
quoteMarginPool: RawTransactionArgument<string>,
|
|
760
|
-
baseOracle: RawTransactionArgument<string>,
|
|
761
|
-
quoteOracle: RawTransactionArgument<string>,
|
|
762
|
-
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
763
|
-
orderType: RawTransactionArgument<number>,
|
|
764
|
-
selfMatchingOption: RawTransactionArgument<number>,
|
|
765
|
-
price: RawTransactionArgument<number | bigint>,
|
|
766
|
-
quantity: RawTransactionArgument<number | bigint>,
|
|
767
|
-
isBid: RawTransactionArgument<boolean>,
|
|
768
|
-
payWithDeep: RawTransactionArgument<boolean>,
|
|
769
|
-
expireTimestamp: RawTransactionArgument<number | bigint>,
|
|
770
489
|
];
|
|
771
490
|
typeArguments: [string, string];
|
|
772
491
|
}
|
|
773
492
|
/**
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
* plus the repay-then-net-monotonic gate of
|
|
777
|
-
* `place_reduce_only_market_order_and_repay_loan`: the portion that crosses the
|
|
778
|
-
* book fills immediately and settles, the rest rests as a maker, then the settled
|
|
779
|
-
* (taker) proceeds repay the debt before the monotonic check on the net
|
|
780
|
-
* (post-repay) state.
|
|
781
|
-
*
|
|
782
|
-
* This is the danger-band tool for a _price-bounded_ reduce: a crossing
|
|
783
|
-
* reduce-only limit pays the spread on its taker fills, which alone would abort
|
|
784
|
-
* `place_reduce_only_limit_order_v2`'s swap-only monotonic check; repaying first
|
|
785
|
-
* deleverages so the net ratio holds. The resting remainder only locks balance
|
|
786
|
-
* (counted in assets), so it doesn't move the ratio. Unfilled-and-resting behaves
|
|
787
|
-
* exactly like `place_reduce_only_limit_order_v2` (nothing to repay).
|
|
493
|
+
* Withdraw settled amounts to balance_manager permissionlessly. Anyone can call
|
|
494
|
+
* this function to settle balances for a margin manager.
|
|
788
495
|
*/
|
|
789
|
-
export function
|
|
790
|
-
options:
|
|
496
|
+
export function withdrawSettledAmountsPermissionless(
|
|
497
|
+
options: WithdrawSettledAmountsPermissionlessOptions,
|
|
791
498
|
) {
|
|
792
499
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
793
|
-
const argumentsTypes = [
|
|
794
|
-
|
|
795
|
-
null,
|
|
796
|
-
null,
|
|
797
|
-
null,
|
|
798
|
-
null,
|
|
799
|
-
null,
|
|
800
|
-
null,
|
|
801
|
-
'u64',
|
|
802
|
-
'u8',
|
|
803
|
-
'u8',
|
|
804
|
-
'u64',
|
|
805
|
-
'u64',
|
|
806
|
-
'bool',
|
|
807
|
-
'bool',
|
|
808
|
-
'u64',
|
|
809
|
-
'0x2::clock::Clock',
|
|
810
|
-
] satisfies (string | null)[];
|
|
811
|
-
const parameterNames = [
|
|
812
|
-
'registry',
|
|
813
|
-
'marginManager',
|
|
814
|
-
'pool',
|
|
815
|
-
'baseMarginPool',
|
|
816
|
-
'quoteMarginPool',
|
|
817
|
-
'baseOracle',
|
|
818
|
-
'quoteOracle',
|
|
819
|
-
'clientOrderId',
|
|
820
|
-
'orderType',
|
|
821
|
-
'selfMatchingOption',
|
|
822
|
-
'price',
|
|
823
|
-
'quantity',
|
|
824
|
-
'isBid',
|
|
825
|
-
'payWithDeep',
|
|
826
|
-
'expireTimestamp',
|
|
827
|
-
];
|
|
500
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
501
|
+
const parameterNames = ['registry', 'marginManager', 'pool'];
|
|
828
502
|
return (tx: Transaction) =>
|
|
829
503
|
tx.moveCall({
|
|
830
504
|
package: packageAddress,
|
|
831
505
|
module: 'pool_proxy',
|
|
832
|
-
function: '
|
|
506
|
+
function: 'withdraw_settled_amounts_permissionless',
|
|
833
507
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
834
508
|
typeArguments: options.typeArguments,
|
|
835
509
|
});
|
|
836
510
|
}
|
|
837
|
-
export interface
|
|
511
|
+
export interface StakeArguments {
|
|
838
512
|
registry: RawTransactionArgument<string>;
|
|
839
513
|
marginManager: RawTransactionArgument<string>;
|
|
840
514
|
pool: RawTransactionArgument<string>;
|
|
841
|
-
|
|
842
|
-
quoteMarginPool: RawTransactionArgument<string>;
|
|
843
|
-
baseOracle: RawTransactionArgument<string>;
|
|
844
|
-
quoteOracle: RawTransactionArgument<string>;
|
|
845
|
-
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
846
|
-
selfMatchingOption: RawTransactionArgument<number>;
|
|
847
|
-
quantity: RawTransactionArgument<number | bigint>;
|
|
848
|
-
isBid: RawTransactionArgument<boolean>;
|
|
849
|
-
payWithDeep: RawTransactionArgument<boolean>;
|
|
515
|
+
amount: RawTransactionArgument<number | bigint>;
|
|
850
516
|
}
|
|
851
|
-
export interface
|
|
517
|
+
export interface StakeOptions {
|
|
852
518
|
package?: string;
|
|
853
519
|
arguments:
|
|
854
|
-
|
|
|
520
|
+
| StakeArguments
|
|
855
521
|
| [
|
|
856
522
|
registry: RawTransactionArgument<string>,
|
|
857
523
|
marginManager: RawTransactionArgument<string>,
|
|
858
524
|
pool: RawTransactionArgument<string>,
|
|
859
|
-
|
|
860
|
-
quoteMarginPool: RawTransactionArgument<string>,
|
|
861
|
-
baseOracle: RawTransactionArgument<string>,
|
|
862
|
-
quoteOracle: RawTransactionArgument<string>,
|
|
863
|
-
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
864
|
-
selfMatchingOption: RawTransactionArgument<number>,
|
|
865
|
-
quantity: RawTransactionArgument<number | bigint>,
|
|
866
|
-
isBid: RawTransactionArgument<boolean>,
|
|
867
|
-
payWithDeep: RawTransactionArgument<boolean>,
|
|
525
|
+
amount: RawTransactionArgument<number | bigint>,
|
|
868
526
|
];
|
|
869
527
|
typeArguments: [string, string];
|
|
870
528
|
}
|
|
871
|
-
/**
|
|
872
|
-
|
|
873
|
-
* on a **monotonic** net-state check: if any debt remains after the repay, the
|
|
874
|
-
* post-repay `risk_ratio` must be at least the pre-trade ratio (improve-or-hold).
|
|
875
|
-
* A full close drives debt to 0 (`risk_ratio` MAX), which always passes.
|
|
876
|
-
*
|
|
877
|
-
* This is the everyday close / deleverage tool. The monotonic gate — rather than
|
|
878
|
-
* the `min_open` opening floor used by `place_market_order_v2` — lets a position
|
|
879
|
-
* in the `liquidation..min_borrow` danger band wind down _partially_: a small
|
|
880
|
-
* close that lifts the ratio from, say, 1.12 to 1.15 is allowed even though 1.15
|
|
881
|
-
* is still below `min_open`, which the opening floor would reject.
|
|
882
|
-
*
|
|
883
|
-
* Not reduce-only and uncapped, but the monotonic check makes a quantity cap
|
|
884
|
-
* unnecessary: a market (taker) fill settles immediately, so any genuinely
|
|
885
|
-
* exposure-_increasing_ trade lowers the ratio and aborts here, while any
|
|
886
|
-
* deleveraging trade is allowed at any size — an overshoot past the debt is fine
|
|
887
|
-
* (surplus is the manager's own holding) and `assert_price` still bounds slippage.
|
|
888
|
-
* Requires margin trading enabled; in reduce-only mode use
|
|
889
|
-
* `place_reduce_only_market_order_and_repay_loan`.
|
|
890
|
-
*/
|
|
891
|
-
export function placeMarketOrderAndRepayLoan(options: PlaceMarketOrderAndRepayLoanOptions) {
|
|
529
|
+
/** Stake DEEP tokens to the pool. */
|
|
530
|
+
export function stake(options: StakeOptions) {
|
|
892
531
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
893
|
-
const argumentsTypes = [
|
|
894
|
-
|
|
895
|
-
null,
|
|
896
|
-
null,
|
|
897
|
-
null,
|
|
898
|
-
null,
|
|
899
|
-
null,
|
|
900
|
-
null,
|
|
901
|
-
'u64',
|
|
902
|
-
'u8',
|
|
903
|
-
'u64',
|
|
904
|
-
'bool',
|
|
905
|
-
'bool',
|
|
906
|
-
'0x2::clock::Clock',
|
|
907
|
-
] satisfies (string | null)[];
|
|
908
|
-
const parameterNames = [
|
|
909
|
-
'registry',
|
|
910
|
-
'marginManager',
|
|
911
|
-
'pool',
|
|
912
|
-
'baseMarginPool',
|
|
913
|
-
'quoteMarginPool',
|
|
914
|
-
'baseOracle',
|
|
915
|
-
'quoteOracle',
|
|
916
|
-
'clientOrderId',
|
|
917
|
-
'selfMatchingOption',
|
|
918
|
-
'quantity',
|
|
919
|
-
'isBid',
|
|
920
|
-
'payWithDeep',
|
|
921
|
-
];
|
|
532
|
+
const argumentsTypes = [null, null, null, 'u64'] satisfies (string | null)[];
|
|
533
|
+
const parameterNames = ['registry', 'marginManager', 'pool', 'amount'];
|
|
922
534
|
return (tx: Transaction) =>
|
|
923
535
|
tx.moveCall({
|
|
924
536
|
package: packageAddress,
|
|
925
537
|
module: 'pool_proxy',
|
|
926
|
-
function: '
|
|
538
|
+
function: 'stake',
|
|
927
539
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
928
540
|
typeArguments: options.typeArguments,
|
|
929
541
|
});
|
|
930
542
|
}
|
|
931
|
-
export interface
|
|
543
|
+
export interface UnstakeArguments {
|
|
932
544
|
registry: RawTransactionArgument<string>;
|
|
933
545
|
marginManager: RawTransactionArgument<string>;
|
|
934
546
|
pool: RawTransactionArgument<string>;
|
|
935
|
-
orderId: RawTransactionArgument<number | bigint>;
|
|
936
|
-
newQuantity: RawTransactionArgument<number | bigint>;
|
|
937
547
|
}
|
|
938
|
-
export interface
|
|
548
|
+
export interface UnstakeOptions {
|
|
939
549
|
package?: string;
|
|
940
550
|
arguments:
|
|
941
|
-
|
|
|
551
|
+
| UnstakeArguments
|
|
942
552
|
| [
|
|
943
553
|
registry: RawTransactionArgument<string>,
|
|
944
554
|
marginManager: RawTransactionArgument<string>,
|
|
945
555
|
pool: RawTransactionArgument<string>,
|
|
946
|
-
orderId: RawTransactionArgument<number | bigint>,
|
|
947
|
-
newQuantity: RawTransactionArgument<number | bigint>,
|
|
948
556
|
];
|
|
949
557
|
typeArguments: [string, string];
|
|
950
558
|
}
|
|
951
|
-
/**
|
|
952
|
-
export function
|
|
559
|
+
/** Unstake DEEP tokens from the pool. */
|
|
560
|
+
export function unstake(options: UnstakeOptions) {
|
|
953
561
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
954
|
-
const argumentsTypes = [null, null, null
|
|
955
|
-
|
|
956
|
-
| null
|
|
957
|
-
)[];
|
|
958
|
-
const parameterNames = ['registry', 'marginManager', 'pool', 'orderId', 'newQuantity'];
|
|
562
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
563
|
+
const parameterNames = ['registry', 'marginManager', 'pool'];
|
|
959
564
|
return (tx: Transaction) =>
|
|
960
565
|
tx.moveCall({
|
|
961
566
|
package: packageAddress,
|
|
962
567
|
module: 'pool_proxy',
|
|
963
|
-
function: '
|
|
568
|
+
function: 'unstake',
|
|
964
569
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
965
570
|
typeArguments: options.typeArguments,
|
|
966
571
|
});
|
|
967
572
|
}
|
|
968
|
-
export interface
|
|
573
|
+
export interface SubmitProposalArguments {
|
|
969
574
|
registry: RawTransactionArgument<string>;
|
|
970
575
|
marginManager: RawTransactionArgument<string>;
|
|
971
576
|
pool: RawTransactionArgument<string>;
|
|
972
|
-
|
|
577
|
+
takerFee: RawTransactionArgument<number | bigint>;
|
|
578
|
+
makerFee: RawTransactionArgument<number | bigint>;
|
|
579
|
+
stakeRequired: RawTransactionArgument<number | bigint>;
|
|
973
580
|
}
|
|
974
|
-
export interface
|
|
581
|
+
export interface SubmitProposalOptions {
|
|
975
582
|
package?: string;
|
|
976
583
|
arguments:
|
|
977
|
-
|
|
|
584
|
+
| SubmitProposalArguments
|
|
978
585
|
| [
|
|
979
586
|
registry: RawTransactionArgument<string>,
|
|
980
587
|
marginManager: RawTransactionArgument<string>,
|
|
981
588
|
pool: RawTransactionArgument<string>,
|
|
982
|
-
|
|
589
|
+
takerFee: RawTransactionArgument<number | bigint>,
|
|
590
|
+
makerFee: RawTransactionArgument<number | bigint>,
|
|
591
|
+
stakeRequired: RawTransactionArgument<number | bigint>,
|
|
983
592
|
];
|
|
984
593
|
typeArguments: [string, string];
|
|
985
594
|
}
|
|
986
|
-
/**
|
|
987
|
-
export function
|
|
595
|
+
/** Submit proposal using the margin manager. */
|
|
596
|
+
export function submitProposal(options: SubmitProposalOptions) {
|
|
988
597
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
989
|
-
const argumentsTypes = [null, null, null, '
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
598
|
+
const argumentsTypes = [null, null, null, 'u64', 'u64', 'u64'] satisfies (string | null)[];
|
|
599
|
+
const parameterNames = [
|
|
600
|
+
'registry',
|
|
601
|
+
'marginManager',
|
|
602
|
+
'pool',
|
|
603
|
+
'takerFee',
|
|
604
|
+
'makerFee',
|
|
605
|
+
'stakeRequired',
|
|
606
|
+
];
|
|
994
607
|
return (tx: Transaction) =>
|
|
995
608
|
tx.moveCall({
|
|
996
609
|
package: packageAddress,
|
|
997
610
|
module: 'pool_proxy',
|
|
998
|
-
function: '
|
|
611
|
+
function: 'submit_proposal',
|
|
999
612
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1000
613
|
typeArguments: options.typeArguments,
|
|
1001
614
|
});
|
|
1002
615
|
}
|
|
1003
|
-
export interface
|
|
616
|
+
export interface VoteArguments {
|
|
1004
617
|
registry: RawTransactionArgument<string>;
|
|
1005
618
|
marginManager: RawTransactionArgument<string>;
|
|
1006
619
|
pool: RawTransactionArgument<string>;
|
|
1007
|
-
|
|
620
|
+
proposalId: RawTransactionArgument<string>;
|
|
1008
621
|
}
|
|
1009
|
-
export interface
|
|
622
|
+
export interface VoteOptions {
|
|
1010
623
|
package?: string;
|
|
1011
624
|
arguments:
|
|
1012
|
-
|
|
|
625
|
+
| VoteArguments
|
|
1013
626
|
| [
|
|
1014
627
|
registry: RawTransactionArgument<string>,
|
|
1015
628
|
marginManager: RawTransactionArgument<string>,
|
|
1016
629
|
pool: RawTransactionArgument<string>,
|
|
1017
|
-
|
|
630
|
+
proposalId: RawTransactionArgument<string>,
|
|
1018
631
|
];
|
|
1019
632
|
typeArguments: [string, string];
|
|
1020
633
|
}
|
|
1021
|
-
/**
|
|
1022
|
-
export function
|
|
634
|
+
/** Vote on a proposal using the margin manager. */
|
|
635
|
+
export function vote(options: VoteOptions) {
|
|
1023
636
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1024
|
-
const argumentsTypes = [null, null, null, '
|
|
1025
|
-
|
|
1026
|
-
| null
|
|
1027
|
-
)[];
|
|
1028
|
-
const parameterNames = ['registry', 'marginManager', 'pool', 'orderIds'];
|
|
637
|
+
const argumentsTypes = [null, null, null, '0x2::object::ID'] satisfies (string | null)[];
|
|
638
|
+
const parameterNames = ['registry', 'marginManager', 'pool', 'proposalId'];
|
|
1029
639
|
return (tx: Transaction) =>
|
|
1030
640
|
tx.moveCall({
|
|
1031
641
|
package: packageAddress,
|
|
1032
642
|
module: 'pool_proxy',
|
|
1033
|
-
function: '
|
|
643
|
+
function: 'vote',
|
|
1034
644
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1035
645
|
typeArguments: options.typeArguments,
|
|
1036
646
|
});
|
|
1037
647
|
}
|
|
1038
|
-
export interface
|
|
648
|
+
export interface ClaimRebatesArguments {
|
|
1039
649
|
registry: RawTransactionArgument<string>;
|
|
1040
650
|
marginManager: RawTransactionArgument<string>;
|
|
1041
651
|
pool: RawTransactionArgument<string>;
|
|
1042
652
|
}
|
|
1043
|
-
export interface
|
|
653
|
+
export interface ClaimRebatesOptions {
|
|
1044
654
|
package?: string;
|
|
1045
655
|
arguments:
|
|
1046
|
-
|
|
|
656
|
+
| ClaimRebatesArguments
|
|
1047
657
|
| [
|
|
1048
658
|
registry: RawTransactionArgument<string>,
|
|
1049
659
|
marginManager: RawTransactionArgument<string>,
|
|
@@ -1051,247 +661,650 @@ export interface CancelAllOrdersOptions {
|
|
|
1051
661
|
];
|
|
1052
662
|
typeArguments: [string, string];
|
|
1053
663
|
}
|
|
1054
|
-
|
|
1055
|
-
export function cancelAllOrders(options: CancelAllOrdersOptions) {
|
|
664
|
+
export function claimRebates(options: ClaimRebatesOptions) {
|
|
1056
665
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1057
|
-
const argumentsTypes = [null, null, null
|
|
666
|
+
const argumentsTypes = [null, null, null] satisfies (string | null)[];
|
|
1058
667
|
const parameterNames = ['registry', 'marginManager', 'pool'];
|
|
1059
668
|
return (tx: Transaction) =>
|
|
1060
669
|
tx.moveCall({
|
|
1061
670
|
package: packageAddress,
|
|
1062
671
|
module: 'pool_proxy',
|
|
1063
|
-
function: '
|
|
672
|
+
function: 'claim_rebates',
|
|
1064
673
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1065
674
|
typeArguments: options.typeArguments,
|
|
1066
675
|
});
|
|
1067
676
|
}
|
|
1068
|
-
export interface
|
|
677
|
+
export interface PlaceLimitOrderV2Arguments {
|
|
1069
678
|
registry: RawTransactionArgument<string>;
|
|
1070
679
|
marginManager: RawTransactionArgument<string>;
|
|
1071
680
|
pool: RawTransactionArgument<string>;
|
|
681
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
682
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
683
|
+
baseOracle: RawTransactionArgument<string>;
|
|
684
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
685
|
+
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
686
|
+
orderType: RawTransactionArgument<number>;
|
|
687
|
+
selfMatchingOption: RawTransactionArgument<number>;
|
|
688
|
+
price: RawTransactionArgument<number | bigint>;
|
|
689
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
690
|
+
isBid: RawTransactionArgument<boolean>;
|
|
691
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
692
|
+
expireTimestamp: RawTransactionArgument<number | bigint>;
|
|
1072
693
|
}
|
|
1073
|
-
export interface
|
|
694
|
+
export interface PlaceLimitOrderV2Options {
|
|
1074
695
|
package?: string;
|
|
1075
696
|
arguments:
|
|
1076
|
-
|
|
|
697
|
+
| PlaceLimitOrderV2Arguments
|
|
1077
698
|
| [
|
|
1078
699
|
registry: RawTransactionArgument<string>,
|
|
1079
700
|
marginManager: RawTransactionArgument<string>,
|
|
1080
701
|
pool: RawTransactionArgument<string>,
|
|
702
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
703
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
704
|
+
baseOracle: RawTransactionArgument<string>,
|
|
705
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
706
|
+
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
707
|
+
orderType: RawTransactionArgument<number>,
|
|
708
|
+
selfMatchingOption: RawTransactionArgument<number>,
|
|
709
|
+
price: RawTransactionArgument<number | bigint>,
|
|
710
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
711
|
+
isBid: RawTransactionArgument<boolean>,
|
|
712
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
713
|
+
expireTimestamp: RawTransactionArgument<number | bigint>,
|
|
1081
714
|
];
|
|
1082
715
|
typeArguments: [string, string];
|
|
1083
716
|
}
|
|
1084
|
-
/**
|
|
1085
|
-
|
|
717
|
+
/**
|
|
718
|
+
* Places a limit order in the pool. Twin:
|
|
719
|
+
* `pool_proxy_upgraded::place_limit_order_v2`. Edit both.
|
|
720
|
+
*/
|
|
721
|
+
export function placeLimitOrderV2(options: PlaceLimitOrderV2Options) {
|
|
1086
722
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1087
|
-
const argumentsTypes = [
|
|
1088
|
-
|
|
723
|
+
const argumentsTypes = [
|
|
724
|
+
null,
|
|
725
|
+
null,
|
|
726
|
+
null,
|
|
727
|
+
null,
|
|
728
|
+
null,
|
|
729
|
+
null,
|
|
730
|
+
null,
|
|
731
|
+
'u64',
|
|
732
|
+
'u8',
|
|
733
|
+
'u8',
|
|
734
|
+
'u64',
|
|
735
|
+
'u64',
|
|
736
|
+
'bool',
|
|
737
|
+
'bool',
|
|
738
|
+
'u64',
|
|
739
|
+
'0x2::clock::Clock',
|
|
740
|
+
] satisfies (string | null)[];
|
|
741
|
+
const parameterNames = [
|
|
742
|
+
'registry',
|
|
743
|
+
'marginManager',
|
|
744
|
+
'pool',
|
|
745
|
+
'baseMarginPool',
|
|
746
|
+
'quoteMarginPool',
|
|
747
|
+
'baseOracle',
|
|
748
|
+
'quoteOracle',
|
|
749
|
+
'clientOrderId',
|
|
750
|
+
'orderType',
|
|
751
|
+
'selfMatchingOption',
|
|
752
|
+
'price',
|
|
753
|
+
'quantity',
|
|
754
|
+
'isBid',
|
|
755
|
+
'payWithDeep',
|
|
756
|
+
'expireTimestamp',
|
|
757
|
+
];
|
|
1089
758
|
return (tx: Transaction) =>
|
|
1090
759
|
tx.moveCall({
|
|
1091
760
|
package: packageAddress,
|
|
1092
761
|
module: 'pool_proxy',
|
|
1093
|
-
function: '
|
|
762
|
+
function: 'place_limit_order_v2',
|
|
1094
763
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1095
764
|
typeArguments: options.typeArguments,
|
|
1096
765
|
});
|
|
1097
766
|
}
|
|
1098
|
-
export interface
|
|
767
|
+
export interface PlaceMarketOrderV2Arguments {
|
|
1099
768
|
registry: RawTransactionArgument<string>;
|
|
1100
769
|
marginManager: RawTransactionArgument<string>;
|
|
1101
770
|
pool: RawTransactionArgument<string>;
|
|
771
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
772
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
773
|
+
baseOracle: RawTransactionArgument<string>;
|
|
774
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
775
|
+
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
776
|
+
selfMatchingOption: RawTransactionArgument<number>;
|
|
777
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
778
|
+
isBid: RawTransactionArgument<boolean>;
|
|
779
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
1102
780
|
}
|
|
1103
|
-
export interface
|
|
781
|
+
export interface PlaceMarketOrderV2Options {
|
|
1104
782
|
package?: string;
|
|
1105
783
|
arguments:
|
|
1106
|
-
|
|
|
784
|
+
| PlaceMarketOrderV2Arguments
|
|
1107
785
|
| [
|
|
1108
786
|
registry: RawTransactionArgument<string>,
|
|
1109
787
|
marginManager: RawTransactionArgument<string>,
|
|
1110
788
|
pool: RawTransactionArgument<string>,
|
|
789
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
790
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
791
|
+
baseOracle: RawTransactionArgument<string>,
|
|
792
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
793
|
+
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
794
|
+
selfMatchingOption: RawTransactionArgument<number>,
|
|
795
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
796
|
+
isBid: RawTransactionArgument<boolean>,
|
|
797
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
1111
798
|
];
|
|
1112
799
|
typeArguments: [string, string];
|
|
1113
800
|
}
|
|
1114
801
|
/**
|
|
1115
|
-
*
|
|
1116
|
-
*
|
|
802
|
+
* Places a market order in the pool. Twin:
|
|
803
|
+
* `pool_proxy_upgraded::place_market_order_v2`. Edit both.
|
|
1117
804
|
*/
|
|
1118
|
-
export function
|
|
1119
|
-
options: WithdrawSettledAmountsPermissionlessOptions,
|
|
1120
|
-
) {
|
|
805
|
+
export function placeMarketOrderV2(options: PlaceMarketOrderV2Options) {
|
|
1121
806
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1122
|
-
const argumentsTypes = [
|
|
1123
|
-
|
|
807
|
+
const argumentsTypes = [
|
|
808
|
+
null,
|
|
809
|
+
null,
|
|
810
|
+
null,
|
|
811
|
+
null,
|
|
812
|
+
null,
|
|
813
|
+
null,
|
|
814
|
+
null,
|
|
815
|
+
'u64',
|
|
816
|
+
'u8',
|
|
817
|
+
'u64',
|
|
818
|
+
'bool',
|
|
819
|
+
'bool',
|
|
820
|
+
'0x2::clock::Clock',
|
|
821
|
+
] satisfies (string | null)[];
|
|
822
|
+
const parameterNames = [
|
|
823
|
+
'registry',
|
|
824
|
+
'marginManager',
|
|
825
|
+
'pool',
|
|
826
|
+
'baseMarginPool',
|
|
827
|
+
'quoteMarginPool',
|
|
828
|
+
'baseOracle',
|
|
829
|
+
'quoteOracle',
|
|
830
|
+
'clientOrderId',
|
|
831
|
+
'selfMatchingOption',
|
|
832
|
+
'quantity',
|
|
833
|
+
'isBid',
|
|
834
|
+
'payWithDeep',
|
|
835
|
+
];
|
|
1124
836
|
return (tx: Transaction) =>
|
|
1125
837
|
tx.moveCall({
|
|
1126
838
|
package: packageAddress,
|
|
1127
839
|
module: 'pool_proxy',
|
|
1128
|
-
function: '
|
|
840
|
+
function: 'place_market_order_v2',
|
|
1129
841
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1130
842
|
typeArguments: options.typeArguments,
|
|
1131
843
|
});
|
|
1132
844
|
}
|
|
1133
|
-
export interface
|
|
845
|
+
export interface PlaceReduceOnlyLimitOrderV2Arguments {
|
|
1134
846
|
registry: RawTransactionArgument<string>;
|
|
1135
847
|
marginManager: RawTransactionArgument<string>;
|
|
1136
848
|
pool: RawTransactionArgument<string>;
|
|
1137
|
-
|
|
849
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
850
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
851
|
+
baseOracle: RawTransactionArgument<string>;
|
|
852
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
853
|
+
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
854
|
+
orderType: RawTransactionArgument<number>;
|
|
855
|
+
selfMatchingOption: RawTransactionArgument<number>;
|
|
856
|
+
price: RawTransactionArgument<number | bigint>;
|
|
857
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
858
|
+
isBid: RawTransactionArgument<boolean>;
|
|
859
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
860
|
+
expireTimestamp: RawTransactionArgument<number | bigint>;
|
|
1138
861
|
}
|
|
1139
|
-
export interface
|
|
862
|
+
export interface PlaceReduceOnlyLimitOrderV2Options {
|
|
1140
863
|
package?: string;
|
|
1141
864
|
arguments:
|
|
1142
|
-
|
|
|
865
|
+
| PlaceReduceOnlyLimitOrderV2Arguments
|
|
1143
866
|
| [
|
|
1144
867
|
registry: RawTransactionArgument<string>,
|
|
1145
868
|
marginManager: RawTransactionArgument<string>,
|
|
1146
869
|
pool: RawTransactionArgument<string>,
|
|
1147
|
-
|
|
870
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
871
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
872
|
+
baseOracle: RawTransactionArgument<string>,
|
|
873
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
874
|
+
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
875
|
+
orderType: RawTransactionArgument<number>,
|
|
876
|
+
selfMatchingOption: RawTransactionArgument<number>,
|
|
877
|
+
price: RawTransactionArgument<number | bigint>,
|
|
878
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
879
|
+
isBid: RawTransactionArgument<boolean>,
|
|
880
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
881
|
+
expireTimestamp: RawTransactionArgument<number | bigint>,
|
|
1148
882
|
];
|
|
1149
883
|
typeArguments: [string, string];
|
|
1150
884
|
}
|
|
1151
|
-
/**
|
|
1152
|
-
|
|
885
|
+
/**
|
|
886
|
+
* Places a reduce-only order in the pool. Used when margin trading is disabled.
|
|
887
|
+
* Twin: `pool_proxy_upgraded::place_reduce_only_limit_order_v2`. Edit both.
|
|
888
|
+
*/
|
|
889
|
+
export function placeReduceOnlyLimitOrderV2(options: PlaceReduceOnlyLimitOrderV2Options) {
|
|
1153
890
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1154
|
-
const argumentsTypes = [
|
|
1155
|
-
|
|
891
|
+
const argumentsTypes = [
|
|
892
|
+
null,
|
|
893
|
+
null,
|
|
894
|
+
null,
|
|
895
|
+
null,
|
|
896
|
+
null,
|
|
897
|
+
null,
|
|
898
|
+
null,
|
|
899
|
+
'u64',
|
|
900
|
+
'u8',
|
|
901
|
+
'u8',
|
|
902
|
+
'u64',
|
|
903
|
+
'u64',
|
|
904
|
+
'bool',
|
|
905
|
+
'bool',
|
|
906
|
+
'u64',
|
|
907
|
+
'0x2::clock::Clock',
|
|
908
|
+
] satisfies (string | null)[];
|
|
909
|
+
const parameterNames = [
|
|
910
|
+
'registry',
|
|
911
|
+
'marginManager',
|
|
912
|
+
'pool',
|
|
913
|
+
'baseMarginPool',
|
|
914
|
+
'quoteMarginPool',
|
|
915
|
+
'baseOracle',
|
|
916
|
+
'quoteOracle',
|
|
917
|
+
'clientOrderId',
|
|
918
|
+
'orderType',
|
|
919
|
+
'selfMatchingOption',
|
|
920
|
+
'price',
|
|
921
|
+
'quantity',
|
|
922
|
+
'isBid',
|
|
923
|
+
'payWithDeep',
|
|
924
|
+
'expireTimestamp',
|
|
925
|
+
];
|
|
1156
926
|
return (tx: Transaction) =>
|
|
1157
927
|
tx.moveCall({
|
|
1158
928
|
package: packageAddress,
|
|
1159
929
|
module: 'pool_proxy',
|
|
1160
|
-
function: '
|
|
930
|
+
function: 'place_reduce_only_limit_order_v2',
|
|
1161
931
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1162
932
|
typeArguments: options.typeArguments,
|
|
1163
933
|
});
|
|
1164
934
|
}
|
|
1165
|
-
export interface
|
|
935
|
+
export interface PlaceReduceOnlyMarketOrderV2Arguments {
|
|
1166
936
|
registry: RawTransactionArgument<string>;
|
|
1167
937
|
marginManager: RawTransactionArgument<string>;
|
|
1168
938
|
pool: RawTransactionArgument<string>;
|
|
939
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
940
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
941
|
+
baseOracle: RawTransactionArgument<string>;
|
|
942
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
943
|
+
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
944
|
+
selfMatchingOption: RawTransactionArgument<number>;
|
|
945
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
946
|
+
isBid: RawTransactionArgument<boolean>;
|
|
947
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
1169
948
|
}
|
|
1170
|
-
export interface
|
|
949
|
+
export interface PlaceReduceOnlyMarketOrderV2Options {
|
|
1171
950
|
package?: string;
|
|
1172
951
|
arguments:
|
|
1173
|
-
|
|
|
952
|
+
| PlaceReduceOnlyMarketOrderV2Arguments
|
|
1174
953
|
| [
|
|
1175
954
|
registry: RawTransactionArgument<string>,
|
|
1176
955
|
marginManager: RawTransactionArgument<string>,
|
|
1177
956
|
pool: RawTransactionArgument<string>,
|
|
957
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
958
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
959
|
+
baseOracle: RawTransactionArgument<string>,
|
|
960
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
961
|
+
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
962
|
+
selfMatchingOption: RawTransactionArgument<number>,
|
|
963
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
964
|
+
isBid: RawTransactionArgument<boolean>,
|
|
965
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
1178
966
|
];
|
|
1179
967
|
typeArguments: [string, string];
|
|
1180
968
|
}
|
|
1181
|
-
/**
|
|
1182
|
-
|
|
969
|
+
/**
|
|
970
|
+
* Places a reduce-only market order in the pool. Used when margin trading is
|
|
971
|
+
* disabled.
|
|
972
|
+
*
|
|
973
|
+
* Superseded by `place_reduce_only_market_order_and_repay_loan`. A market (taker)
|
|
974
|
+
* fill always pays the spread, which lowers the oracle-valued `risk_ratio` while
|
|
975
|
+
* the debt is unchanged, so the swap-only monotonic check here rejects essentially
|
|
976
|
+
* every taker fill. The `_and_repay` variant deleverages with the proceeds so the
|
|
977
|
+
* net-state ratio actually improves. Kept callable for existing integrators; its
|
|
978
|
+
* reduce-only _direction_ guard matches the other entries — a bid needs base
|
|
979
|
+
* (short-side) debt, the ask needs quote (long-side) debt and sells up to gross
|
|
980
|
+
* base held — with no size cap. Twin:
|
|
981
|
+
* `pool_proxy_upgraded::place_reduce_only_market_order_v2`. Edit both.
|
|
982
|
+
*/
|
|
983
|
+
export function placeReduceOnlyMarketOrderV2(options: PlaceReduceOnlyMarketOrderV2Options) {
|
|
1183
984
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1184
|
-
const argumentsTypes = [
|
|
1185
|
-
|
|
985
|
+
const argumentsTypes = [
|
|
986
|
+
null,
|
|
987
|
+
null,
|
|
988
|
+
null,
|
|
989
|
+
null,
|
|
990
|
+
null,
|
|
991
|
+
null,
|
|
992
|
+
null,
|
|
993
|
+
'u64',
|
|
994
|
+
'u8',
|
|
995
|
+
'u64',
|
|
996
|
+
'bool',
|
|
997
|
+
'bool',
|
|
998
|
+
'0x2::clock::Clock',
|
|
999
|
+
] satisfies (string | null)[];
|
|
1000
|
+
const parameterNames = [
|
|
1001
|
+
'registry',
|
|
1002
|
+
'marginManager',
|
|
1003
|
+
'pool',
|
|
1004
|
+
'baseMarginPool',
|
|
1005
|
+
'quoteMarginPool',
|
|
1006
|
+
'baseOracle',
|
|
1007
|
+
'quoteOracle',
|
|
1008
|
+
'clientOrderId',
|
|
1009
|
+
'selfMatchingOption',
|
|
1010
|
+
'quantity',
|
|
1011
|
+
'isBid',
|
|
1012
|
+
'payWithDeep',
|
|
1013
|
+
];
|
|
1186
1014
|
return (tx: Transaction) =>
|
|
1187
1015
|
tx.moveCall({
|
|
1188
1016
|
package: packageAddress,
|
|
1189
1017
|
module: 'pool_proxy',
|
|
1190
|
-
function: '
|
|
1018
|
+
function: 'place_reduce_only_market_order_v2',
|
|
1191
1019
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1192
1020
|
typeArguments: options.typeArguments,
|
|
1193
1021
|
});
|
|
1194
1022
|
}
|
|
1195
|
-
export interface
|
|
1023
|
+
export interface PlaceReduceOnlyMarketOrderAndRepayLoanArguments {
|
|
1196
1024
|
registry: RawTransactionArgument<string>;
|
|
1197
1025
|
marginManager: RawTransactionArgument<string>;
|
|
1198
1026
|
pool: RawTransactionArgument<string>;
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1027
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
1028
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
1029
|
+
baseOracle: RawTransactionArgument<string>;
|
|
1030
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
1031
|
+
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
1032
|
+
selfMatchingOption: RawTransactionArgument<number>;
|
|
1033
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
1034
|
+
isBid: RawTransactionArgument<boolean>;
|
|
1035
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
1202
1036
|
}
|
|
1203
|
-
export interface
|
|
1037
|
+
export interface PlaceReduceOnlyMarketOrderAndRepayLoanOptions {
|
|
1204
1038
|
package?: string;
|
|
1205
1039
|
arguments:
|
|
1206
|
-
|
|
|
1040
|
+
| PlaceReduceOnlyMarketOrderAndRepayLoanArguments
|
|
1207
1041
|
| [
|
|
1208
1042
|
registry: RawTransactionArgument<string>,
|
|
1209
1043
|
marginManager: RawTransactionArgument<string>,
|
|
1210
1044
|
pool: RawTransactionArgument<string>,
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1045
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
1046
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
1047
|
+
baseOracle: RawTransactionArgument<string>,
|
|
1048
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
1049
|
+
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
1050
|
+
selfMatchingOption: RawTransactionArgument<number>,
|
|
1051
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
1052
|
+
isBid: RawTransactionArgument<boolean>,
|
|
1053
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
1214
1054
|
];
|
|
1215
1055
|
typeArguments: [string, string];
|
|
1216
1056
|
}
|
|
1217
|
-
/**
|
|
1218
|
-
|
|
1057
|
+
/**
|
|
1058
|
+
* Atomically winds down a leveraged position: places a reduce-only market order,
|
|
1059
|
+
* repays the loan with the proceeds, then requires the net (post-repay) risk ratio
|
|
1060
|
+
* to be at least the pre-trade ratio.
|
|
1061
|
+
*
|
|
1062
|
+
* The post-repay check is the point. A market close pays the spread, which alone
|
|
1063
|
+
* lowers the oracle-valued ratio (debt is unchanged until repay) and would abort
|
|
1064
|
+
* the plain reduce-only path. Repaying first deleverages and absorbs the slippage
|
|
1065
|
+
* (still bounded by the `assert_price` band), and lets a manager in the
|
|
1066
|
+
* `liquidation..min_borrow` band climb out — it cannot reach the borrow floor in a
|
|
1067
|
+
* single swap. Twin:
|
|
1068
|
+
* `pool_proxy_upgraded::place_reduce_only_market_order_and_repay_loan`. Edit both.
|
|
1069
|
+
*/
|
|
1070
|
+
export function placeReduceOnlyMarketOrderAndRepayLoan(
|
|
1071
|
+
options: PlaceReduceOnlyMarketOrderAndRepayLoanOptions,
|
|
1072
|
+
) {
|
|
1219
1073
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1220
|
-
const argumentsTypes = [
|
|
1074
|
+
const argumentsTypes = [
|
|
1075
|
+
null,
|
|
1076
|
+
null,
|
|
1077
|
+
null,
|
|
1078
|
+
null,
|
|
1079
|
+
null,
|
|
1080
|
+
null,
|
|
1081
|
+
null,
|
|
1082
|
+
'u64',
|
|
1083
|
+
'u8',
|
|
1084
|
+
'u64',
|
|
1085
|
+
'bool',
|
|
1086
|
+
'bool',
|
|
1087
|
+
'0x2::clock::Clock',
|
|
1088
|
+
] satisfies (string | null)[];
|
|
1221
1089
|
const parameterNames = [
|
|
1222
1090
|
'registry',
|
|
1223
1091
|
'marginManager',
|
|
1224
1092
|
'pool',
|
|
1225
|
-
'
|
|
1226
|
-
'
|
|
1227
|
-
'
|
|
1093
|
+
'baseMarginPool',
|
|
1094
|
+
'quoteMarginPool',
|
|
1095
|
+
'baseOracle',
|
|
1096
|
+
'quoteOracle',
|
|
1097
|
+
'clientOrderId',
|
|
1098
|
+
'selfMatchingOption',
|
|
1099
|
+
'quantity',
|
|
1100
|
+
'isBid',
|
|
1101
|
+
'payWithDeep',
|
|
1228
1102
|
];
|
|
1229
1103
|
return (tx: Transaction) =>
|
|
1230
1104
|
tx.moveCall({
|
|
1231
1105
|
package: packageAddress,
|
|
1232
1106
|
module: 'pool_proxy',
|
|
1233
|
-
function: '
|
|
1107
|
+
function: 'place_reduce_only_market_order_and_repay_loan',
|
|
1234
1108
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1235
1109
|
typeArguments: options.typeArguments,
|
|
1236
1110
|
});
|
|
1237
1111
|
}
|
|
1238
|
-
export interface
|
|
1112
|
+
export interface PlaceReduceOnlyLimitOrderAndRepayLoanArguments {
|
|
1239
1113
|
registry: RawTransactionArgument<string>;
|
|
1240
1114
|
marginManager: RawTransactionArgument<string>;
|
|
1241
1115
|
pool: RawTransactionArgument<string>;
|
|
1242
|
-
|
|
1116
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
1117
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
1118
|
+
baseOracle: RawTransactionArgument<string>;
|
|
1119
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
1120
|
+
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
1121
|
+
orderType: RawTransactionArgument<number>;
|
|
1122
|
+
selfMatchingOption: RawTransactionArgument<number>;
|
|
1123
|
+
price: RawTransactionArgument<number | bigint>;
|
|
1124
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
1125
|
+
isBid: RawTransactionArgument<boolean>;
|
|
1126
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
1127
|
+
expireTimestamp: RawTransactionArgument<number | bigint>;
|
|
1243
1128
|
}
|
|
1244
|
-
export interface
|
|
1129
|
+
export interface PlaceReduceOnlyLimitOrderAndRepayLoanOptions {
|
|
1245
1130
|
package?: string;
|
|
1246
1131
|
arguments:
|
|
1247
|
-
|
|
|
1132
|
+
| PlaceReduceOnlyLimitOrderAndRepayLoanArguments
|
|
1248
1133
|
| [
|
|
1249
1134
|
registry: RawTransactionArgument<string>,
|
|
1250
1135
|
marginManager: RawTransactionArgument<string>,
|
|
1251
1136
|
pool: RawTransactionArgument<string>,
|
|
1252
|
-
|
|
1137
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
1138
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
1139
|
+
baseOracle: RawTransactionArgument<string>,
|
|
1140
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
1141
|
+
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
1142
|
+
orderType: RawTransactionArgument<number>,
|
|
1143
|
+
selfMatchingOption: RawTransactionArgument<number>,
|
|
1144
|
+
price: RawTransactionArgument<number | bigint>,
|
|
1145
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
1146
|
+
isBid: RawTransactionArgument<boolean>,
|
|
1147
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
1148
|
+
expireTimestamp: RawTransactionArgument<number | bigint>,
|
|
1253
1149
|
];
|
|
1254
1150
|
typeArguments: [string, string];
|
|
1255
1151
|
}
|
|
1256
|
-
/**
|
|
1257
|
-
|
|
1152
|
+
/**
|
|
1153
|
+
* Reduce-only **limit** order that atomically repays the loan with the taker
|
|
1154
|
+
* fills. It is the limit/maker behaviour of `place_reduce_only_limit_order_v2`
|
|
1155
|
+
* plus the repay-then-net-monotonic gate of
|
|
1156
|
+
* `place_reduce_only_market_order_and_repay_loan`: the portion that crosses the
|
|
1157
|
+
* book fills immediately and settles, the rest rests as a maker, then the settled
|
|
1158
|
+
* (taker) proceeds repay the debt before the monotonic check on the net
|
|
1159
|
+
* (post-repay) state.
|
|
1160
|
+
*
|
|
1161
|
+
* This is the danger-band tool for a _price-bounded_ reduce: a crossing
|
|
1162
|
+
* reduce-only limit pays the spread on its taker fills, which alone would abort
|
|
1163
|
+
* `place_reduce_only_limit_order_v2`'s swap-only monotonic check; repaying first
|
|
1164
|
+
* deleverages so the net ratio holds. The resting remainder only locks balance
|
|
1165
|
+
* (counted in assets), so it doesn't move the ratio. Unfilled-and-resting behaves
|
|
1166
|
+
* exactly like `place_reduce_only_limit_order_v2` (nothing to repay). Twin:
|
|
1167
|
+
* `pool_proxy_upgraded::place_reduce_only_limit_order_and_repay_loan`. Edit both.
|
|
1168
|
+
*/
|
|
1169
|
+
export function placeReduceOnlyLimitOrderAndRepayLoan(
|
|
1170
|
+
options: PlaceReduceOnlyLimitOrderAndRepayLoanOptions,
|
|
1171
|
+
) {
|
|
1258
1172
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1259
|
-
const argumentsTypes = [
|
|
1260
|
-
|
|
1173
|
+
const argumentsTypes = [
|
|
1174
|
+
null,
|
|
1175
|
+
null,
|
|
1176
|
+
null,
|
|
1177
|
+
null,
|
|
1178
|
+
null,
|
|
1179
|
+
null,
|
|
1180
|
+
null,
|
|
1181
|
+
'u64',
|
|
1182
|
+
'u8',
|
|
1183
|
+
'u8',
|
|
1184
|
+
'u64',
|
|
1185
|
+
'u64',
|
|
1186
|
+
'bool',
|
|
1187
|
+
'bool',
|
|
1188
|
+
'u64',
|
|
1189
|
+
'0x2::clock::Clock',
|
|
1190
|
+
] satisfies (string | null)[];
|
|
1191
|
+
const parameterNames = [
|
|
1192
|
+
'registry',
|
|
1193
|
+
'marginManager',
|
|
1194
|
+
'pool',
|
|
1195
|
+
'baseMarginPool',
|
|
1196
|
+
'quoteMarginPool',
|
|
1197
|
+
'baseOracle',
|
|
1198
|
+
'quoteOracle',
|
|
1199
|
+
'clientOrderId',
|
|
1200
|
+
'orderType',
|
|
1201
|
+
'selfMatchingOption',
|
|
1202
|
+
'price',
|
|
1203
|
+
'quantity',
|
|
1204
|
+
'isBid',
|
|
1205
|
+
'payWithDeep',
|
|
1206
|
+
'expireTimestamp',
|
|
1207
|
+
];
|
|
1261
1208
|
return (tx: Transaction) =>
|
|
1262
1209
|
tx.moveCall({
|
|
1263
1210
|
package: packageAddress,
|
|
1264
1211
|
module: 'pool_proxy',
|
|
1265
|
-
function: '
|
|
1212
|
+
function: 'place_reduce_only_limit_order_and_repay_loan',
|
|
1266
1213
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1267
1214
|
typeArguments: options.typeArguments,
|
|
1268
1215
|
});
|
|
1269
1216
|
}
|
|
1270
|
-
export interface
|
|
1217
|
+
export interface PlaceMarketOrderAndRepayLoanArguments {
|
|
1271
1218
|
registry: RawTransactionArgument<string>;
|
|
1272
1219
|
marginManager: RawTransactionArgument<string>;
|
|
1273
1220
|
pool: RawTransactionArgument<string>;
|
|
1221
|
+
baseMarginPool: RawTransactionArgument<string>;
|
|
1222
|
+
quoteMarginPool: RawTransactionArgument<string>;
|
|
1223
|
+
baseOracle: RawTransactionArgument<string>;
|
|
1224
|
+
quoteOracle: RawTransactionArgument<string>;
|
|
1225
|
+
clientOrderId: RawTransactionArgument<number | bigint>;
|
|
1226
|
+
selfMatchingOption: RawTransactionArgument<number>;
|
|
1227
|
+
quantity: RawTransactionArgument<number | bigint>;
|
|
1228
|
+
isBid: RawTransactionArgument<boolean>;
|
|
1229
|
+
payWithDeep: RawTransactionArgument<boolean>;
|
|
1274
1230
|
}
|
|
1275
|
-
export interface
|
|
1231
|
+
export interface PlaceMarketOrderAndRepayLoanOptions {
|
|
1276
1232
|
package?: string;
|
|
1277
1233
|
arguments:
|
|
1278
|
-
|
|
|
1234
|
+
| PlaceMarketOrderAndRepayLoanArguments
|
|
1279
1235
|
| [
|
|
1280
1236
|
registry: RawTransactionArgument<string>,
|
|
1281
1237
|
marginManager: RawTransactionArgument<string>,
|
|
1282
1238
|
pool: RawTransactionArgument<string>,
|
|
1239
|
+
baseMarginPool: RawTransactionArgument<string>,
|
|
1240
|
+
quoteMarginPool: RawTransactionArgument<string>,
|
|
1241
|
+
baseOracle: RawTransactionArgument<string>,
|
|
1242
|
+
quoteOracle: RawTransactionArgument<string>,
|
|
1243
|
+
clientOrderId: RawTransactionArgument<number | bigint>,
|
|
1244
|
+
selfMatchingOption: RawTransactionArgument<number>,
|
|
1245
|
+
quantity: RawTransactionArgument<number | bigint>,
|
|
1246
|
+
isBid: RawTransactionArgument<boolean>,
|
|
1247
|
+
payWithDeep: RawTransactionArgument<boolean>,
|
|
1283
1248
|
];
|
|
1284
1249
|
typeArguments: [string, string];
|
|
1285
1250
|
}
|
|
1286
|
-
|
|
1251
|
+
/**
|
|
1252
|
+
* Atomically places a market order and repays the loan with the proceeds, gating
|
|
1253
|
+
* on a **monotonic** net-state check: if any debt remains after the repay, the
|
|
1254
|
+
* post-repay `risk_ratio` must be at least the pre-trade ratio (improve-or-hold).
|
|
1255
|
+
* A full close drives debt to 0 (`risk_ratio` MAX), which always passes.
|
|
1256
|
+
*
|
|
1257
|
+
* This is the everyday close / deleverage tool. The monotonic gate — rather than
|
|
1258
|
+
* the `min_open` opening floor used by `place_market_order_v2` — lets a position
|
|
1259
|
+
* in the `liquidation..min_borrow` danger band wind down _partially_: a small
|
|
1260
|
+
* close that lifts the ratio from, say, 1.12 to 1.15 is allowed even though 1.15
|
|
1261
|
+
* is still below `min_open`, which the opening floor would reject.
|
|
1262
|
+
*
|
|
1263
|
+
* Not reduce-only and uncapped, but the monotonic check makes a quantity cap
|
|
1264
|
+
* unnecessary: a market (taker) fill settles immediately, so any genuinely
|
|
1265
|
+
* exposure-_increasing_ trade lowers the ratio and aborts here, while any
|
|
1266
|
+
* deleveraging trade is allowed at any size — an overshoot past the debt is fine
|
|
1267
|
+
* (surplus is the manager's own holding) and `assert_price` still bounds slippage.
|
|
1268
|
+
* Requires margin trading enabled; in reduce-only mode use
|
|
1269
|
+
* `place_reduce_only_market_order_and_repay_loan`. Twin:
|
|
1270
|
+
* `pool_proxy_upgraded::place_market_order_and_repay_loan`. Edit both.
|
|
1271
|
+
*/
|
|
1272
|
+
export function placeMarketOrderAndRepayLoan(options: PlaceMarketOrderAndRepayLoanOptions) {
|
|
1287
1273
|
const packageAddress = options.package ?? '@deepbook/margin';
|
|
1288
|
-
const argumentsTypes = [
|
|
1289
|
-
|
|
1274
|
+
const argumentsTypes = [
|
|
1275
|
+
null,
|
|
1276
|
+
null,
|
|
1277
|
+
null,
|
|
1278
|
+
null,
|
|
1279
|
+
null,
|
|
1280
|
+
null,
|
|
1281
|
+
null,
|
|
1282
|
+
'u64',
|
|
1283
|
+
'u8',
|
|
1284
|
+
'u64',
|
|
1285
|
+
'bool',
|
|
1286
|
+
'bool',
|
|
1287
|
+
'0x2::clock::Clock',
|
|
1288
|
+
] satisfies (string | null)[];
|
|
1289
|
+
const parameterNames = [
|
|
1290
|
+
'registry',
|
|
1291
|
+
'marginManager',
|
|
1292
|
+
'pool',
|
|
1293
|
+
'baseMarginPool',
|
|
1294
|
+
'quoteMarginPool',
|
|
1295
|
+
'baseOracle',
|
|
1296
|
+
'quoteOracle',
|
|
1297
|
+
'clientOrderId',
|
|
1298
|
+
'selfMatchingOption',
|
|
1299
|
+
'quantity',
|
|
1300
|
+
'isBid',
|
|
1301
|
+
'payWithDeep',
|
|
1302
|
+
];
|
|
1290
1303
|
return (tx: Transaction) =>
|
|
1291
1304
|
tx.moveCall({
|
|
1292
1305
|
package: packageAddress,
|
|
1293
1306
|
module: 'pool_proxy',
|
|
1294
|
-
function: '
|
|
1307
|
+
function: 'place_market_order_and_repay_loan',
|
|
1295
1308
|
arguments: normalizeMoveArguments(options.arguments, argumentsTypes, parameterNames),
|
|
1296
1309
|
typeArguments: options.typeArguments,
|
|
1297
1310
|
});
|