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
141
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.0.0-experimental-20241104181539 to 0.0.0-experimental-20241104222610

10

CHANGELOG.md
# @mysten/deepbook-v3
## 0.0.0-experimental-20241104181539
## 0.0.0-experimental-20241104222610
### Patch Changes
- 6a571f1: Deep conversion
## 0.12.3
### Patch Changes
- Updated dependencies [69ef100]
- @mysten/sui@0.0.0-experimental-20241104181539
- @mysten/sui@1.14.1

@@ -10,0 +16,0 @@ ## 0.12.2

@@ -244,2 +244,16 @@ import type { SuiClient } from '@mysten/sui/client';

}>;
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey Key of the pool
* @returns {Promise<{ asset_is_base: bool, deep_per_quote: number }>} Deep price conversion
*/
getPoolDeepPrice(poolKey: string): Promise<{
asset_is_base: true;
deep_per_base: number;
deep_per_quote?: undefined;
} | {
asset_is_base: false;
deep_per_quote: number;
deep_per_base?: undefined;
}>;
}

@@ -535,2 +535,36 @@ "use strict";

}
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey Key of the pool
* @returns {Promise<{ asset_is_base: bool, deep_per_quote: number }>} Deep price conversion
*/
async getPoolDeepPrice(poolKey) {
const tx = new import_transactions.Transaction();
const pool = __privateGet(this, _config).getPool(poolKey);
tx.add(this.deepBook.getPoolDeepPrice(poolKey));
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const deepCoin = __privateGet(this, _config).getCoin("DEEP");
const res = await this.client.devInspectTransactionBlock({
sender: (0, import_utils.normalizeSuiAddress)(__privateGet(this, _address)),
transactionBlock: tx
});
const OrderDeepPrice = import_bcs.bcs.struct("OrderDeepPrice", {
asset_is_base: import_bcs.bcs.bool(),
deep_per_asset: import_bcs.bcs.u64()
});
const poolDeepPriceBytes = res.results[0].returnValues[0][0];
const poolDeepPrice = OrderDeepPrice.parse(new Uint8Array(poolDeepPriceBytes));
if (poolDeepPrice.asset_is_base) {
return {
asset_is_base: poolDeepPrice.asset_is_base,
deep_per_base: Number(poolDeepPrice.deep_per_asset) / import_config.FLOAT_SCALAR * baseCoin.scalar / deepCoin.scalar
};
} else {
return {
asset_is_base: poolDeepPrice.asset_is_base,
deep_per_quote: Number(poolDeepPrice.deep_per_asset) / import_config.FLOAT_SCALAR * quoteCoin.scalar / deepCoin.scalar
};
}
}
}

@@ -537,0 +571,0 @@ _config = new WeakMap();

@@ -209,2 +209,8 @@ import type { Transaction } from '@mysten/sui/transactions';

lockedBalance: (poolKey: string, managerKey: string) => (tx: Transaction) => void;
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey The key to identify the pool
* @returns A function that takes a Transaction object
*/
getPoolDeepPrice: (poolKey: string) => (tx: Transaction) => void;
}

