New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@mysten/deepbook-v3

Package Overview
Dependencies
Maintainers
0
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mysten/deepbook-v3 - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

7

CHANGELOG.md
# @mysten/deepbook-v3
## 0.3.0
### Minor Changes
- 36f1c6f: Rounding for numbers, exports update
- c51f186: New contract constants
## 0.2.1

@@ -4,0 +11,0 @@

46

dist/cjs/client.js

@@ -98,3 +98,3 @@ "use strict";

coinType: coin.type,
balance: adjusted_balance
balance: Number(adjusted_balance.toFixed(9))
};

@@ -140,5 +140,5 @@ }

baseQuantity,
baseOut: baseOut / baseScalar,
quoteOut: quoteOut / quoteScalar,
deepRequired: deepRequired / import_config.DEEP_SCALAR
baseOut: Number((baseOut / baseScalar).toFixed(9)),
quoteOut: Number((quoteOut / quoteScalar).toFixed(9)),
deepRequired: Number((deepRequired / import_config.DEEP_SCALAR).toFixed(9))
};

@@ -168,5 +168,5 @@ }

quoteQuantity,
baseOut: baseOut / baseScalar,
quoteOut: quoteOut / quoteScalar,
deepRequired: deepRequired / import_config.DEEP_SCALAR
baseOut: Number((baseOut / baseScalar).toFixed(9)),
quoteOut: Number((quoteOut / quoteScalar).toFixed(9)),
deepRequired: Number((deepRequired / import_config.DEEP_SCALAR).toFixed(9))
};

@@ -198,5 +198,5 @@ }

quoteQuantity,
baseOut: baseOut / baseScalar,
quoteOut: quoteOut / quoteScalar,
deepRequired: deepRequired / import_config.DEEP_SCALAR
baseOut: Number((baseOut / baseScalar).toFixed(9)),
quoteOut: Number((quoteOut / quoteScalar).toFixed(9)),
deepRequired: Number((deepRequired / import_config.DEEP_SCALAR).toFixed(9))
};

@@ -283,5 +283,7 @@ }

prices: parsed_prices.map(
(price) => Number(price) / import_config.FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar
(price) => Number((Number(price) / import_config.FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar).toFixed(9))
),
quantities: parsed_quantities.map((price) => Number(price) / baseCoin.scalar)
quantities: parsed_quantities.map(
(price) => Number((Number(price) / baseCoin.scalar).toFixed(9))
)
};

@@ -316,9 +318,13 @@ }

bid_prices: bid_parsed_prices.map(
(price) => Number(price) / import_config.FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar
(price) => Number((Number(price) / import_config.FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar).toFixed(9))
),
bid_quantities: bid_parsed_quantities.map((quantity) => Number(quantity) / baseCoin.scalar),
bid_quantities: bid_parsed_quantities.map(
(quantity) => Number((Number(quantity) / baseCoin.scalar).toFixed(9))
),
ask_prices: ask_parsed_prices.map(
(price) => Number(price) / import_config.FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar
(price) => Number((Number(price) / import_config.FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar).toFixed(9))
),
ask_quantities: ask_parsed_quantities.map((quantity) => Number(quantity) / baseCoin.scalar)
ask_quantities: ask_parsed_quantities.map(
(quantity) => Number((Number(quantity) / baseCoin.scalar).toFixed(9))
)
};

@@ -346,5 +352,5 @@ }

return {
base: baseInVault / baseScalar,
quote: quoteInVault / quoteScalar,
deep: deepInVault / import_config.DEEP_SCALAR
base: Number((baseInVault / baseScalar).toFixed(9)),
quote: Number((quoteInVault / quoteScalar).toFixed(9)),
deep: Number((deepInVault / import_config.DEEP_SCALAR).toFixed(9))
};

@@ -389,3 +395,3 @@ }

const adjusted_mid_price = parsed_mid_price * baseCoin.scalar / quoteCoin.scalar / import_config.FLOAT_SCALAR;
return adjusted_mid_price;
return Number(adjusted_mid_price.toFixed(9));
}

@@ -392,0 +398,0 @@ }

@@ -8,1 +8,3 @@ export { DeepBookClient } from './client.js';

export { DeepBookConfig } from './utils/config.js';
export type { BalanceManager, Coin, Pool } from './types/index.js';
export type { CoinMap, PoolMap } from './utils/constants.js';

@@ -64,5 +64,6 @@ "use strict";

const coin = __privateGet(this, _config).getCoin(coinKey);
const depositInput = Math.round(amountToDeposit * coin.scalar);
const deposit = (0, import_transactions.coinWithBalance)({
type: coin.type,
balance: amountToDeposit * coin.scalar
balance: depositInput
});

