@mysten/deepbook-v3 1.1.5 → 1.2.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 +23 -0
- package/dist/client.d.mts +58 -763
- package/dist/client.d.mts.map +1 -1
- package/dist/client.mjs +253 -2127
- package/dist/client.mjs.map +1 -1
- package/dist/contracts/utils/index.mjs +1 -1
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +4 -4
- package/dist/pyth/pyth.mjs +1 -1
- package/dist/queries/accountQueries.mjs +104 -0
- package/dist/queries/accountQueries.mjs.map +1 -0
- package/dist/queries/balanceManagerQueries.mjs +113 -0
- package/dist/queries/balanceManagerQueries.mjs.map +1 -0
- package/dist/queries/context.mjs +15 -0
- package/dist/queries/context.mjs.map +1 -0
- package/dist/queries/marginManagerQueries.mjs +365 -0
- package/dist/queries/marginManagerQueries.mjs.map +1 -0
- package/dist/queries/marginPoolQueries.mjs +184 -0
- package/dist/queries/marginPoolQueries.mjs.map +1 -0
- package/dist/queries/orderQueries.mjs +165 -0
- package/dist/queries/orderQueries.mjs.map +1 -0
- package/dist/queries/poolQueries.mjs +234 -0
- package/dist/queries/poolQueries.mjs.map +1 -0
- package/dist/queries/priceFeedQueries.mjs +83 -0
- package/dist/queries/priceFeedQueries.mjs.map +1 -0
- package/dist/queries/quantityQueries.mjs +216 -0
- package/dist/queries/quantityQueries.mjs.map +1 -0
- package/dist/queries/referralQueries.mjs +96 -0
- package/dist/queries/referralQueries.mjs.map +1 -0
- package/dist/queries/registryQueries.mjs +162 -0
- package/dist/queries/registryQueries.mjs.map +1 -0
- package/dist/queries/tpslQueries.mjs +62 -0
- package/dist/queries/tpslQueries.mjs.map +1 -0
- package/dist/transactions/balanceManager.d.mts +12 -12
- package/dist/transactions/balanceManager.d.mts.map +1 -1
- package/dist/transactions/balanceManager.mjs +5 -4
- package/dist/transactions/balanceManager.mjs.map +1 -1
- package/dist/transactions/deepbook.d.mts +24 -24
- package/dist/transactions/deepbook.d.mts.map +1 -1
- package/dist/transactions/deepbook.mjs +48 -47
- package/dist/transactions/deepbook.mjs.map +1 -1
- package/dist/transactions/deepbookAdmin.d.mts +2 -2
- package/dist/transactions/deepbookAdmin.d.mts.map +1 -1
- package/dist/transactions/deepbookAdmin.mjs +10 -9
- package/dist/transactions/deepbookAdmin.mjs.map +1 -1
- package/dist/transactions/flashLoans.d.mts.map +1 -1
- package/dist/transactions/flashLoans.mjs +6 -4
- package/dist/transactions/flashLoans.mjs.map +1 -1
- package/dist/transactions/governance.d.mts.map +1 -1
- package/dist/transactions/governance.mjs +5 -4
- package/dist/transactions/governance.mjs.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 +8 -7
- package/dist/transactions/marginAdmin.mjs.map +1 -1
- package/dist/transactions/marginLiquidations.d.mts.map +1 -1
- package/dist/transactions/marginLiquidations.mjs +5 -4
- package/dist/transactions/marginLiquidations.mjs.map +1 -1
- package/dist/transactions/marginMaintainer.d.mts +5 -5
- package/dist/transactions/marginMaintainer.d.mts.map +1 -1
- package/dist/transactions/marginMaintainer.mjs +15 -14
- package/dist/transactions/marginMaintainer.mjs.map +1 -1
- package/dist/transactions/marginManager.d.mts +23 -23
- package/dist/transactions/marginManager.d.mts.map +1 -1
- package/dist/transactions/marginManager.mjs +17 -12
- package/dist/transactions/marginManager.mjs.map +1 -1
- package/dist/transactions/marginPool.d.mts.map +1 -1
- package/dist/transactions/marginPool.mjs +3 -2
- package/dist/transactions/marginPool.mjs.map +1 -1
- package/dist/transactions/marginTPSL.d.mts +1 -1
- package/dist/transactions/marginTPSL.d.mts.map +1 -1
- package/dist/transactions/marginTPSL.mjs +6 -8
- package/dist/transactions/marginTPSL.mjs.map +1 -1
- package/dist/transactions/poolProxy.d.mts.map +1 -1
- package/dist/transactions/poolProxy.mjs +13 -13
- package/dist/transactions/poolProxy.mjs.map +1 -1
- package/dist/types/index.d.mts +189 -52
- package/dist/types/index.d.mts.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/dist/utils/constants.d.mts +4 -0
- package/dist/utils/constants.d.mts.map +1 -1
- package/dist/utils/constants.mjs +12 -5
- package/dist/utils/constants.mjs.map +1 -1
- package/dist/utils/conversion.mjs +26 -0
- package/dist/utils/conversion.mjs.map +1 -0
- package/package.json +6 -5
- package/src/client.ts +421 -2662
- package/src/index.ts +27 -0
- package/src/queries/accountQueries.ts +117 -0
- package/src/queries/balanceManagerQueries.ts +156 -0
- package/src/queries/context.ts +44 -0
- package/src/queries/index.ts +16 -0
- package/src/queries/marginManagerQueries.ts +575 -0
- package/src/queries/marginPoolQueries.ts +226 -0
- package/src/queries/orderQueries.ts +202 -0
- package/src/queries/poolQueries.ts +266 -0
- package/src/queries/priceFeedQueries.ts +141 -0
- package/src/queries/quantityQueries.ts +266 -0
- package/src/queries/referralQueries.ts +112 -0
- package/src/queries/registryQueries.ts +185 -0
- package/src/queries/tpslQueries.ts +88 -0
- package/src/transactions/balanceManager.ts +5 -4
- package/src/transactions/deepbook.ts +98 -84
- package/src/transactions/deepbookAdmin.ts +10 -9
- package/src/transactions/flashLoans.ts +5 -4
- package/src/transactions/governance.ts +5 -4
- package/src/transactions/marginAdmin.ts +8 -7
- package/src/transactions/marginLiquidations.ts +5 -4
- package/src/transactions/marginMaintainer.ts +15 -14
- package/src/transactions/marginManager.ts +13 -12
- package/src/transactions/marginPool.ts +3 -2
- package/src/transactions/marginTPSL.ts +11 -6
- package/src/transactions/poolProxy.ts +12 -11
- package/src/types/index.ts +200 -53
- package/src/utils/constants.ts +12 -5
- package/src/utils/conversion.ts +33 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Copyright (c) Mysten Labs, Inc.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { bcs } from '@mysten/sui/bcs';
|
|
5
|
+
import { Transaction } from '@mysten/sui/transactions';
|
|
6
|
+
|
|
7
|
+
import type { QueryContext } from './context.js';
|
|
8
|
+
|
|
9
|
+
export class TPSLQueries {
|
|
10
|
+
#ctx: QueryContext;
|
|
11
|
+
|
|
12
|
+
constructor(ctx: QueryContext) {
|
|
13
|
+
this.#ctx = ctx;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async getConditionalOrderIds(marginManagerKey: string): Promise<string[]> {
|
|
17
|
+
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
18
|
+
const tx = new Transaction();
|
|
19
|
+
tx.add(this.#ctx.marginTPSL.conditionalOrderIds(manager.poolKey, manager.address));
|
|
20
|
+
|
|
21
|
+
const res = await this.#ctx.client.core.simulateTransaction({
|
|
22
|
+
transaction: tx,
|
|
23
|
+
include: { commandResults: true, effects: true },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (res.FailedTransaction) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {
|
|
33
|
+
throw new Error(`Failed to get conditional order IDs: Unknown error`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const bytes = res.commandResults[0].returnValues[0].bcs;
|
|
37
|
+
const orderIds = bcs.vector(bcs.u64()).parse(bytes);
|
|
38
|
+
return orderIds.map((id) => id.toString());
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async getLowestTriggerAbovePrice(marginManagerKey: string): Promise<bigint> {
|
|
42
|
+
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
43
|
+
const tx = new Transaction();
|
|
44
|
+
tx.add(this.#ctx.marginTPSL.lowestTriggerAbovePrice(manager.poolKey, manager.address));
|
|
45
|
+
|
|
46
|
+
const res = await this.#ctx.client.core.simulateTransaction({
|
|
47
|
+
transaction: tx,
|
|
48
|
+
include: { commandResults: true, effects: true },
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (res.FailedTransaction) {
|
|
52
|
+
throw new Error(
|
|
53
|
+
`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {
|
|
58
|
+
throw new Error(`Failed to get lowest trigger above price: Unknown error`);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const bytes = res.commandResults[0].returnValues[0].bcs;
|
|
62
|
+
return BigInt(bcs.U64.parse(bytes));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async getHighestTriggerBelowPrice(marginManagerKey: string): Promise<bigint> {
|
|
66
|
+
const manager = this.#ctx.config.getMarginManager(marginManagerKey);
|
|
67
|
+
const tx = new Transaction();
|
|
68
|
+
tx.add(this.#ctx.marginTPSL.highestTriggerBelowPrice(manager.poolKey, manager.address));
|
|
69
|
+
|
|
70
|
+
const res = await this.#ctx.client.core.simulateTransaction({
|
|
71
|
+
transaction: tx,
|
|
72
|
+
include: { commandResults: true, effects: true },
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
if (res.FailedTransaction) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
`Transaction failed: ${res.FailedTransaction.status.error?.message || 'Unknown error'}`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!res.commandResults || !res.commandResults[0] || !res.commandResults[0].returnValues) {
|
|
82
|
+
throw new Error(`Failed to get highest trigger below price: Unknown error`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const bytes = res.commandResults[0].returnValues[0].bcs;
|
|
86
|
+
return BigInt(bcs.U64.parse(bytes));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -4,6 +4,7 @@ import { coinWithBalance } from '@mysten/sui/transactions';
|
|
|
4
4
|
import type { Transaction, TransactionArgument } from '@mysten/sui/transactions';
|
|
5
5
|
|
|
6
6
|
import type { DeepBookConfig } from '../utils/config.js';
|
|
7
|
+
import { convertQuantity } from '../utils/conversion.js';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* BalanceManagerContract class for managing BalanceManager operations.
|
|
@@ -70,7 +71,7 @@ export class BalanceManagerContract {
|
|
|
70
71
|
tx.setSenderIfNotSet(this.#config.address);
|
|
71
72
|
const managerId = this.#config.getBalanceManager(managerKey).address;
|
|
72
73
|
const coin = this.#config.getCoin(coinKey);
|
|
73
|
-
const depositInput =
|
|
74
|
+
const depositInput = convertQuantity(amountToDeposit, coin.scalar);
|
|
74
75
|
const deposit = coinWithBalance({
|
|
75
76
|
type: coin.type,
|
|
76
77
|
balance: depositInput,
|
|
@@ -96,7 +97,7 @@ export class BalanceManagerContract {
|
|
|
96
97
|
(tx: Transaction) => {
|
|
97
98
|
const managerId = this.#config.getBalanceManager(managerKey).address;
|
|
98
99
|
const coin = this.#config.getCoin(coinKey);
|
|
99
|
-
const withdrawInput =
|
|
100
|
+
const withdrawInput = convertQuantity(amountToWithdraw, coin.scalar);
|
|
100
101
|
const coinObject = tx.moveCall({
|
|
101
102
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,
|
|
102
103
|
arguments: [tx.object(managerId), tx.pure.u64(withdrawInput)],
|
|
@@ -240,7 +241,7 @@ export class BalanceManagerContract {
|
|
|
240
241
|
}
|
|
241
242
|
const depositCapId = manager.depositCap;
|
|
242
243
|
const coin = this.#config.getCoin(coinKey);
|
|
243
|
-
const depositInput =
|
|
244
|
+
const depositInput = convertQuantity(amountToDeposit, coin.scalar);
|
|
244
245
|
const deposit = coinWithBalance({
|
|
245
246
|
type: coin.type,
|
|
246
247
|
balance: depositInput,
|
|
@@ -269,7 +270,7 @@ export class BalanceManagerContract {
|
|
|
269
270
|
}
|
|
270
271
|
const withdrawCapId = manager.withdrawCap;
|
|
271
272
|
const coin = this.#config.getCoin(coinKey);
|
|
272
|
-
const withdrawAmount =
|
|
273
|
+
const withdrawAmount = convertQuantity(amountToWithdraw, coin.scalar);
|
|
273
274
|
return tx.moveCall({
|
|
274
275
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_with_cap`,
|
|
275
276
|
arguments: [tx.object(managerId), tx.object(withdrawCapId), tx.pure.u64(withdrawAmount)],
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
MAX_TIMESTAMP,
|
|
22
22
|
POOL_CREATION_FEE_DEEP,
|
|
23
23
|
} from '../utils/config.js';
|
|
24
|
+
import { convertQuantity, convertPrice, convertRate } from '../utils/conversion.js';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* DeepBookContract class for managing DeepBook operations.
|
|
@@ -59,8 +60,8 @@ export class DeepBookContract {
|
|
|
59
60
|
const balanceManager = this.#config.getBalanceManager(balanceManagerKey);
|
|
60
61
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
61
62
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
62
|
-
const inputPrice =
|
|
63
|
-
const inputQuantity =
|
|
63
|
+
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
64
|
+
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
64
65
|
|
|
65
66
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
66
67
|
|
|
@@ -106,7 +107,7 @@ export class DeepBookContract {
|
|
|
106
107
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
107
108
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
108
109
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
109
|
-
const inputQuantity =
|
|
110
|
+
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
110
111
|
|
|
111
112
|
tx.moveCall({
|
|
112
113
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::place_market_order`,
|
|
@@ -141,7 +142,7 @@ export class DeepBookContract {
|
|
|
141
142
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
142
143
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
143
144
|
const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
|
|
144
|
-
const inputQuantity =
|
|
145
|
+
const inputQuantity = convertQuantity(newQuantity, baseCoin.scalar);
|
|
145
146
|
|
|
146
147
|
tx.moveCall({
|
|
147
148
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::modify_order`,
|
|
@@ -359,7 +360,7 @@ export class DeepBookContract {
|
|
|
359
360
|
const pool = this.#config.getPool(poolKey);
|
|
360
361
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
361
362
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
362
|
-
const adjustedNumber =
|
|
363
|
+
const adjustedNumber = convertRate(multiplier, FLOAT_SCALAR);
|
|
363
364
|
|
|
364
365
|
tx.moveCall({
|
|
365
366
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::mint_referral`,
|
|
@@ -380,7 +381,7 @@ export class DeepBookContract {
|
|
|
380
381
|
const pool = this.#config.getPool(poolKey);
|
|
381
382
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
382
383
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
383
|
-
const adjustedNumber =
|
|
384
|
+
const adjustedNumber = convertRate(multiplier, FLOAT_SCALAR);
|
|
384
385
|
|
|
385
386
|
tx.moveCall({
|
|
386
387
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::update_pool_referral_multiplier`,
|
|
@@ -516,7 +517,7 @@ export class DeepBookContract {
|
|
|
516
517
|
* @param {number} baseQuantity Base quantity to convert
|
|
517
518
|
* @returns A function that takes a Transaction object
|
|
518
519
|
*/
|
|
519
|
-
getQuoteQuantityOut = (poolKey: string, baseQuantity: number) => (tx: Transaction) => {
|
|
520
|
+
getQuoteQuantityOut = (poolKey: string, baseQuantity: number | bigint) => (tx: Transaction) => {
|
|
520
521
|
const pool = this.#config.getPool(poolKey);
|
|
521
522
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
522
523
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
@@ -525,7 +526,7 @@ export class DeepBookContract {
|
|
|
525
526
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quote_quantity_out`,
|
|
526
527
|
arguments: [
|
|
527
528
|
tx.object(pool.address),
|
|
528
|
-
tx.pure.u64(
|
|
529
|
+
tx.pure.u64(convertQuantity(baseQuantity, baseCoin.scalar)),
|
|
529
530
|
tx.object.clock(),
|
|
530
531
|
],
|
|
531
532
|
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
@@ -538,7 +539,7 @@ export class DeepBookContract {
|
|
|
538
539
|
* @param {number} quoteQuantity Quote quantity to convert
|
|
539
540
|
* @returns A function that takes a Transaction object
|
|
540
541
|
*/
|
|
541
|
-
getBaseQuantityOut = (poolKey: string, quoteQuantity: number) => (tx: Transaction) => {
|
|
542
|
+
getBaseQuantityOut = (poolKey: string, quoteQuantity: number | bigint) => (tx: Transaction) => {
|
|
542
543
|
const pool = this.#config.getPool(poolKey);
|
|
543
544
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
544
545
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
@@ -548,7 +549,7 @@ export class DeepBookContract {
|
|
|
548
549
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_base_quantity_out`,
|
|
549
550
|
arguments: [
|
|
550
551
|
tx.object(pool.address),
|
|
551
|
-
tx.pure.u64(
|
|
552
|
+
tx.pure.u64(convertQuantity(quoteQuantity, quoteScalar)),
|
|
552
553
|
tx.object.clock(),
|
|
553
554
|
],
|
|
554
555
|
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
@@ -563,7 +564,8 @@ export class DeepBookContract {
|
|
|
563
564
|
* @returns A function that takes a Transaction object
|
|
564
565
|
*/
|
|
565
566
|
getQuantityOut =
|
|
566
|
-
(poolKey: string, baseQuantity: number, quoteQuantity: number
|
|
567
|
+
(poolKey: string, baseQuantity: number | bigint, quoteQuantity: number | bigint) =>
|
|
568
|
+
(tx: Transaction) => {
|
|
567
569
|
const pool = this.#config.getPool(poolKey);
|
|
568
570
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
569
571
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
@@ -573,8 +575,8 @@ export class DeepBookContract {
|
|
|
573
575
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quantity_out`,
|
|
574
576
|
arguments: [
|
|
575
577
|
tx.object(pool.address),
|
|
576
|
-
tx.pure.u64(
|
|
577
|
-
tx.pure.u64(
|
|
578
|
+
tx.pure.u64(convertQuantity(baseQuantity, baseCoin.scalar)),
|
|
579
|
+
tx.pure.u64(convertQuantity(quoteQuantity, quoteScalar)),
|
|
578
580
|
tx.object.clock(),
|
|
579
581
|
],
|
|
580
582
|
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
@@ -609,7 +611,8 @@ export class DeepBookContract {
|
|
|
609
611
|
* @returns A function that takes a Transaction object
|
|
610
612
|
*/
|
|
611
613
|
getLevel2Range =
|
|
612
|
-
(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) =>
|
|
614
|
+
(poolKey: string, priceLow: number | bigint, priceHigh: number | bigint, isBid: boolean) =>
|
|
615
|
+
(tx: Transaction) => {
|
|
613
616
|
const pool = this.#config.getPool(poolKey);
|
|
614
617
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
615
618
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
@@ -618,8 +621,8 @@ export class DeepBookContract {
|
|
|
618
621
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_level2_range`,
|
|
619
622
|
arguments: [
|
|
620
623
|
tx.object(pool.address),
|
|
621
|
-
tx.pure.u64(
|
|
622
|
-
tx.pure.u64(
|
|
624
|
+
tx.pure.u64(convertPrice(priceLow, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar)),
|
|
625
|
+
tx.pure.u64(convertPrice(priceHigh, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar)),
|
|
623
626
|
tx.pure.bool(isBid),
|
|
624
627
|
tx.object.clock(),
|
|
625
628
|
],
|
|
@@ -697,13 +700,16 @@ export class DeepBookContract {
|
|
|
697
700
|
|
|
698
701
|
const baseCoinInput =
|
|
699
702
|
params.baseCoin ??
|
|
700
|
-
coinWithBalance({
|
|
703
|
+
coinWithBalance({
|
|
704
|
+
type: baseCoin.type,
|
|
705
|
+
balance: convertQuantity(baseAmount, baseCoin.scalar),
|
|
706
|
+
});
|
|
701
707
|
|
|
702
708
|
const deepCoin =
|
|
703
709
|
params.deepCoin ??
|
|
704
|
-
coinWithBalance({ type: deepCoinType, balance:
|
|
710
|
+
coinWithBalance({ type: deepCoinType, balance: convertQuantity(deepAmount, DEEP_SCALAR) });
|
|
705
711
|
|
|
706
|
-
const minQuoteInput =
|
|
712
|
+
const minQuoteInput = convertQuantity(minQuote, quoteCoin.scalar);
|
|
707
713
|
|
|
708
714
|
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({
|
|
709
715
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,
|
|
@@ -743,14 +749,14 @@ export class DeepBookContract {
|
|
|
743
749
|
params.quoteCoin ??
|
|
744
750
|
coinWithBalance({
|
|
745
751
|
type: quoteCoin.type,
|
|
746
|
-
balance:
|
|
752
|
+
balance: convertQuantity(quoteAmount, quoteCoin.scalar),
|
|
747
753
|
});
|
|
748
754
|
|
|
749
755
|
const deepCoin =
|
|
750
756
|
params.deepCoin ??
|
|
751
|
-
coinWithBalance({ type: deepCoinType, balance:
|
|
757
|
+
coinWithBalance({ type: deepCoinType, balance: convertQuantity(deepAmount, DEEP_SCALAR) });
|
|
752
758
|
|
|
753
|
-
const minBaseInput =
|
|
759
|
+
const minBaseInput = convertQuantity(minBase, baseCoin.scalar);
|
|
754
760
|
|
|
755
761
|
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({
|
|
756
762
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,
|
|
@@ -788,7 +794,7 @@ export class DeepBookContract {
|
|
|
788
794
|
? (baseCoin ??
|
|
789
795
|
coinWithBalance({
|
|
790
796
|
type: baseCoinType.type,
|
|
791
|
-
balance:
|
|
797
|
+
balance: convertQuantity(amount, baseCoinType.scalar),
|
|
792
798
|
}))
|
|
793
799
|
: coinWithBalance({ type: baseCoinType.type, balance: 0 });
|
|
794
800
|
|
|
@@ -797,15 +803,16 @@ export class DeepBookContract {
|
|
|
797
803
|
: (quoteCoin ??
|
|
798
804
|
coinWithBalance({
|
|
799
805
|
type: quoteCoinType.type,
|
|
800
|
-
balance:
|
|
806
|
+
balance: convertQuantity(amount, quoteCoinType.scalar),
|
|
801
807
|
}));
|
|
802
808
|
|
|
803
809
|
const deepCoinInput =
|
|
804
810
|
deepCoin ??
|
|
805
|
-
coinWithBalance({ type: deepCoinType, balance:
|
|
811
|
+
coinWithBalance({ type: deepCoinType, balance: convertQuantity(deepAmount, DEEP_SCALAR) });
|
|
806
812
|
|
|
807
|
-
const minOutInput =
|
|
808
|
-
minOut
|
|
813
|
+
const minOutInput = convertQuantity(
|
|
814
|
+
minOut,
|
|
815
|
+
isBaseToCoin ? quoteCoinType.scalar : baseCoinType.scalar,
|
|
809
816
|
);
|
|
810
817
|
|
|
811
818
|
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({
|
|
@@ -851,9 +858,9 @@ export class DeepBookContract {
|
|
|
851
858
|
baseCoin ??
|
|
852
859
|
coinWithBalance({
|
|
853
860
|
type: baseCoinType.type,
|
|
854
|
-
balance:
|
|
861
|
+
balance: convertQuantity(baseAmount, baseCoinType.scalar),
|
|
855
862
|
});
|
|
856
|
-
const minQuoteInput =
|
|
863
|
+
const minQuoteInput = convertQuantity(minQuote, quoteCoinType.scalar);
|
|
857
864
|
|
|
858
865
|
const [baseCoinResult, quoteCoinResult] = tx.moveCall({
|
|
859
866
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote_with_manager`,
|
|
@@ -900,9 +907,9 @@ export class DeepBookContract {
|
|
|
900
907
|
quoteCoin ??
|
|
901
908
|
coinWithBalance({
|
|
902
909
|
type: quoteCoinType.type,
|
|
903
|
-
balance:
|
|
910
|
+
balance: convertQuantity(quoteAmount, quoteCoinType.scalar),
|
|
904
911
|
});
|
|
905
|
-
const minBaseInput =
|
|
912
|
+
const minBaseInput = convertQuantity(minBase, baseCoinType.scalar);
|
|
906
913
|
|
|
907
914
|
const [baseCoinResult, quoteCoinResult] = tx.moveCall({
|
|
908
915
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base_with_manager`,
|
|
@@ -952,7 +959,7 @@ export class DeepBookContract {
|
|
|
952
959
|
? (baseCoin ??
|
|
953
960
|
coinWithBalance({
|
|
954
961
|
type: baseCoinType.type,
|
|
955
|
-
balance:
|
|
962
|
+
balance: convertQuantity(amount, baseCoinType.scalar),
|
|
956
963
|
}))
|
|
957
964
|
: coinWithBalance({ type: baseCoinType.type, balance: 0 });
|
|
958
965
|
|
|
@@ -961,11 +968,12 @@ export class DeepBookContract {
|
|
|
961
968
|
: (quoteCoin ??
|
|
962
969
|
coinWithBalance({
|
|
963
970
|
type: quoteCoinType.type,
|
|
964
|
-
balance:
|
|
971
|
+
balance: convertQuantity(amount, quoteCoinType.scalar),
|
|
965
972
|
}));
|
|
966
973
|
|
|
967
|
-
const minOutInput =
|
|
968
|
-
minOut
|
|
974
|
+
const minOutInput = convertQuantity(
|
|
975
|
+
minOut,
|
|
976
|
+
isBaseToCoin ? quoteCoinType.scalar : baseCoinType.scalar,
|
|
969
977
|
);
|
|
970
978
|
|
|
971
979
|
const [baseCoinResult, quoteCoinResult] = tx.moveCall({
|
|
@@ -1002,9 +1010,9 @@ export class DeepBookContract {
|
|
|
1002
1010
|
const baseScalar = baseCoin.scalar;
|
|
1003
1011
|
const quoteScalar = quoteCoin.scalar;
|
|
1004
1012
|
|
|
1005
|
-
const adjustedTickSize =
|
|
1006
|
-
const adjustedLotSize =
|
|
1007
|
-
const adjustedMinSize =
|
|
1013
|
+
const adjustedTickSize = convertPrice(tickSize, FLOAT_SCALAR, quoteScalar, baseScalar);
|
|
1014
|
+
const adjustedLotSize = convertQuantity(lotSize, baseScalar);
|
|
1015
|
+
const adjustedMinSize = convertQuantity(minSize, baseScalar);
|
|
1008
1016
|
|
|
1009
1017
|
const deepCoinInput =
|
|
1010
1018
|
deepCoin ??
|
|
@@ -1203,21 +1211,22 @@ export class DeepBookContract {
|
|
|
1203
1211
|
* @param {number} baseQuantity Base quantity to convert
|
|
1204
1212
|
* @returns A function that takes a Transaction object
|
|
1205
1213
|
*/
|
|
1206
|
-
getQuoteQuantityOutInputFee =
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1214
|
+
getQuoteQuantityOutInputFee =
|
|
1215
|
+
(poolKey: string, baseQuantity: number | bigint) => (tx: Transaction) => {
|
|
1216
|
+
const pool = this.#config.getPool(poolKey);
|
|
1217
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1218
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
1210
1219
|
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1220
|
+
return tx.moveCall({
|
|
1221
|
+
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quote_quantity_out_input_fee`,
|
|
1222
|
+
arguments: [
|
|
1223
|
+
tx.object(pool.address),
|
|
1224
|
+
tx.pure.u64(convertQuantity(baseQuantity, baseCoin.scalar)),
|
|
1225
|
+
tx.object.clock(),
|
|
1226
|
+
],
|
|
1227
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
1228
|
+
});
|
|
1229
|
+
};
|
|
1221
1230
|
|
|
1222
1231
|
/**
|
|
1223
1232
|
* @description Get the base quantity out for a given quote quantity using input token as fee
|
|
@@ -1225,21 +1234,22 @@ export class DeepBookContract {
|
|
|
1225
1234
|
* @param {number} quoteQuantity Quote quantity to convert
|
|
1226
1235
|
* @returns A function that takes a Transaction object
|
|
1227
1236
|
*/
|
|
1228
|
-
getBaseQuantityOutInputFee =
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1237
|
+
getBaseQuantityOutInputFee =
|
|
1238
|
+
(poolKey: string, quoteQuantity: number | bigint) => (tx: Transaction) => {
|
|
1239
|
+
const pool = this.#config.getPool(poolKey);
|
|
1240
|
+
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1241
|
+
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
1232
1242
|
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
+
return tx.moveCall({
|
|
1244
|
+
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_base_quantity_out_input_fee`,
|
|
1245
|
+
arguments: [
|
|
1246
|
+
tx.object(pool.address),
|
|
1247
|
+
tx.pure.u64(convertQuantity(quoteQuantity, quoteCoin.scalar)),
|
|
1248
|
+
tx.object.clock(),
|
|
1249
|
+
],
|
|
1250
|
+
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
1251
|
+
});
|
|
1252
|
+
};
|
|
1243
1253
|
|
|
1244
1254
|
/**
|
|
1245
1255
|
* @description Get the quantity out for a given base or quote quantity using input token as fee
|
|
@@ -1249,7 +1259,8 @@ export class DeepBookContract {
|
|
|
1249
1259
|
* @returns A function that takes a Transaction object
|
|
1250
1260
|
*/
|
|
1251
1261
|
getQuantityOutInputFee =
|
|
1252
|
-
(poolKey: string, baseQuantity: number, quoteQuantity: number
|
|
1262
|
+
(poolKey: string, baseQuantity: number | bigint, quoteQuantity: number | bigint) =>
|
|
1263
|
+
(tx: Transaction) => {
|
|
1253
1264
|
const pool = this.#config.getPool(poolKey);
|
|
1254
1265
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1255
1266
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
@@ -1258,8 +1269,8 @@ export class DeepBookContract {
|
|
|
1258
1269
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quantity_out_input_fee`,
|
|
1259
1270
|
arguments: [
|
|
1260
1271
|
tx.object(pool.address),
|
|
1261
|
-
tx.pure.u64(
|
|
1262
|
-
tx.pure.u64(
|
|
1272
|
+
tx.pure.u64(convertQuantity(baseQuantity, baseCoin.scalar)),
|
|
1273
|
+
tx.pure.u64(convertQuantity(quoteQuantity, quoteCoin.scalar)),
|
|
1263
1274
|
tx.object.clock(),
|
|
1264
1275
|
],
|
|
1265
1276
|
typeArguments: [baseCoin.type, quoteCoin.type],
|
|
@@ -1274,7 +1285,8 @@ export class DeepBookContract {
|
|
|
1274
1285
|
* @returns A function that takes a Transaction object
|
|
1275
1286
|
*/
|
|
1276
1287
|
getBaseQuantityIn =
|
|
1277
|
-
(poolKey: string, targetQuoteQuantity: number, payWithDeep: boolean) =>
|
|
1288
|
+
(poolKey: string, targetQuoteQuantity: number | bigint, payWithDeep: boolean) =>
|
|
1289
|
+
(tx: Transaction) => {
|
|
1278
1290
|
const pool = this.#config.getPool(poolKey);
|
|
1279
1291
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1280
1292
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
@@ -1283,7 +1295,7 @@ export class DeepBookContract {
|
|
|
1283
1295
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_base_quantity_in`,
|
|
1284
1296
|
arguments: [
|
|
1285
1297
|
tx.object(pool.address),
|
|
1286
|
-
tx.pure.u64(
|
|
1298
|
+
tx.pure.u64(convertQuantity(targetQuoteQuantity, quoteCoin.scalar)),
|
|
1287
1299
|
tx.pure.bool(payWithDeep),
|
|
1288
1300
|
tx.object.clock(),
|
|
1289
1301
|
],
|
|
@@ -1299,7 +1311,8 @@ export class DeepBookContract {
|
|
|
1299
1311
|
* @returns A function that takes a Transaction object
|
|
1300
1312
|
*/
|
|
1301
1313
|
getQuoteQuantityIn =
|
|
1302
|
-
(poolKey: string, targetBaseQuantity: number, payWithDeep: boolean) =>
|
|
1314
|
+
(poolKey: string, targetBaseQuantity: number | bigint, payWithDeep: boolean) =>
|
|
1315
|
+
(tx: Transaction) => {
|
|
1303
1316
|
const pool = this.#config.getPool(poolKey);
|
|
1304
1317
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1305
1318
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
@@ -1308,7 +1321,7 @@ export class DeepBookContract {
|
|
|
1308
1321
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quote_quantity_in`,
|
|
1309
1322
|
arguments: [
|
|
1310
1323
|
tx.object(pool.address),
|
|
1311
|
-
tx.pure.u64(
|
|
1324
|
+
tx.pure.u64(convertQuantity(targetBaseQuantity, baseCoin.scalar)),
|
|
1312
1325
|
tx.pure.bool(payWithDeep),
|
|
1313
1326
|
tx.object.clock(),
|
|
1314
1327
|
],
|
|
@@ -1343,12 +1356,13 @@ export class DeepBookContract {
|
|
|
1343
1356
|
* @returns A function that takes a Transaction object
|
|
1344
1357
|
*/
|
|
1345
1358
|
getOrderDeepRequired =
|
|
1346
|
-
(poolKey: string, baseQuantity: number, price: number
|
|
1359
|
+
(poolKey: string, baseQuantity: number | bigint, price: number | bigint) =>
|
|
1360
|
+
(tx: Transaction) => {
|
|
1347
1361
|
const pool = this.#config.getPool(poolKey);
|
|
1348
1362
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1349
1363
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
1350
|
-
const inputPrice =
|
|
1351
|
-
const inputQuantity =
|
|
1364
|
+
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
1365
|
+
const inputQuantity = convertQuantity(baseQuantity, baseCoin.scalar);
|
|
1352
1366
|
|
|
1353
1367
|
return tx.moveCall({
|
|
1354
1368
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_order_deep_required`,
|
|
@@ -1440,8 +1454,8 @@ export class DeepBookContract {
|
|
|
1440
1454
|
const manager = this.#config.getBalanceManager(balanceManagerKey);
|
|
1441
1455
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1442
1456
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
1443
|
-
const inputPrice =
|
|
1444
|
-
const inputQuantity =
|
|
1457
|
+
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
1458
|
+
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
1445
1459
|
|
|
1446
1460
|
return tx.moveCall({
|
|
1447
1461
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::can_place_limit_order`,
|
|
@@ -1471,7 +1485,7 @@ export class DeepBookContract {
|
|
|
1471
1485
|
const manager = this.#config.getBalanceManager(balanceManagerKey);
|
|
1472
1486
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1473
1487
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
1474
|
-
const inputQuantity =
|
|
1488
|
+
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
1475
1489
|
|
|
1476
1490
|
return tx.moveCall({
|
|
1477
1491
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::can_place_market_order`,
|
|
@@ -1493,11 +1507,11 @@ export class DeepBookContract {
|
|
|
1493
1507
|
* @param {number} quantity Quantity
|
|
1494
1508
|
* @returns A function that takes a Transaction object
|
|
1495
1509
|
*/
|
|
1496
|
-
checkMarketOrderParams = (poolKey: string, quantity: number) => (tx: Transaction) => {
|
|
1510
|
+
checkMarketOrderParams = (poolKey: string, quantity: number | bigint) => (tx: Transaction) => {
|
|
1497
1511
|
const pool = this.#config.getPool(poolKey);
|
|
1498
1512
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1499
1513
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
1500
|
-
const inputQuantity =
|
|
1514
|
+
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
1501
1515
|
|
|
1502
1516
|
return tx.moveCall({
|
|
1503
1517
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::check_market_order_params`,
|
|
@@ -1515,13 +1529,13 @@ export class DeepBookContract {
|
|
|
1515
1529
|
* @returns A function that takes a Transaction object
|
|
1516
1530
|
*/
|
|
1517
1531
|
checkLimitOrderParams =
|
|
1518
|
-
(poolKey: string, price: number, quantity: number, expireTimestamp: number) =>
|
|
1532
|
+
(poolKey: string, price: number | bigint, quantity: number | bigint, expireTimestamp: number) =>
|
|
1519
1533
|
(tx: Transaction) => {
|
|
1520
1534
|
const pool = this.#config.getPool(poolKey);
|
|
1521
1535
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
1522
1536
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|
|
1523
|
-
const inputPrice =
|
|
1524
|
-
const inputQuantity =
|
|
1537
|
+
const inputPrice = convertPrice(price, FLOAT_SCALAR, quoteCoin.scalar, baseCoin.scalar);
|
|
1538
|
+
const inputQuantity = convertQuantity(quantity, baseCoin.scalar);
|
|
1525
1539
|
|
|
1526
1540
|
return tx.moveCall({
|
|
1527
1541
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::check_limit_order_params`,
|
|
@@ -6,6 +6,7 @@ import type { Transaction } from '@mysten/sui/transactions';
|
|
|
6
6
|
import type { CreatePoolAdminParams, SetEwmaParams } from '../types/index.js';
|
|
7
7
|
import type { DeepBookConfig } from '../utils/config.js';
|
|
8
8
|
import { FLOAT_SCALAR } from '../utils/config.js';
|
|
9
|
+
import { convertQuantity, convertPrice, convertRate } from '../utils/conversion.js';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* DeepBookAdminContract class for managing admin actions.
|
|
@@ -47,9 +48,9 @@ export class DeepBookAdminContract {
|
|
|
47
48
|
const baseScalar = baseCoin.scalar;
|
|
48
49
|
const quoteScalar = quoteCoin.scalar;
|
|
49
50
|
|
|
50
|
-
const adjustedTickSize =
|
|
51
|
-
const adjustedLotSize =
|
|
52
|
-
const adjustedMinSize =
|
|
51
|
+
const adjustedTickSize = convertPrice(tickSize, FLOAT_SCALAR, quoteScalar, baseScalar);
|
|
52
|
+
const adjustedLotSize = convertQuantity(lotSize, baseScalar);
|
|
53
|
+
const adjustedMinSize = convertQuantity(minSize, baseScalar);
|
|
53
54
|
|
|
54
55
|
tx.moveCall({
|
|
55
56
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::create_pool_admin`,
|
|
@@ -197,7 +198,7 @@ export class DeepBookAdminContract {
|
|
|
197
198
|
const baseScalar = baseCoin.scalar;
|
|
198
199
|
const quoteScalar = quoteCoin.scalar;
|
|
199
200
|
|
|
200
|
-
const adjustedTickSize =
|
|
201
|
+
const adjustedTickSize = convertPrice(newTickSize, FLOAT_SCALAR, quoteScalar, baseScalar);
|
|
201
202
|
|
|
202
203
|
tx.moveCall({
|
|
203
204
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::adjust_tick_size_admin`,
|
|
@@ -227,8 +228,8 @@ export class DeepBookAdminContract {
|
|
|
227
228
|
|
|
228
229
|
const baseScalar = baseCoin.scalar;
|
|
229
230
|
|
|
230
|
-
const adjustedLotSize =
|
|
231
|
-
const adjustedMinSize =
|
|
231
|
+
const adjustedLotSize = convertQuantity(newLotSize, baseScalar);
|
|
232
|
+
const adjustedMinSize = convertQuantity(newMinSize, baseScalar);
|
|
232
233
|
|
|
233
234
|
tx.moveCall({
|
|
234
235
|
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::adjust_min_lot_size_admin`,
|
|
@@ -262,9 +263,9 @@ export class DeepBookAdminContract {
|
|
|
262
263
|
*/
|
|
263
264
|
setEwmaParams = (poolKey: string, params: SetEwmaParams) => (tx: Transaction) => {
|
|
264
265
|
const { alpha, zScoreThreshold, additionalTakerFee } = params;
|
|
265
|
-
const adjustedAlpha =
|
|
266
|
-
const adjustedZScoreThreshold =
|
|
267
|
-
const adjustedAdditionalTakerFee =
|
|
266
|
+
const adjustedAlpha = convertRate(alpha, FLOAT_SCALAR);
|
|
267
|
+
const adjustedZScoreThreshold = convertRate(zScoreThreshold, FLOAT_SCALAR);
|
|
268
|
+
const adjustedAdditionalTakerFee = convertRate(additionalTakerFee, FLOAT_SCALAR);
|
|
268
269
|
const pool = this.#config.getPool(poolKey);
|
|
269
270
|
const baseCoin = this.#config.getCoin(pool.baseCoin);
|
|
270
271
|
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
|