@@ -612,2 +612,17 @@ "use strict";

};
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey The key to identify the pool
* @returns A function that takes a Transaction object
*/
this.getPoolDeepPrice = (poolKey) => (tx) => {
const pool = __privateGet(this, _config).getPool(poolKey);
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
tx.moveCall({
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_order_deep_price`,
arguments: [tx.object(pool.address)],
typeArguments: [baseCoin.type, quoteCoin.type]
});
};
__privateSet(this, _config, config);

@@ -614,0 +629,0 @@ }

@@ -244,2 +244,16 @@ import type { SuiClient } from '@mysten/sui/client';

}>;
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey Key of the pool
* @returns {Promise<{ asset_is_base: bool, deep_per_quote: number }>} Deep price conversion
*/
getPoolDeepPrice(poolKey: string): Promise<{
asset_is_base: true;
deep_per_base: number;
deep_per_quote?: undefined;
} | {
asset_is_base: false;
deep_per_quote: number;
deep_per_base?: undefined;
}>;
}

@@ -512,2 +512,36 @@ var __typeError = (msg) => {

}
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey Key of the pool
* @returns {Promise<{ asset_is_base: bool, deep_per_quote: number }>} Deep price conversion
*/
async getPoolDeepPrice(poolKey) {
const tx = new Transaction();
const pool = __privateGet(this, _config).getPool(poolKey);
tx.add(this.deepBook.getPoolDeepPrice(poolKey));
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
const deepCoin = __privateGet(this, _config).getCoin("DEEP");
const res = await this.client.devInspectTransactionBlock({
sender: normalizeSuiAddress(__privateGet(this, _address)),
transactionBlock: tx
});
const OrderDeepPrice = bcs.struct("OrderDeepPrice", {
asset_is_base: bcs.bool(),
deep_per_asset: bcs.u64()
});
const poolDeepPriceBytes = res.results[0].returnValues[0][0];
const poolDeepPrice = OrderDeepPrice.parse(new Uint8Array(poolDeepPriceBytes));
if (poolDeepPrice.asset_is_base) {
return {
asset_is_base: poolDeepPrice.asset_is_base,
deep_per_base: Number(poolDeepPrice.deep_per_asset) / FLOAT_SCALAR * baseCoin.scalar / deepCoin.scalar
};
} else {
return {
asset_is_base: poolDeepPrice.asset_is_base,
deep_per_quote: Number(poolDeepPrice.deep_per_asset) / FLOAT_SCALAR * quoteCoin.scalar / deepCoin.scalar
};
}
}
}

@@ -514,0 +548,0 @@ _config = new WeakMap();

@@ -209,2 +209,8 @@ import type { Transaction } from '@mysten/sui/transactions';

lockedBalance: (poolKey: string, managerKey: string) => (tx: Transaction) => void;
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey The key to identify the pool
* @returns A function that takes a Transaction object
*/
getPoolDeepPrice: (poolKey: string) => (tx: Transaction) => void;
}

@@ -589,2 +589,17 @@ var __typeError = (msg) => {

};
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey The key to identify the pool
* @returns A function that takes a Transaction object
*/
this.getPoolDeepPrice = (poolKey) => (tx) => {
const pool = __privateGet(this, _config).getPool(poolKey);
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
tx.moveCall({
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::get_order_deep_price`,
arguments: [tx.object(pool.address)],
typeArguments: [baseCoin.type, quoteCoin.type]
});
};
__privateSet(this, _config, config);

@@ -591,0 +606,0 @@ }

4

package.json

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

"description": "Sui Deepbook SDK",
"version": "0.0.0-experimental-20241104181539",
"version": "0.0.0-experimental-20241104222610",
"license": "Apache-2.0",

@@ -27,3 +27,3 @@ "type": "commonjs",

"dependencies": {
"@mysten/sui": "0.0.0-experimental-20241104181539"
"@mysten/sui": "1.14.1"
},

@@ -30,0 +30,0 @@ "devDependencies": {

@@ -600,2 +600,46 @@ // Copyright (c) Mysten Labs, Inc.

}
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey Key of the pool
* @returns {Promise<{ asset_is_base: bool, deep_per_quote: number }>} Deep price conversion
*/
async getPoolDeepPrice(poolKey: string) {
const tx = new Transaction();
const pool = this.#config.getPool(poolKey);
tx.add(this.deepBook.getPoolDeepPrice(poolKey));
const baseCoin = this.#config.getCoin(pool.baseCoin);
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
const deepCoin = this.#config.getCoin('DEEP');
const res = await this.client.devInspectTransactionBlock({
sender: normalizeSuiAddress(this.#address),
transactionBlock: tx,
});
const OrderDeepPrice = bcs.struct('OrderDeepPrice', {
asset_is_base: bcs.bool(),
deep_per_asset: bcs.u64(),
});
const poolDeepPriceBytes = res.results![0].returnValues![0][0];
const poolDeepPrice = OrderDeepPrice.parse(new Uint8Array(poolDeepPriceBytes));
if (poolDeepPrice.asset_is_base) {
return {
asset_is_base: poolDeepPrice.asset_is_base,
deep_per_base:
((Number(poolDeepPrice.deep_per_asset) / FLOAT_SCALAR) * baseCoin.scalar) /
deepCoin.scalar,
};
} else {
return {
asset_is_base: poolDeepPrice.asset_is_base,
deep_per_quote:
((Number(poolDeepPrice.deep_per_asset) / FLOAT_SCALAR) * quoteCoin.scalar) /
deepCoin.scalar,
};
}
}
}

@@ -670,2 +670,19 @@ // Copyright (c) Mysten Labs, Inc.

};
/**
* @description Get the DEEP price conversion for a pool
* @param {string} poolKey The key to identify the pool
* @returns A function that takes a Transaction object
*/
getPoolDeepPrice = (poolKey: string) => (tx: Transaction) => {
const pool = this.#config.getPool(poolKey);
const baseCoin = this.#config.getCoin(pool.baseCoin);
const quoteCoin = this.#config.getCoin(pool.quoteCoin);
tx.moveCall({
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_order_deep_price`,
arguments: [tx.object(pool.address)],
typeArguments: [baseCoin.type, quoteCoin.type],
});
};
}

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