@mysten/deepbook-v3
Advanced tools
Comparing version 0.0.0-experimental-20240821151359 to 0.0.0-experimental-20240823153043
# @mysten/deepbook-v3 | ||
## 0.0.0-experimental-20240821151359 | ||
## 0.0.0-experimental-20240823153043 | ||
### Minor Changes | ||
- adc704a: trade params and account getters | ||
## 0.3.3 | ||
### Patch Changes | ||
@@ -6,0 +12,0 @@ |
@@ -177,2 +177,47 @@ import type { SuiClient } from '@mysten/sui/client'; | ||
midPrice(poolKey: string): Promise<number>; | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns {Promise<{ takerFee: number, makerFee: number, stakeRequired: number }>} | ||
*/ | ||
poolTradeParams(poolKey: string): Promise<{ | ||
takerFee: number; | ||
makerFee: number; | ||
stakeRequired: number; | ||
}>; | ||
/** | ||
* @description Get the account information for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<Object>} A promise that resolves to an object containing the account information | ||
*/ | ||
account(poolKey: string, managerKey: string): Promise<{ | ||
epoch: string; | ||
open_orders: { | ||
constants: string[]; | ||
}; | ||
taker_volume: number; | ||
maker_volume: number; | ||
active_stake: number; | ||
inactive_stake: number; | ||
created_proposal: boolean; | ||
voted_proposal: { | ||
bytes: string; | ||
} | null; | ||
unclaimed_rebates: { | ||
base: number; | ||
quote: number; | ||
deep: number; | ||
}; | ||
settled_balances: { | ||
base: number; | ||
quote: number; | ||
deep: number; | ||
}; | ||
owed_balances: { | ||
base: number; | ||
quote: number; | ||
deep: number; | ||
}; | ||
}>; | ||
} |
@@ -390,2 +390,93 @@ "use strict"; | ||
} | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns {Promise<{ takerFee: number, makerFee: number, stakeRequired: number }>} | ||
*/ | ||
async poolTradeParams(poolKey) { | ||
const tx = new import_transactions.Transaction(); | ||
tx.add(this.deepBook.poolTradeParams(poolKey)); | ||
const res = await this.client.devInspectTransactionBlock({ | ||
sender: (0, import_utils.normalizeSuiAddress)(__privateGet(this, _address)), | ||
transactionBlock: tx | ||
}); | ||
const takerFee = Number(import_bcs.bcs.U64.parse(new Uint8Array(res.results[0].returnValues[0][0]))); | ||
const makerFee = Number(import_bcs.bcs.U64.parse(new Uint8Array(res.results[0].returnValues[1][0]))); | ||
const stakeRequired = Number( | ||
import_bcs.bcs.U64.parse(new Uint8Array(res.results[0].returnValues[2][0])) | ||
); | ||
return { | ||
takerFee: Number(takerFee / import_config.FLOAT_SCALAR), | ||
makerFee: Number(makerFee / import_config.FLOAT_SCALAR), | ||
stakeRequired: Number(stakeRequired / import_config.DEEP_SCALAR) | ||
}; | ||
} | ||
/** | ||
* @description Get the account information for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<Object>} A promise that resolves to an object containing the account information | ||
*/ | ||
async account(poolKey, managerKey) { | ||
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.account(poolKey, managerKey)); | ||
const res = await this.client.devInspectTransactionBlock({ | ||
sender: (0, import_utils.normalizeSuiAddress)(__privateGet(this, _address)), | ||
transactionBlock: tx | ||
}); | ||
const ID = import_bcs.bcs.struct("ID", { | ||
bytes: import_bcs.bcs.Address | ||
}); | ||
const Balances = import_bcs.bcs.struct("Balances", { | ||
base: import_bcs.bcs.u64(), | ||
quote: import_bcs.bcs.u64(), | ||
deep: import_bcs.bcs.u64() | ||
}); | ||
const VecSet = import_bcs.bcs.struct("VecSet", { | ||
constants: import_bcs.bcs.vector(import_bcs.bcs.U128) | ||
}); | ||
const Account = import_bcs.bcs.struct("Account", { | ||
epoch: import_bcs.bcs.u64(), | ||
open_orders: VecSet, | ||
taker_volume: import_bcs.bcs.u128(), | ||
maker_volume: import_bcs.bcs.u128(), | ||
active_stake: import_bcs.bcs.u64(), | ||
inactive_stake: import_bcs.bcs.u64(), | ||
created_proposal: import_bcs.bcs.bool(), | ||
voted_proposal: import_bcs.bcs.option(ID), | ||
unclaimed_rebates: Balances, | ||
settled_balances: Balances, | ||
owed_balances: Balances | ||
}); | ||
const accountInformation = res.results[0].returnValues[0][0]; | ||
const accountInfo = Account.parse(new Uint8Array(accountInformation)); | ||
return { | ||
epoch: accountInfo.epoch, | ||
open_orders: accountInfo.open_orders, | ||
taker_volume: Number(accountInfo.taker_volume) / baseScalar, | ||
maker_volume: Number(accountInfo.maker_volume) / baseScalar, | ||
active_stake: Number(accountInfo.active_stake) / import_config.DEEP_SCALAR, | ||
inactive_stake: Number(accountInfo.inactive_stake) / import_config.DEEP_SCALAR, | ||
created_proposal: accountInfo.created_proposal, | ||
voted_proposal: accountInfo.voted_proposal, | ||
unclaimed_rebates: { | ||
base: Number(accountInfo.unclaimed_rebates.base) / baseScalar, | ||
quote: Number(accountInfo.unclaimed_rebates.quote) / quoteScalar, | ||
deep: Number(accountInfo.unclaimed_rebates.deep) / import_config.DEEP_SCALAR | ||
}, | ||
settled_balances: { | ||
base: Number(accountInfo.settled_balances.base) / baseScalar, | ||
quote: Number(accountInfo.settled_balances.quote) / quoteScalar, | ||
deep: Number(accountInfo.settled_balances.deep) / import_config.DEEP_SCALAR | ||
}, | ||
owed_balances: { | ||
base: Number(accountInfo.owed_balances.base) / baseScalar, | ||
quote: Number(accountInfo.owed_balances.quote) / quoteScalar, | ||
deep: Number(accountInfo.owed_balances.deep) / import_config.DEEP_SCALAR | ||
} | ||
}; | ||
} | ||
} | ||
@@ -392,0 +483,0 @@ _config = new WeakMap(); |
@@ -183,2 +183,15 @@ import type { Transaction } from '@mysten/sui/transactions'; | ||
}]; | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
poolTradeParams: (poolKey: string) => (tx: Transaction) => void; | ||
/** | ||
* @description Get the account information 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 | ||
*/ | ||
account: (poolKey: string, managerKey: string) => (tx: Transaction) => void; | ||
} |
@@ -548,2 +548,34 @@ "use strict"; | ||
}; | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
this.poolTradeParams = (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::pool_trade_params`, | ||
arguments: [tx.object(pool.address)], | ||
typeArguments: [baseCoin.type, quoteCoin.type] | ||
}); | ||
}; | ||
/** | ||
* @description Get the account information 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.account = (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::account`, | ||
arguments: [tx.object(pool.address), tx.object(managerId)], | ||
typeArguments: [baseCoin.type, quoteCoin.type] | ||
}); | ||
}; | ||
__privateSet(this, _config, config); | ||
@@ -550,0 +582,0 @@ } |
@@ -30,3 +30,3 @@ "use strict"; | ||
const testnetPackageIds = { | ||
DEEPBOOK_PACKAGE_ID: "0xc671049379e6d512e3ecd0e79da50cb28840f09764d80a342b904863d87e5389", | ||
DEEPBOOK_PACKAGE_ID: "0x4251db4eb0622b82c8729f5d1b4a2db010a82d5493c706c14174a69ab9e6b4f1", | ||
REGISTRY_ID: "0x9162317a81a9eb66ecd42705529b2a39c7805f98f42312275c2e7a599d518437", | ||
@@ -33,0 +33,0 @@ DEEP_TREASURY_ID: "0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb" |
@@ -177,2 +177,47 @@ import type { SuiClient } from '@mysten/sui/client'; | ||
midPrice(poolKey: string): Promise<number>; | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns {Promise<{ takerFee: number, makerFee: number, stakeRequired: number }>} | ||
*/ | ||
poolTradeParams(poolKey: string): Promise<{ | ||
takerFee: number; | ||
makerFee: number; | ||
stakeRequired: number; | ||
}>; | ||
/** | ||
* @description Get the account information for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<Object>} A promise that resolves to an object containing the account information | ||
*/ | ||
account(poolKey: string, managerKey: string): Promise<{ | ||
epoch: string; | ||
open_orders: { | ||
constants: string[]; | ||
}; | ||
taker_volume: number; | ||
maker_volume: number; | ||
active_stake: number; | ||
inactive_stake: number; | ||
created_proposal: boolean; | ||
voted_proposal: { | ||
bytes: string; | ||
} | null; | ||
unclaimed_rebates: { | ||
base: number; | ||
quote: number; | ||
deep: number; | ||
}; | ||
settled_balances: { | ||
base: number; | ||
quote: number; | ||
deep: number; | ||
}; | ||
owed_balances: { | ||
base: number; | ||
quote: number; | ||
deep: number; | ||
}; | ||
}>; | ||
} |
@@ -367,2 +367,93 @@ var __typeError = (msg) => { | ||
} | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns {Promise<{ takerFee: number, makerFee: number, stakeRequired: number }>} | ||
*/ | ||
async poolTradeParams(poolKey) { | ||
const tx = new Transaction(); | ||
tx.add(this.deepBook.poolTradeParams(poolKey)); | ||
const res = await this.client.devInspectTransactionBlock({ | ||
sender: normalizeSuiAddress(__privateGet(this, _address)), | ||
transactionBlock: tx | ||
}); | ||
const takerFee = Number(bcs.U64.parse(new Uint8Array(res.results[0].returnValues[0][0]))); | ||
const makerFee = Number(bcs.U64.parse(new Uint8Array(res.results[0].returnValues[1][0]))); | ||
const stakeRequired = Number( | ||
bcs.U64.parse(new Uint8Array(res.results[0].returnValues[2][0])) | ||
); | ||
return { | ||
takerFee: Number(takerFee / FLOAT_SCALAR), | ||
makerFee: Number(makerFee / FLOAT_SCALAR), | ||
stakeRequired: Number(stakeRequired / DEEP_SCALAR) | ||
}; | ||
} | ||
/** | ||
* @description Get the account information for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<Object>} A promise that resolves to an object containing the account information | ||
*/ | ||
async account(poolKey, managerKey) { | ||
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.account(poolKey, managerKey)); | ||
const res = await this.client.devInspectTransactionBlock({ | ||
sender: normalizeSuiAddress(__privateGet(this, _address)), | ||
transactionBlock: tx | ||
}); | ||
const ID = bcs.struct("ID", { | ||
bytes: bcs.Address | ||
}); | ||
const Balances = bcs.struct("Balances", { | ||
base: bcs.u64(), | ||
quote: bcs.u64(), | ||
deep: bcs.u64() | ||
}); | ||
const VecSet = bcs.struct("VecSet", { | ||
constants: bcs.vector(bcs.U128) | ||
}); | ||
const Account = bcs.struct("Account", { | ||
epoch: bcs.u64(), | ||
open_orders: VecSet, | ||
taker_volume: bcs.u128(), | ||
maker_volume: bcs.u128(), | ||
active_stake: bcs.u64(), | ||
inactive_stake: bcs.u64(), | ||
created_proposal: bcs.bool(), | ||
voted_proposal: bcs.option(ID), | ||
unclaimed_rebates: Balances, | ||
settled_balances: Balances, | ||
owed_balances: Balances | ||
}); | ||
const accountInformation = res.results[0].returnValues[0][0]; | ||
const accountInfo = Account.parse(new Uint8Array(accountInformation)); | ||
return { | ||
epoch: accountInfo.epoch, | ||
open_orders: accountInfo.open_orders, | ||
taker_volume: Number(accountInfo.taker_volume) / baseScalar, | ||
maker_volume: Number(accountInfo.maker_volume) / baseScalar, | ||
active_stake: Number(accountInfo.active_stake) / DEEP_SCALAR, | ||
inactive_stake: Number(accountInfo.inactive_stake) / DEEP_SCALAR, | ||
created_proposal: accountInfo.created_proposal, | ||
voted_proposal: accountInfo.voted_proposal, | ||
unclaimed_rebates: { | ||
base: Number(accountInfo.unclaimed_rebates.base) / baseScalar, | ||
quote: Number(accountInfo.unclaimed_rebates.quote) / quoteScalar, | ||
deep: Number(accountInfo.unclaimed_rebates.deep) / DEEP_SCALAR | ||
}, | ||
settled_balances: { | ||
base: Number(accountInfo.settled_balances.base) / baseScalar, | ||
quote: Number(accountInfo.settled_balances.quote) / quoteScalar, | ||
deep: Number(accountInfo.settled_balances.deep) / DEEP_SCALAR | ||
}, | ||
owed_balances: { | ||
base: Number(accountInfo.owed_balances.base) / baseScalar, | ||
quote: Number(accountInfo.owed_balances.quote) / quoteScalar, | ||
deep: Number(accountInfo.owed_balances.deep) / DEEP_SCALAR | ||
} | ||
}; | ||
} | ||
} | ||
@@ -369,0 +460,0 @@ _config = new WeakMap(); |
@@ -183,2 +183,15 @@ import type { Transaction } from '@mysten/sui/transactions'; | ||
}]; | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
poolTradeParams: (poolKey: string) => (tx: Transaction) => void; | ||
/** | ||
* @description Get the account information 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 | ||
*/ | ||
account: (poolKey: string, managerKey: string) => (tx: Transaction) => void; | ||
} |
@@ -525,2 +525,34 @@ var __typeError = (msg) => { | ||
}; | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
this.poolTradeParams = (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::pool_trade_params`, | ||
arguments: [tx.object(pool.address)], | ||
typeArguments: [baseCoin.type, quoteCoin.type] | ||
}); | ||
}; | ||
/** | ||
* @description Get the account information 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.account = (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::account`, | ||
arguments: [tx.object(pool.address), tx.object(managerId)], | ||
typeArguments: [baseCoin.type, quoteCoin.type] | ||
}); | ||
}; | ||
__privateSet(this, _config, config); | ||
@@ -527,0 +559,0 @@ } |
const testnetPackageIds = { | ||
DEEPBOOK_PACKAGE_ID: "0xc671049379e6d512e3ecd0e79da50cb28840f09764d80a342b904863d87e5389", | ||
DEEPBOOK_PACKAGE_ID: "0x4251db4eb0622b82c8729f5d1b4a2db010a82d5493c706c14174a69ab9e6b4f1", | ||
REGISTRY_ID: "0x9162317a81a9eb66ecd42705529b2a39c7805f98f42312275c2e7a599d518437", | ||
@@ -4,0 +4,0 @@ DEEP_TREASURY_ID: "0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb" |
@@ -5,3 +5,3 @@ { | ||
"description": "Sui Deepbook SDK", | ||
"version": "0.0.0-experimental-20240821151359", | ||
"version": "0.0.0-experimental-20240823153043", | ||
"license": "Apache-2.0", | ||
@@ -8,0 +8,0 @@ "type": "commonjs", |
@@ -435,2 +435,105 @@ // Copyright (c) Mysten Labs, Inc. | ||
} | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns {Promise<{ takerFee: number, makerFee: number, stakeRequired: number }>} | ||
*/ | ||
async poolTradeParams(poolKey: string) { | ||
const tx = new Transaction(); | ||
tx.add(this.deepBook.poolTradeParams(poolKey)); | ||
const res = await this.client.devInspectTransactionBlock({ | ||
sender: normalizeSuiAddress(this.#address), | ||
transactionBlock: tx, | ||
}); | ||
const takerFee = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0]))); | ||
const makerFee = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0]))); | ||
const stakeRequired = Number( | ||
bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])), | ||
); | ||
return { | ||
takerFee: Number(takerFee / FLOAT_SCALAR), | ||
makerFee: Number(makerFee / FLOAT_SCALAR), | ||
stakeRequired: Number(stakeRequired / DEEP_SCALAR), | ||
}; | ||
} | ||
/** | ||
* @description Get the account information for a given pool and balance manager | ||
* @param {string} poolKey Key of the pool | ||
* @param {string} managerKey The key of the BalanceManager | ||
* @returns {Promise<Object>} A promise that resolves to an object containing the account information | ||
*/ | ||
async account(poolKey: string, managerKey: 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.account(poolKey, managerKey)); | ||
const res = await this.client.devInspectTransactionBlock({ | ||
sender: normalizeSuiAddress(this.#address), | ||
transactionBlock: tx, | ||
}); | ||
const ID = bcs.struct('ID', { | ||
bytes: bcs.Address, | ||
}); | ||
const Balances = bcs.struct('Balances', { | ||
base: bcs.u64(), | ||
quote: bcs.u64(), | ||
deep: bcs.u64(), | ||
}); | ||
const VecSet = bcs.struct('VecSet', { | ||
constants: bcs.vector(bcs.U128), | ||
}); | ||
const Account = bcs.struct('Account', { | ||
epoch: bcs.u64(), | ||
open_orders: VecSet, | ||
taker_volume: bcs.u128(), | ||
maker_volume: bcs.u128(), | ||
active_stake: bcs.u64(), | ||
inactive_stake: bcs.u64(), | ||
created_proposal: bcs.bool(), | ||
voted_proposal: bcs.option(ID), | ||
unclaimed_rebates: Balances, | ||
settled_balances: Balances, | ||
owed_balances: Balances, | ||
}); | ||
const accountInformation = res.results![0].returnValues![0][0]; | ||
const accountInfo = Account.parse(new Uint8Array(accountInformation)); | ||
return { | ||
epoch: accountInfo.epoch, | ||
open_orders: accountInfo.open_orders, | ||
taker_volume: Number(accountInfo.taker_volume) / baseScalar, | ||
maker_volume: Number(accountInfo.maker_volume) / baseScalar, | ||
active_stake: Number(accountInfo.active_stake) / DEEP_SCALAR, | ||
inactive_stake: Number(accountInfo.inactive_stake) / DEEP_SCALAR, | ||
created_proposal: accountInfo.created_proposal, | ||
voted_proposal: accountInfo.voted_proposal, | ||
unclaimed_rebates: { | ||
base: Number(accountInfo.unclaimed_rebates.base) / baseScalar, | ||
quote: Number(accountInfo.unclaimed_rebates.quote) / quoteScalar, | ||
deep: Number(accountInfo.unclaimed_rebates.deep) / DEEP_SCALAR, | ||
}, | ||
settled_balances: { | ||
base: Number(accountInfo.settled_balances.base) / baseScalar, | ||
quote: Number(accountInfo.settled_balances.quote) / quoteScalar, | ||
deep: Number(accountInfo.settled_balances.deep) / DEEP_SCALAR, | ||
}, | ||
owed_balances: { | ||
base: Number(accountInfo.owed_balances.base) / baseScalar, | ||
quote: Number(accountInfo.owed_balances.quote) / quoteScalar, | ||
deep: Number(accountInfo.owed_balances.deep) / DEEP_SCALAR, | ||
}, | ||
}; | ||
} | ||
} |
@@ -598,2 +598,38 @@ // Copyright (c) Mysten Labs, Inc. | ||
}; | ||
/** | ||
* @description Get the trade parameters for a given pool, including taker fee, maker fee, and stake required. | ||
* @param {string} poolKey Key of the pool | ||
* @returns A function that takes a Transaction object | ||
*/ | ||
poolTradeParams = (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::pool_trade_params`, | ||
arguments: [tx.object(pool.address)], | ||
typeArguments: [baseCoin.type, quoteCoin.type], | ||
}); | ||
}; | ||
/** | ||
* @description Get the account information 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 | ||
*/ | ||
account = (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::account`, | ||
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: '0xc671049379e6d512e3ecd0e79da50cb28840f09764d80a342b904863d87e5389', | ||
DEEPBOOK_PACKAGE_ID: '0x4251db4eb0622b82c8729f5d1b4a2db010a82d5493c706c14174a69ab9e6b4f1', | ||
REGISTRY_ID: '0x9162317a81a9eb66ecd42705529b2a39c7805f98f42312275c2e7a599d518437', | ||
@@ -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
683854
7158