@mysten/deepbook-v3
Advanced tools
Comparing version 0.7.0 to 0.7.1
# @mysten/deepbook-v3 | ||
## 0.7.1 | ||
### Patch Changes | ||
- 37d259a: Locked balance feature | ||
## 0.7.0 | ||
@@ -4,0 +10,0 @@ |
@@ -232,2 +232,14 @@ import type { SuiClient } from '@mysten/sui/client'; | ||
}>; | ||
/** | ||
* @description Get the locked balances for a pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<{ base: number, quote: number, deep: number }>} | ||
* An object with base, quote, and deep locked for the balance manager in the pool | ||
*/ | ||
lockedBalance(poolKey: string, balanceManagerKey: string): Promise<{ | ||
base: number; | ||
quote: number; | ||
deep: number; | ||
}>; | ||
} |
@@ -509,2 +509,28 @@ "use strict"; | ||
} | ||
/** | ||
* @description Get the locked balances for a pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<{ base: number, quote: number, deep: number }>} | ||
* An object with base, quote, and deep locked for the balance manager in the pool | ||
*/ | ||
async lockedBalance(poolKey, balanceManagerKey) { | ||
const tx = new import_transactions.Transaction(); | ||
const pool = __privateGet(this, _config).getPool(poolKey); | ||
const baseScalar = __privateGet(this, _config).getCoin(pool.baseCoin).scalar; | ||
const quoteScalar = __privateGet(this, _config).getCoin(pool.quoteCoin).scalar; | ||
tx.add(this.deepBook.lockedBalance(poolKey, balanceManagerKey)); | ||
const res = await this.client.devInspectTransactionBlock({ | ||
sender: (0, import_utils.normalizeSuiAddress)(__privateGet(this, _address)), | ||
transactionBlock: tx | ||
}); | ||
const baseLocked = Number(import_bcs.bcs.U64.parse(new Uint8Array(res.results[0].returnValues[0][0]))); | ||
const quoteLocked = Number(import_bcs.bcs.U64.parse(new Uint8Array(res.results[0].returnValues[1][0]))); | ||
const deepLocked = Number(import_bcs.bcs.U64.parse(new Uint8Array(res.results[0].returnValues[2][0]))); | ||
return { | ||
base: Number((baseLocked / baseScalar).toFixed(9)), | ||
quote: Number((quoteLocked / quoteScalar).toFixed(9)), | ||
deep: Number((deepLocked / import_config.DEEP_SCALAR).toFixed(9)) | ||
}; | ||
} | ||
} | ||
@@ -511,0 +537,0 @@ _config = new WeakMap(); |
@@ -202,2 +202,9 @@ import type { Transaction } from '@mysten/sui/transactions'; | ||
account: (poolKey: string, managerKey: string) => (tx: Transaction) => void; | ||
/** | ||
* @description Get the locked balance for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
lockedBalance: (poolKey: string, managerKey: string) => (tx: Transaction) => void; | ||
} |
@@ -595,2 +595,19 @@ "use strict"; | ||
}; | ||
/** | ||
* @description Get the locked balance for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
this.lockedBalance = (poolKey, managerKey) => (tx) => { | ||
const pool = __privateGet(this, _config).getPool(poolKey); | ||
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin); | ||
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin); | ||
const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address; | ||
tx.moveCall({ | ||
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::locked_balance`, | ||
arguments: [tx.object(pool.address), tx.object(managerId)], | ||
typeArguments: [baseCoin.type, quoteCoin.type] | ||
}); | ||
}; | ||
__privateSet(this, _config, config); | ||
@@ -597,0 +614,0 @@ } |
@@ -30,3 +30,3 @@ "use strict"; | ||
const testnetPackageIds = { | ||
DEEPBOOK_PACKAGE_ID: "0xc819e689055c241fa1f35a4c87217809edc11b2e73a10fe93300f623e434ecf4", | ||
DEEPBOOK_PACKAGE_ID: "0xd97efea24d2b2f215adb9423211dc9c659cbc25635bdcad2cb2c92e3d28b6474", | ||
REGISTRY_ID: "0xc0bc8c0e0ebd8f891fca1ec0d553c4a06c546a3fa1e902e8fced0606b41a72db", | ||
@@ -33,0 +33,0 @@ DEEP_TREASURY_ID: "0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb" |
@@ -232,2 +232,14 @@ import type { SuiClient } from '@mysten/sui/client'; | ||
}>; | ||
/** | ||
* @description Get the locked balances for a pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<{ base: number, quote: number, deep: number }>} | ||
* An object with base, quote, and deep locked for the balance manager in the pool | ||
*/ | ||
lockedBalance(poolKey: string, balanceManagerKey: string): Promise<{ | ||
base: number; | ||
quote: number; | ||
deep: number; | ||
}>; | ||
} |
@@ -486,2 +486,28 @@ var __typeError = (msg) => { | ||
} | ||
/** | ||
* @description Get the locked balances for a pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<{ base: number, quote: number, deep: number }>} | ||
* An object with base, quote, and deep locked for the balance manager in the pool | ||
*/ | ||
async lockedBalance(poolKey, balanceManagerKey) { | ||
const tx = new Transaction(); | ||
const pool = __privateGet(this, _config).getPool(poolKey); | ||
const baseScalar = __privateGet(this, _config).getCoin(pool.baseCoin).scalar; | ||
const quoteScalar = __privateGet(this, _config).getCoin(pool.quoteCoin).scalar; | ||
tx.add(this.deepBook.lockedBalance(poolKey, balanceManagerKey)); | ||
const res = await this.client.devInspectTransactionBlock({ | ||
sender: normalizeSuiAddress(__privateGet(this, _address)), | ||
transactionBlock: tx | ||
}); | ||
const baseLocked = Number(bcs.U64.parse(new Uint8Array(res.results[0].returnValues[0][0]))); | ||
const quoteLocked = Number(bcs.U64.parse(new Uint8Array(res.results[0].returnValues[1][0]))); | ||
const deepLocked = Number(bcs.U64.parse(new Uint8Array(res.results[0].returnValues[2][0]))); | ||
return { | ||
base: Number((baseLocked / baseScalar).toFixed(9)), | ||
quote: Number((quoteLocked / quoteScalar).toFixed(9)), | ||
deep: Number((deepLocked / DEEP_SCALAR).toFixed(9)) | ||
}; | ||
} | ||
} | ||
@@ -488,0 +514,0 @@ _config = new WeakMap(); |
@@ -202,2 +202,9 @@ import type { Transaction } from '@mysten/sui/transactions'; | ||
account: (poolKey: string, managerKey: string) => (tx: Transaction) => void; | ||
/** | ||
* @description Get the locked balance for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
lockedBalance: (poolKey: string, managerKey: string) => (tx: Transaction) => void; | ||
} |
@@ -572,2 +572,19 @@ var __typeError = (msg) => { | ||
}; | ||
/** | ||
* @description Get the locked balance for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
this.lockedBalance = (poolKey, managerKey) => (tx) => { | ||
const pool = __privateGet(this, _config).getPool(poolKey); | ||
const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin); | ||
const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin); | ||
const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address; | ||
tx.moveCall({ | ||
target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::locked_balance`, | ||
arguments: [tx.object(pool.address), tx.object(managerId)], | ||
typeArguments: [baseCoin.type, quoteCoin.type] | ||
}); | ||
}; | ||
__privateSet(this, _config, config); | ||
@@ -574,0 +591,0 @@ } |
const testnetPackageIds = { | ||
DEEPBOOK_PACKAGE_ID: "0xc819e689055c241fa1f35a4c87217809edc11b2e73a10fe93300f623e434ecf4", | ||
DEEPBOOK_PACKAGE_ID: "0xd97efea24d2b2f215adb9423211dc9c659cbc25635bdcad2cb2c92e3d28b6474", | ||
REGISTRY_ID: "0xc0bc8c0e0ebd8f891fca1ec0d553c4a06c546a3fa1e902e8fced0606b41a72db", | ||
@@ -4,0 +4,0 @@ DEEP_TREASURY_ID: "0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb" |
@@ -5,3 +5,3 @@ { | ||
"description": "Sui Deepbook SDK", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"license": "Apache-2.0", | ||
@@ -8,0 +8,0 @@ "type": "commonjs", |
@@ -570,2 +570,32 @@ // Copyright (c) Mysten Labs, Inc. | ||
} | ||
/** | ||
* @description Get the locked balances for a pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<{ base: number, quote: number, deep: number }>} | ||
* An object with base, quote, and deep locked for the balance manager in the pool | ||
*/ | ||
async lockedBalance(poolKey: string, balanceManagerKey: string) { | ||
const tx = new Transaction(); | ||
const pool = this.#config.getPool(poolKey); | ||
const baseScalar = this.#config.getCoin(pool.baseCoin).scalar; | ||
const quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar; | ||
tx.add(this.deepBook.lockedBalance(poolKey, balanceManagerKey)); | ||
const res = await this.client.devInspectTransactionBlock({ | ||
sender: normalizeSuiAddress(this.#address), | ||
transactionBlock: tx, | ||
}); | ||
const baseLocked = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0]))); | ||
const quoteLocked = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0]))); | ||
const deepLocked = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0]))); | ||
return { | ||
base: Number((baseLocked / baseScalar).toFixed(9)), | ||
quote: Number((quoteLocked / quoteScalar).toFixed(9)), | ||
deep: Number((deepLocked / DEEP_SCALAR).toFixed(9)), | ||
}; | ||
} | ||
} |
@@ -651,2 +651,21 @@ // Copyright (c) Mysten Labs, Inc. | ||
}; | ||
/** | ||
* @description Get the locked balance for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
lockedBalance = (poolKey: string, managerKey: string) => (tx: Transaction) => { | ||
const pool = this.#config.getPool(poolKey); | ||
const baseCoin = this.#config.getCoin(pool.baseCoin); | ||
const quoteCoin = this.#config.getCoin(pool.quoteCoin); | ||
const managerId = this.#config.getBalanceManager(managerKey).address; | ||
tx.moveCall({ | ||
target: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::locked_balance`, | ||
arguments: [tx.object(pool.address), tx.object(managerId)], | ||
typeArguments: [baseCoin.type, quoteCoin.type], | ||
}); | ||
}; | ||
} |
@@ -15,3 +15,3 @@ // Copyright (c) Mysten Labs, Inc. | ||
export const testnetPackageIds = { | ||
DEEPBOOK_PACKAGE_ID: '0xc819e689055c241fa1f35a4c87217809edc11b2e73a10fe93300f623e434ecf4', | ||
DEEPBOOK_PACKAGE_ID: '0xd97efea24d2b2f215adb9423211dc9c659cbc25635bdcad2cb2c92e3d28b6474', | ||
REGISTRY_ID: '0xc0bc8c0e0ebd8f891fca1ec0d553c4a06c546a3fa1e902e8fced0606b41a72db', | ||
@@ -18,0 +18,0 @@ DEEP_TREASURY_ID: '0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb', |
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
721186
7624