@@ -86,5 +87,6 @@ tx.moveCall({

const coin = __privateGet(this, _config).getCoin(coinKey);
const withdrawInput = Math.round(amountToWithdraw * coin.scalar);
const coinObject = tx.moveCall({
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,
arguments: [tx.object(managerId), tx.pure.u64(amountToWithdraw * coin.scalar)],
arguments: [tx.object(managerId), tx.pure.u64(withdrawInput)],
typeArguments: [coin.type]

@@ -91,0 +93,0 @@ });

@@ -65,4 +65,4 @@ "use strict";

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const inputPrice = price * import_config.FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar;
const inputQuantity = quantity * baseCoin.scalar;
const inputPrice = Math.round(price * import_config.FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar);
const inputQuantity = Math.round(quantity * baseCoin.scalar);
const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));

@@ -109,2 +109,3 @@ tx.moveCall({

const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
const inputQuantity = Math.round(quantity * baseCoin.scalar);
tx.moveCall({

@@ -118,3 +119,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::place_market_order`,

tx.pure.u8(selfMatchingOption),
tx.pure.u64(quantity * baseCoin.scalar),
tx.pure.u64(inputQuantity),
tx.pure.bool(isBid),

@@ -141,2 +142,3 @@ tx.pure.bool(payWithDeep),

const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
const inputQuantity = Math.round(newQuantity * baseCoin.scalar);
tx.moveCall({

@@ -149,3 +151,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::modify_order`,

tx.pure.u128(orderId),
tx.pure.u64(newQuantity),
tx.pure.u64(inputQuantity),
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)

@@ -500,4 +502,5 @@ ],

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const baseCoinInput = params.baseCoin ?? (0, import_transactions.coinWithBalance)({ type: baseCoin.type, balance: baseAmount * baseCoin.scalar });
const deepCoin = params.deepCoin ?? (0, import_transactions.coinWithBalance)({ type: deepCoinType, balance: deepAmount * import_config.DEEP_SCALAR });
const baseCoinInput = params.baseCoin ?? (0, import_transactions.coinWithBalance)({ type: baseCoin.type, balance: Math.round(baseAmount * baseCoin.scalar) });
const deepCoin = params.deepCoin ?? (0, import_transactions.coinWithBalance)({ type: deepCoinType, balance: Math.round(deepAmount * import_config.DEEP_SCALAR) });
const minQuoteInput = Math.round(minQuote * quoteCoin.scalar);
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({

@@ -509,3 +512,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,

deepCoin,
tx.pure.u64(quoteCoin.scalar * minQuote),
tx.pure.u64(minQuoteInput),
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)

@@ -533,4 +536,8 @@ ],

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const quoteCoinInput = params.quoteCoin ?? (0, import_transactions.coinWithBalance)({ type: quoteCoin.type, balance: quoteAmount * quoteCoin.scalar });
const deepCoin = params.deepCoin ?? (0, import_transactions.coinWithBalance)({ type: deepCoinType, balance: deepAmount * import_config.DEEP_SCALAR });
const quoteCoinInput = params.quoteCoin ?? (0, import_transactions.coinWithBalance)({
type: quoteCoin.type,
balance: Math.round(quoteAmount * quoteCoin.scalar)
});
const deepCoin = params.deepCoin ?? (0, import_transactions.coinWithBalance)({ type: deepCoinType, balance: Math.round(deepAmount * import_config.DEEP_SCALAR) });
const minBaseInput = Math.round(minBase * baseCoin.scalar);
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({

@@ -542,3 +549,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,

deepCoin,
tx.pure.u64(baseCoin.scalar * minBase),
tx.pure.u64(minBaseInput),
tx.object(import_utils.SUI_CLOCK_OBJECT_ID)

@@ -545,0 +552,0 @@ ],

@@ -48,5 +48,6 @@ "use strict";

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const inputQuantity = Math.round(borrowAmount * baseCoin.scalar);
const [baseCoinResult, flashLoan] = tx.moveCall({
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_base`,
arguments: [tx.object(pool.address), tx.pure.u64(borrowAmount * baseCoin.scalar)],
arguments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],
typeArguments: [baseCoin.type, quoteCoin.type]

@@ -70,3 +71,3 @@ });

const [baseCoinReturn] = tx.splitCoins(baseCoinInput, [
tx.pure.u64(borrowAmount * borrowScalar)
tx.pure.u64(Math.round(borrowAmount * borrowScalar))
]);

@@ -90,5 +91,6 @@ tx.moveCall({

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const inputQuantity = Math.round(borrowAmount * quoteCoin.scalar);
const [quoteCoinResult, flashLoan] = tx.moveCall({
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_quote`,
arguments: [tx.object(pool.address), tx.pure.u64(borrowAmount * quoteCoin.scalar)],
arguments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],
typeArguments: [baseCoin.type, quoteCoin.type]

@@ -112,3 +114,3 @@ });

const [quoteCoinReturn] = tx.splitCoins(quoteCoinInput, [
tx.pure.u64(borrowAmount * borrowScalar)
tx.pure.u64(Math.round(borrowAmount * borrowScalar))
]);

@@ -115,0 +117,0 @@ tx.moveCall({

@@ -52,2 +52,3 @@ "use strict";

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const stakeInput = Math.round(stakeAmount * import_config.DEEP_SCALAR);
tx.moveCall({

@@ -59,3 +60,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::stake`,

tradeProof,
tx.pure.u64(stakeAmount * import_config.DEEP_SCALAR)
tx.pure.u64(stakeInput)
],

@@ -101,5 +102,5 @@ typeArguments: [baseCoin.type, quoteCoin.type]

tradeProof,
tx.pure.u64(takerFee * import_config.FLOAT_SCALAR),
tx.pure.u64(makerFee * import_config.FLOAT_SCALAR),
tx.pure.u64(stakeRequired * import_config.DEEP_SCALAR)
tx.pure.u64(Math.round(takerFee * import_config.FLOAT_SCALAR)),
tx.pure.u64(Math.round(makerFee * import_config.FLOAT_SCALAR)),
tx.pure.u64(Math.round(stakeRequired * import_config.DEEP_SCALAR))
],

@@ -106,0 +107,0 @@ typeArguments: [baseCoin.type, quoteCoin.type]

@@ -30,4 +30,4 @@ "use strict";

const testnetPackageIds = {
DEEPBOOK_PACKAGE_ID: "0x279443bdf339c7beb585fa44bbd9fa40e4ff255b4df6a2eca32ccc469ffc9046",
REGISTRY_ID: "0xe9c839fd0c6469b750b96ebe0fe656eec25466dea2a57f7d6df12c63c71af9ac",
DEEPBOOK_PACKAGE_ID: "0x2c152dba0110d3afb76b659ed3436edd848b37e177c3abfc0296f8aefc2e6cf4",
REGISTRY_ID: "0x9162317a81a9eb66ecd42705529b2a39c7805f98f42312275c2e7a599d518437",
DEEP_TREASURY_ID: "0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb"

@@ -91,3 +91,3 @@ };

DEEP_SUI: {
address: `0x69c220e16a38e6f18073b2ae5d200d45f27449db86d3435a592474686037416e`,
address: `0x2decc59a6f05c5800e5c8a1135f9d133d1746f562bf56673e6e81ef4f7ccd3b7`,
baseCoin: "DEEP",

@@ -97,3 +97,3 @@ quoteCoin: "SUI"

SUI_DBUSDC: {
address: `0x7abf219eda0771e27a4cc1c87946515c3dfc6ef994b4b06aef81830ff3bfad7f`,
address: `0xace543e8239f0c19783e57bacb02c581fd38d52899bdce117e49c91b494c8b10`,
baseCoin: "SUI",

@@ -103,3 +103,3 @@ quoteCoin: "DBUSDC"

DEEP_DBUSDC: {
address: `0x4d48440f70032595f31d1fd39c4891e81e9b3f5d48ae2dde3198f26eebfed55e`,
address: `0x1faaa544a84c16215ef005edb046ddf8e1cfec0792aec3032e86e554b33bd33a`,
baseCoin: "DEEP",

@@ -109,3 +109,3 @@ quoteCoin: "DBUSDC"

DBUSDT_DBUSDC: {
address: `0x2d532573987c46e43b6d4c09d6b702caee045d330b7450300d331e57a11a0308`,
address: `0x83aca040eaeaf061e3d482a44d1a87a5b8b6206ad52edae9d0479b830a38106f`,
baseCoin: "DBUSDT",

@@ -112,0 +112,0 @@ quoteCoin: "DBUSDC"

@@ -75,3 +75,3 @@ var __typeError = (msg) => {

coinType: coin.type,
balance: adjusted_balance
balance: Number(adjusted_balance.toFixed(9))
};

@@ -117,5 +117,5 @@ }

baseQuantity,
baseOut: baseOut / baseScalar,
quoteOut: quoteOut / quoteScalar,
deepRequired: deepRequired / DEEP_SCALAR
baseOut: Number((baseOut / baseScalar).toFixed(9)),
quoteOut: Number((quoteOut / quoteScalar).toFixed(9)),
deepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9))
};

@@ -145,5 +145,5 @@ }

quoteQuantity,
baseOut: baseOut / baseScalar,
quoteOut: quoteOut / quoteScalar,
deepRequired: deepRequired / DEEP_SCALAR
baseOut: Number((baseOut / baseScalar).toFixed(9)),
quoteOut: Number((quoteOut / quoteScalar).toFixed(9)),
deepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9))
};

@@ -175,5 +175,5 @@ }

quoteQuantity,
baseOut: baseOut / baseScalar,
quoteOut: quoteOut / quoteScalar,
deepRequired: deepRequired / DEEP_SCALAR
baseOut: Number((baseOut / baseScalar).toFixed(9)),
quoteOut: Number((quoteOut / quoteScalar).toFixed(9)),
deepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9))
};

@@ -260,5 +260,7 @@ }

prices: parsed_prices.map(
(price) => Number(price) / FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar
(price) => Number((Number(price) / FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar).toFixed(9))
),
quantities: parsed_quantities.map((price) => Number(price) / baseCoin.scalar)
quantities: parsed_quantities.map(
(price) => Number((Number(price) / baseCoin.scalar).toFixed(9))
)
};

@@ -293,9 +295,13 @@ }

bid_prices: bid_parsed_prices.map(
(price) => Number(price) / FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar
(price) => Number((Number(price) / FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar).toFixed(9))
),
bid_quantities: bid_parsed_quantities.map((quantity) => Number(quantity) / baseCoin.scalar),
bid_quantities: bid_parsed_quantities.map(
(quantity) => Number((Number(quantity) / baseCoin.scalar).toFixed(9))
),
ask_prices: ask_parsed_prices.map(
(price) => Number(price) / FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar
(price) => Number((Number(price) / FLOAT_SCALAR / quoteCoin.scalar * baseCoin.scalar).toFixed(9))
),
ask_quantities: ask_parsed_quantities.map((quantity) => Number(quantity) / baseCoin.scalar)
ask_quantities: ask_parsed_quantities.map(
(quantity) => Number((Number(quantity) / baseCoin.scalar).toFixed(9))
)
};

@@ -323,5 +329,5 @@ }

return {
base: baseInVault / baseScalar,
quote: quoteInVault / quoteScalar,
deep: deepInVault / DEEP_SCALAR
base: Number((baseInVault / baseScalar).toFixed(9)),
quote: Number((quoteInVault / quoteScalar).toFixed(9)),
deep: Number((deepInVault / DEEP_SCALAR).toFixed(9))
};

@@ -366,3 +372,3 @@ }

const adjusted_mid_price = parsed_mid_price * baseCoin.scalar / quoteCoin.scalar / FLOAT_SCALAR;
return adjusted_mid_price;
return Number(adjusted_mid_price.toFixed(9));
}

@@ -369,0 +375,0 @@ }

@@ -8,1 +8,3 @@ export { DeepBookClient } from './client.js';

export { DeepBookConfig } from './utils/config.js';
export type { BalanceManager, Coin, Pool } from './types/index.js';
export type { CoinMap, PoolMap } from './utils/constants.js';

@@ -41,5 +41,6 @@ var __typeError = (msg) => {

const coin = __privateGet(this, _config).getCoin(coinKey);
const depositInput = Math.round(amountToDeposit * coin.scalar);
const deposit = coinWithBalance({
type: coin.type,
balance: amountToDeposit * coin.scalar
balance: depositInput
});

@@ -63,5 +64,6 @@ tx.moveCall({

const coin = __privateGet(this, _config).getCoin(coinKey);
const withdrawInput = Math.round(amountToWithdraw * coin.scalar);
const coinObject = tx.moveCall({
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,
arguments: [tx.object(managerId), tx.pure.u64(amountToWithdraw * coin.scalar)],
arguments: [tx.object(managerId), tx.pure.u64(withdrawInput)],
typeArguments: [coin.type]

@@ -68,0 +70,0 @@ });

@@ -42,4 +42,4 @@ var __typeError = (msg) => {

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const inputPrice = price * FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar;
const inputQuantity = quantity * baseCoin.scalar;
const inputPrice = Math.round(price * FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar);
const inputQuantity = Math.round(quantity * baseCoin.scalar);
const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));

@@ -86,2 +86,3 @@ tx.moveCall({

const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
const inputQuantity = Math.round(quantity * baseCoin.scalar);
tx.moveCall({

@@ -95,3 +96,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::place_market_order`,

tx.pure.u8(selfMatchingOption),
tx.pure.u64(quantity * baseCoin.scalar),
tx.pure.u64(inputQuantity),
tx.pure.bool(isBid),

@@ -118,2 +119,3 @@ tx.pure.bool(payWithDeep),

const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
const inputQuantity = Math.round(newQuantity * baseCoin.scalar);
tx.moveCall({

@@ -126,3 +128,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::modify_order`,

tx.pure.u128(orderId),
tx.pure.u64(newQuantity),
tx.pure.u64(inputQuantity),
tx.object(SUI_CLOCK_OBJECT_ID)

@@ -477,4 +479,5 @@ ],

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const baseCoinInput = params.baseCoin ?? coinWithBalance({ type: baseCoin.type, balance: baseAmount * baseCoin.scalar });
const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });
const baseCoinInput = params.baseCoin ?? coinWithBalance({ type: baseCoin.type, balance: Math.round(baseAmount * baseCoin.scalar) });
const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: Math.round(deepAmount * DEEP_SCALAR) });
const minQuoteInput = Math.round(minQuote * quoteCoin.scalar);
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({

@@ -486,3 +489,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,

deepCoin,
tx.pure.u64(quoteCoin.scalar * minQuote),
tx.pure.u64(minQuoteInput),
tx.object(SUI_CLOCK_OBJECT_ID)

@@ -510,4 +513,8 @@ ],

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const quoteCoinInput = params.quoteCoin ?? coinWithBalance({ type: quoteCoin.type, balance: quoteAmount * quoteCoin.scalar });
const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });
const quoteCoinInput = params.quoteCoin ?? coinWithBalance({
type: quoteCoin.type,
balance: Math.round(quoteAmount * quoteCoin.scalar)
});
const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: Math.round(deepAmount * DEEP_SCALAR) });
const minBaseInput = Math.round(minBase * baseCoin.scalar);
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({

@@ -519,3 +526,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,

deepCoin,
tx.pure.u64(baseCoin.scalar * minBase),
tx.pure.u64(minBaseInput),
tx.object(SUI_CLOCK_OBJECT_ID)

@@ -522,0 +529,0 @@ ],

@@ -25,5 +25,6 @@ var __typeError = (msg) => {

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const inputQuantity = Math.round(borrowAmount * baseCoin.scalar);
const [baseCoinResult, flashLoan] = tx.moveCall({
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_base`,
arguments: [tx.object(pool.address), tx.pure.u64(borrowAmount * baseCoin.scalar)],
arguments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],
typeArguments: [baseCoin.type, quoteCoin.type]

@@ -47,3 +48,3 @@ });

const [baseCoinReturn] = tx.splitCoins(baseCoinInput, [
tx.pure.u64(borrowAmount * borrowScalar)
tx.pure.u64(Math.round(borrowAmount * borrowScalar))
]);

@@ -67,5 +68,6 @@ tx.moveCall({

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const inputQuantity = Math.round(borrowAmount * quoteCoin.scalar);
const [quoteCoinResult, flashLoan] = tx.moveCall({
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_quote`,
arguments: [tx.object(pool.address), tx.pure.u64(borrowAmount * quoteCoin.scalar)],
arguments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],
typeArguments: [baseCoin.type, quoteCoin.type]

@@ -89,3 +91,3 @@ });

const [quoteCoinReturn] = tx.splitCoins(quoteCoinInput, [
tx.pure.u64(borrowAmount * borrowScalar)
tx.pure.u64(Math.round(borrowAmount * borrowScalar))
]);

@@ -92,0 +94,0 @@ tx.moveCall({

@@ -29,2 +29,3 @@ var __typeError = (msg) => {

const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const stakeInput = Math.round(stakeAmount * DEEP_SCALAR);
tx.moveCall({

@@ -36,3 +37,3 @@ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::stake`,

tradeProof,
tx.pure.u64(stakeAmount * DEEP_SCALAR)
tx.pure.u64(stakeInput)
],

@@ -78,5 +79,5 @@ typeArguments: [baseCoin.type, quoteCoin.type]

tradeProof,
tx.pure.u64(takerFee * FLOAT_SCALAR),
tx.pure.u64(makerFee * FLOAT_SCALAR),
tx.pure.u64(stakeRequired * DEEP_SCALAR)
tx.pure.u64(Math.round(takerFee * FLOAT_SCALAR)),
tx.pure.u64(Math.round(makerFee * FLOAT_SCALAR)),
tx.pure.u64(Math.round(stakeRequired * DEEP_SCALAR))
],

@@ -83,0 +84,0 @@ typeArguments: [baseCoin.type, quoteCoin.type]

const testnetPackageIds = {
DEEPBOOK_PACKAGE_ID: "0x279443bdf339c7beb585fa44bbd9fa40e4ff255b4df6a2eca32ccc469ffc9046",
REGISTRY_ID: "0xe9c839fd0c6469b750b96ebe0fe656eec25466dea2a57f7d6df12c63c71af9ac",
DEEPBOOK_PACKAGE_ID: "0x2c152dba0110d3afb76b659ed3436edd848b37e177c3abfc0296f8aefc2e6cf4",
REGISTRY_ID: "0x9162317a81a9eb66ecd42705529b2a39c7805f98f42312275c2e7a599d518437",
DEEP_TREASURY_ID: "0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb"

@@ -62,3 +62,3 @@ };

DEEP_SUI: {
address: `0x69c220e16a38e6f18073b2ae5d200d45f27449db86d3435a592474686037416e`,
address: `0x2decc59a6f05c5800e5c8a1135f9d133d1746f562bf56673e6e81ef4f7ccd3b7`,
baseCoin: "DEEP",

@@ -68,3 +68,3 @@ quoteCoin: "SUI"

SUI_DBUSDC: {
address: `0x7abf219eda0771e27a4cc1c87946515c3dfc6ef994b4b06aef81830ff3bfad7f`,
address: `0xace543e8239f0c19783e57bacb02c581fd38d52899bdce117e49c91b494c8b10`,
baseCoin: "SUI",

@@ -74,3 +74,3 @@ quoteCoin: "DBUSDC"

DEEP_DBUSDC: {
address: `0x4d48440f70032595f31d1fd39c4891e81e9b3f5d48ae2dde3198f26eebfed55e`,
address: `0x1faaa544a84c16215ef005edb046ddf8e1cfec0792aec3032e86e554b33bd33a`,
baseCoin: "DEEP",

@@ -80,3 +80,3 @@ quoteCoin: "DBUSDC"

DBUSDT_DBUSDC: {
address: `0x2d532573987c46e43b6d4c09d6b702caee045d330b7450300d331e57a11a0308`,
address: `0x83aca040eaeaf061e3d482a44d1a87a5b8b6206ad52edae9d0479b830a38106f`,
baseCoin: "DBUSDT",

@@ -83,0 +83,0 @@ quoteCoin: "DBUSDC"

@@ -5,3 +5,3 @@ {

"description": "Sui Deepbook SDK",
"version": "0.2.1",
"version": "0.3.0",
"license": "Apache-2.0",

@@ -8,0 +8,0 @@ "type": "commonjs",

@@ -96,3 +96,3 @@ // Copyright (c) Mysten Labs, Inc.

coinType: coin.type,
balance: adjusted_balance,
balance: Number(adjusted_balance.toFixed(9)),
};

@@ -146,5 +146,5 @@ }

baseQuantity,
baseOut: baseOut / baseScalar,
quoteOut: quoteOut / quoteScalar,
deepRequired: deepRequired / DEEP_SCALAR,
baseOut: Number((baseOut / baseScalar).toFixed(9)),
quoteOut: Number((quoteOut / quoteScalar).toFixed(9)),
deepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),
};

@@ -178,5 +178,5 @@ }

quoteQuantity: quoteQuantity,
baseOut: baseOut / baseScalar,
quoteOut: quoteOut / quoteScalar,
deepRequired: deepRequired / DEEP_SCALAR,
baseOut: Number((baseOut / baseScalar).toFixed(9)),
quoteOut: Number((quoteOut / quoteScalar).toFixed(9)),
deepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),
};

@@ -212,5 +212,5 @@ }

quoteQuantity,
baseOut: baseOut / baseScalar,
quoteOut: quoteOut / quoteScalar,
deepRequired: deepRequired / DEEP_SCALAR,
baseOut: Number((baseOut / baseScalar).toFixed(9)),
quoteOut: Number((quoteOut / quoteScalar).toFixed(9)),
deepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),
};

@@ -308,6 +308,8 @@ }

return {
prices: parsed_prices.map(
(price) => (Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar,
prices: parsed_prices.map((price) =>
Number(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),
),
quantities: parsed_quantities.map((price) => Number(price) / baseCoin.scalar),
quantities: parsed_quantities.map((price) =>
Number((Number(price) / baseCoin.scalar).toFixed(9)),
),
};

@@ -346,10 +348,14 @@ }

return {
bid_prices: bid_parsed_prices.map(
(price) => (Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar,
bid_prices: bid_parsed_prices.map((price) =>
Number(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),
),
bid_quantities: bid_parsed_quantities.map((quantity) => Number(quantity) / baseCoin.scalar),
ask_prices: ask_parsed_prices.map(
(price) => (Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar,
bid_quantities: bid_parsed_quantities.map((quantity) =>
Number((Number(quantity) / baseCoin.scalar).toFixed(9)),
),
ask_quantities: ask_parsed_quantities.map((quantity) => Number(quantity) / baseCoin.scalar),
ask_prices: ask_parsed_prices.map((price) =>
Number(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),
),
ask_quantities: ask_parsed_quantities.map((quantity) =>
Number((Number(quantity) / baseCoin.scalar).toFixed(9)),
),
};

@@ -381,5 +387,5 @@ }

return {
base: baseInVault / baseScalar,
quote: quoteInVault / quoteScalar,
deep: deepInVault / DEEP_SCALAR,
base: Number((baseInVault / baseScalar).toFixed(9)),
quote: Number((quoteInVault / quoteScalar).toFixed(9)),
deep: Number((deepInVault / DEEP_SCALAR).toFixed(9)),
};

@@ -434,4 +440,4 @@ }

return adjusted_mid_price;
return Number(adjusted_mid_price.toFixed(9));
}
}

@@ -11,1 +11,3 @@ // Copyright (c) Mysten Labs, Inc.

export { DeepBookConfig } from './utils/config.js';
export type { BalanceManager, Coin, Pool } from './types/index.js';
export type { CoinMap, PoolMap } from './utils/constants.js';

@@ -49,5 +49,6 @@ // Copyright (c) Mysten Labs, Inc.

const coin = this.#config.getCoin(coinKey);
const depositInput = Math.round(amountToDeposit * coin.scalar);
const deposit = coinWithBalance({
type: coin.type,
balance: amountToDeposit * coin.scalar,
balance: depositInput,
});

@@ -75,5 +76,6 @@

const coin = this.#config.getCoin(coinKey);
const withdrawInput = Math.round(amountToWithdraw * coin.scalar);
const coinObject = tx.moveCall({
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,
arguments: [tx.object(managerId), tx.pure.u64(amountToWithdraw * coin.scalar)],
arguments: [tx.object(managerId), tx.pure.u64(withdrawInput)],
typeArguments: [coin.type],

@@ -80,0 +82,0 @@ });

@@ -49,4 +49,4 @@ // Copyright (c) Mysten Labs, Inc.

const quoteCoin = this.#config.getCoin(pool.quoteCoin);
const inputPrice = (price * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar;
const inputQuantity = quantity * baseCoin.scalar;
const inputPrice = Math.round((price * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar);
const inputQuantity = Math.round(quantity * baseCoin.scalar);

@@ -97,2 +97,3 @@ const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));

const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
const inputQuantity = Math.round(quantity * baseCoin.scalar);

@@ -107,3 +108,3 @@ tx.moveCall({

tx.pure.u8(selfMatchingOption),
tx.pure.u64(quantity * baseCoin.scalar),
tx.pure.u64(inputQuantity),
tx.pure.bool(isBid),

@@ -133,2 +134,3 @@ tx.pure.bool(payWithDeep),

const tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));
const inputQuantity = Math.round(newQuantity * baseCoin.scalar);

@@ -142,3 +144,3 @@ tx.moveCall({

tx.pure.u128(orderId),
tx.pure.u64(newQuantity),
tx.pure.u64(inputQuantity),
tx.object(SUI_CLOCK_OBJECT_ID),

@@ -532,7 +534,10 @@ ],

params.baseCoin ??
coinWithBalance({ type: baseCoin.type, balance: baseAmount * baseCoin.scalar });
coinWithBalance({ type: baseCoin.type, balance: Math.round(baseAmount * baseCoin.scalar) });
const deepCoin =
params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });
params.deepCoin ??
coinWithBalance({ type: deepCoinType, balance: Math.round(deepAmount * DEEP_SCALAR) });
const minQuoteInput = Math.round(minQuote * quoteCoin.scalar);
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({

@@ -544,3 +549,3 @@ target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,

deepCoin,
tx.pure.u64(quoteCoin.scalar * minQuote),
tx.pure.u64(minQuoteInput),
tx.object(SUI_CLOCK_OBJECT_ID),

@@ -575,7 +580,13 @@ ],

params.quoteCoin ??
coinWithBalance({ type: quoteCoin.type, balance: quoteAmount * quoteCoin.scalar });
coinWithBalance({
type: quoteCoin.type,
balance: Math.round(quoteAmount * quoteCoin.scalar),
});
const deepCoin =
params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });
params.deepCoin ??
coinWithBalance({ type: deepCoinType, balance: Math.round(deepAmount * DEEP_SCALAR) });
const minBaseInput = Math.round(minBase * baseCoin.scalar);
const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({

@@ -587,3 +598,3 @@ target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,

deepCoin,
tx.pure.u64(baseCoin.scalar * minBase),
tx.pure.u64(minBaseInput),
tx.object(SUI_CLOCK_OBJECT_ID),

@@ -590,0 +601,0 @@ ],

@@ -30,5 +30,6 @@ // Copyright (c) Mysten Labs, Inc.

const quoteCoin = this.#config.getCoin(pool.quoteCoin);
const inputQuantity = Math.round(borrowAmount * baseCoin.scalar);
const [baseCoinResult, flashLoan] = tx.moveCall({
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_base`,
arguments: [tx.object(pool.address), tx.pure.u64(borrowAmount * baseCoin.scalar)],
arguments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],
typeArguments: [baseCoin.type, quoteCoin.type],

@@ -61,3 +62,3 @@ });

const [baseCoinReturn] = tx.splitCoins(baseCoinInput, [
tx.pure.u64(borrowAmount * borrowScalar),
tx.pure.u64(Math.round(borrowAmount * borrowScalar)),
]);

@@ -83,5 +84,6 @@ tx.moveCall({

const quoteCoin = this.#config.getCoin(pool.quoteCoin);
const inputQuantity = Math.round(borrowAmount * quoteCoin.scalar);
const [quoteCoinResult, flashLoan] = tx.moveCall({
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_quote`,
arguments: [tx.object(pool.address), tx.pure.u64(borrowAmount * quoteCoin.scalar)],
arguments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],
typeArguments: [baseCoin.type, quoteCoin.type],

@@ -114,3 +116,3 @@ });

const [quoteCoinReturn] = tx.splitCoins(quoteCoinInput, [
tx.pure.u64(borrowAmount * borrowScalar),
tx.pure.u64(Math.round(borrowAmount * borrowScalar)),
]);

@@ -117,0 +119,0 @@ tx.moveCall({

@@ -36,2 +36,3 @@ // Copyright (c) Mysten Labs, Inc.

const quoteCoin = this.#config.getCoin(pool.quoteCoin);
const stakeInput = Math.round(stakeAmount * DEEP_SCALAR);

@@ -44,3 +45,3 @@ tx.moveCall({

tradeProof,
tx.pure.u64(stakeAmount * DEEP_SCALAR),
tx.pure.u64(stakeInput),
],

@@ -91,5 +92,5 @@ typeArguments: [baseCoin.type, quoteCoin.type],

tradeProof,
tx.pure.u64(takerFee * FLOAT_SCALAR),
tx.pure.u64(makerFee * FLOAT_SCALAR),
tx.pure.u64(stakeRequired * DEEP_SCALAR),
tx.pure.u64(Math.round(takerFee * FLOAT_SCALAR)),
tx.pure.u64(Math.round(makerFee * FLOAT_SCALAR)),
tx.pure.u64(Math.round(stakeRequired * DEEP_SCALAR)),
],

@@ -96,0 +97,0 @@ typeArguments: [baseCoin.type, quoteCoin.type],

@@ -15,4 +15,4 @@ // Copyright (c) Mysten Labs, Inc.

export const testnetPackageIds = {
DEEPBOOK_PACKAGE_ID: '0x279443bdf339c7beb585fa44bbd9fa40e4ff255b4df6a2eca32ccc469ffc9046',
REGISTRY_ID: '0xe9c839fd0c6469b750b96ebe0fe656eec25466dea2a57f7d6df12c63c71af9ac',
DEEPBOOK_PACKAGE_ID: '0x2c152dba0110d3afb76b659ed3436edd848b37e177c3abfc0296f8aefc2e6cf4',
REGISTRY_ID: '0x9162317a81a9eb66ecd42705529b2a39c7805f98f42312275c2e7a599d518437',
DEEP_TREASURY_ID: '0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb',

@@ -80,3 +80,3 @@ } satisfies DeepbookPackageIds;

DEEP_SUI: {
address: `0x69c220e16a38e6f18073b2ae5d200d45f27449db86d3435a592474686037416e`,
address: `0x2decc59a6f05c5800e5c8a1135f9d133d1746f562bf56673e6e81ef4f7ccd3b7`,
baseCoin: 'DEEP',

@@ -86,3 +86,3 @@ quoteCoin: 'SUI',

SUI_DBUSDC: {
address: `0x7abf219eda0771e27a4cc1c87946515c3dfc6ef994b4b06aef81830ff3bfad7f`,
address: `0xace543e8239f0c19783e57bacb02c581fd38d52899bdce117e49c91b494c8b10`,
baseCoin: 'SUI',

@@ -92,3 +92,3 @@ quoteCoin: 'DBUSDC',

DEEP_DBUSDC: {
address: `0x4d48440f70032595f31d1fd39c4891e81e9b3f5d48ae2dde3198f26eebfed55e`,
address: `0x1faaa544a84c16215ef005edb046ddf8e1cfec0792aec3032e86e554b33bd33a`,
baseCoin: 'DEEP',

@@ -98,3 +98,3 @@ quoteCoin: 'DBUSDC',

DBUSDT_DBUSDC: {
address: `0x2d532573987c46e43b6d4c09d6b702caee045d330b7450300d331e57a11a0308`,
address: `0x83aca040eaeaf061e3d482a44d1a87a5b8b6206ad52edae9d0479b830a38106f`,
baseCoin: 'DBUSDT',

@@ -101,0 +101,0 @@ quoteCoin: 'DBUSDC',

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc