@mysten/deepbook-v3 0.2.1 → 0.3.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/client.js +26 -20
  3. package/dist/cjs/client.js.map +2 -2
  4. package/dist/cjs/index.d.ts +2 -0
  5. package/dist/cjs/index.js.map +1 -1
  6. package/dist/cjs/transactions/balanceManager.js +4 -2
  7. package/dist/cjs/transactions/balanceManager.js.map +2 -2
  8. package/dist/cjs/transactions/deepbook.js +17 -10
  9. package/dist/cjs/transactions/deepbook.js.map +2 -2
  10. package/dist/cjs/transactions/flashLoans.js +6 -4
  11. package/dist/cjs/transactions/flashLoans.js.map +2 -2
  12. package/dist/cjs/transactions/governance.js +5 -4
  13. package/dist/cjs/transactions/governance.js.map +2 -2
  14. package/dist/cjs/utils/constants.js +6 -6
  15. package/dist/cjs/utils/constants.js.map +1 -1
  16. package/dist/esm/client.js +26 -20
  17. package/dist/esm/client.js.map +2 -2
  18. package/dist/esm/index.d.ts +2 -0
  19. package/dist/esm/index.js.map +1 -1
  20. package/dist/esm/transactions/balanceManager.js +4 -2
  21. package/dist/esm/transactions/balanceManager.js.map +2 -2
  22. package/dist/esm/transactions/deepbook.js +17 -10
  23. package/dist/esm/transactions/deepbook.js.map +2 -2
  24. package/dist/esm/transactions/flashLoans.js +6 -4
  25. package/dist/esm/transactions/flashLoans.js.map +2 -2
  26. package/dist/esm/transactions/governance.js +5 -4
  27. package/dist/esm/transactions/governance.js.map +2 -2
  28. package/dist/esm/utils/constants.js +6 -6
  29. package/dist/esm/utils/constants.js.map +1 -1
  30. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  31. package/dist/tsconfig.tsbuildinfo +1 -1
  32. package/package.json +1 -1
  33. package/src/client.ts +29 -23
  34. package/src/index.ts +2 -0
  35. package/src/transactions/balanceManager.ts +4 -2
  36. package/src/transactions/deepbook.ts +21 -10
  37. package/src/transactions/flashLoans.ts +6 -4
  38. package/src/transactions/governance.ts +5 -4
  39. package/src/utils/constants.ts +6 -6
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/client.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport type { SuiClient } from '@mysten/sui/client';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport { BalanceManagerContract } from './transactions/balanceManager.js';\nimport { DeepBookContract } from './transactions/deepbook.js';\nimport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nimport { FlashLoanContract } from './transactions/flashLoans.js';\nimport { GovernanceContract } from './transactions/governance.js';\nimport type { BalanceManager, Environment } from './types/index.js';\nimport { DEEP_SCALAR, DeepBookConfig, FLOAT_SCALAR } from './utils/config.js';\nimport type { CoinMap, PoolMap } from './utils/constants.js';\n\n/**\n * DeepBookClient class for managing DeepBook operations.\n */\nexport class DeepBookClient {\n\tclient: SuiClient;\n\t#config: DeepBookConfig;\n\t#address: string;\n\tbalanceManager: BalanceManagerContract;\n\tdeepBook: DeepBookContract;\n\tdeepBookAdmin: DeepBookAdminContract;\n\tflashLoans: FlashLoanContract;\n\tgovernance: GovernanceContract;\n\n\t/**\n\t * @param {SuiClient} client SuiClient instance\n\t * @param {string} address Address of the client\n\t * @param {Environment} env Environment configuration\n\t * @param {Object.<string, BalanceManager>} [balanceManagers] Optional initial BalanceManager map\n\t * @param {CoinMap} [coins] Optional initial CoinMap\n\t * @param {PoolMap} [pools] Optional initial PoolMap\n\t * @param {string} [adminCap] Optional admin capability\n\t */\n\tconstructor({\n\t\tclient,\n\t\taddress,\n\t\tenv,\n\t\tbalanceManagers,\n\t\tcoins,\n\t\tpools,\n\t\tadminCap,\n\t}: {\n\t\tclient: SuiClient;\n\t\taddress: string;\n\t\tenv: Environment;\n\t\tbalanceManagers?: { [key: string]: BalanceManager };\n\t\tcoins?: CoinMap;\n\t\tpools?: PoolMap;\n\t\tadminCap?: string;\n\t}) {\n\t\tthis.client = client;\n\t\tthis.#address = normalizeSuiAddress(address);\n\t\tthis.#config = new DeepBookConfig({\n\t\t\taddress: this.#address,\n\t\t\tenv,\n\t\t\tbalanceManagers,\n\t\t\tcoins,\n\t\t\tpools,\n\t\t\tadminCap,\n\t\t});\n\t\tthis.balanceManager = new BalanceManagerContract(this.#config);\n\t\tthis.deepBook = new DeepBookContract(this.#config);\n\t\tthis.deepBookAdmin = new DeepBookAdminContract(this.#config);\n\t\tthis.flashLoans = new FlashLoanContract(this.#config);\n\t\tthis.governance = new GovernanceContract(this.#config);\n\t}\n\n\t/**\n\t * @description Check the balance of a balance manager for a specific coin\n\t * @param {string} managerKey Key of the balance manager\n\t * @param {string} coinKey Key of the coin\n\t * @returns {Promise<{ coinType: string, balance: number }>} An object with coin type and balance\n\t */\n\tasync checkManagerBalance(managerKey: string, coinKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst coin = this.#config.getCoin(coinKey);\n\n\t\ttx.add(this.balanceManager.checkManagerBalance(managerKey, coinKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: this.#address,\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst parsed_balance = bcs.U64.parse(new Uint8Array(bytes));\n\t\tconst balanceNumber = Number(parsed_balance);\n\t\tconst adjusted_balance = balanceNumber / coin.scalar;\n\n\t\treturn {\n\t\t\tcoinType: coin.type,\n\t\t\tbalance: adjusted_balance,\n\t\t};\n\t}\n\n\t/**\n\t * @description Check if a pool is whitelisted\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<boolean>} Boolean indicating if the pool is whitelisted\n\t */\n\tasync whitelisted(poolKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.whitelisted(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst whitelisted = bcs.Bool.parse(new Uint8Array(bytes));\n\n\t\treturn whitelisted;\n\t}\n\n\t/**\n\t * @description Get the quote quantity out for a given base quantity\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @returns {Promise<{ baseQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with base quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getQuoteQuantityOut(poolKey: string, baseQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getQuoteQuantityOut(poolKey, baseQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbaseQuantity,\n\t\t\tbaseOut: baseOut / baseScalar,\n\t\t\tquoteOut: quoteOut / quoteScalar,\n\t\t\tdeepRequired: deepRequired / DEEP_SCALAR,\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the base quantity out for a given quote quantity\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns {Promise<{ quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with quote quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getBaseQuantityOut(poolKey: string, quoteQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getBaseQuantityOut(poolKey, quoteQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tquoteQuantity: quoteQuantity,\n\t\t\tbaseOut: baseOut / baseScalar,\n\t\t\tquoteOut: quoteOut / quoteScalar,\n\t\t\tdeepRequired: deepRequired / DEEP_SCALAR,\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the output quantities for given base and quote quantities. Only one quantity can be non-zero\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns {Promise<{ baseQuantity: number, quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with base quantity, quote quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getQuantityOut(poolKey: string, baseQuantity: number, quoteQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getQuantityOut(poolKey, baseQuantity, quoteQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbaseQuantity,\n\t\t\tquoteQuantity,\n\t\t\tbaseOut: baseOut / baseScalar,\n\t\t\tquoteOut: quoteOut / quoteScalar,\n\t\t\tdeepRequired: deepRequired / DEEP_SCALAR,\n\t\t};\n\t}\n\n\t/**\n\t * @description Get open orders for a balance manager in a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} managerKey Key of the balance manager\n\t * @returns {Promise<Array>} An array of open order IDs\n\t */\n\tasync accountOpenOrders(poolKey: string, managerKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.accountOpenOrders(poolKey, managerKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst order_ids = res.results![0].returnValues![0][0];\n\t\tconst VecSet = bcs.struct('VecSet', {\n\t\t\tconstants: bcs.vector(bcs.U128),\n\t\t});\n\n\t\treturn VecSet.parse(new Uint8Array(order_ids)).constants;\n\t}\n\n\t/**\n\t * @description Get the order information for a specific order in a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} orderId Order ID\n\t * @returns {Promise<Object>} A promise that resolves to an object containing the order information\n\t */\n\tasync getOrder(poolKey: string, orderId: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst ID = bcs.struct('ID', {\n\t\t\tbytes: bcs.Address,\n\t\t});\n\t\tconst OrderDeepPrice = bcs.struct('OrderDeepPrice', {\n\t\t\tasset_is_base: bcs.bool(),\n\t\t\tdeep_per_asset: bcs.u64(),\n\t\t});\n\t\tconst Order = bcs.struct('Order', {\n\t\t\tbalance_manager_id: ID,\n\t\t\torder_id: bcs.u128(),\n\t\t\tclient_order_id: bcs.u64(),\n\t\t\tquantity: bcs.u64(),\n\t\t\tfilled_quantity: bcs.u64(),\n\t\t\tfee_is_deep: bcs.bool(),\n\t\t\torder_deep_price: OrderDeepPrice,\n\t\t\tepoch: bcs.u64(),\n\t\t\tstatus: bcs.u8(),\n\t\t\texpire_timestamp: bcs.u64(),\n\t\t});\n\n\t\tconst orderInformation = res.results![0].returnValues![0][0];\n\t\treturn Order.parse(new Uint8Array(orderInformation));\n\t}\n\n\t/**\n\t * @description Get level 2 order book specifying range of price\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} priceLow Lower bound of the price range\n\t * @param {number} priceHigh Upper bound of the price range\n\t * @param {boolean} isBid Whether to get bid or ask orders\n\t * @returns {Promise<{ prices: Array<number>, quantities: Array<number> }>}\n\t * An object with arrays of prices and quantities\n\t */\n\tasync getLevel2Range(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(this.deepBook.getLevel2Range(poolKey, priceLow, priceHigh, isBid));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst prices = res.results![0].returnValues![0][0];\n\t\tconst parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(prices));\n\t\tconst quantities = res.results![0].returnValues![1][0];\n\t\tconst parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(quantities));\n\n\t\treturn {\n\t\t\tprices: parsed_prices.map(\n\t\t\t\t(price) => (Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar,\n\t\t\t),\n\t\t\tquantities: parsed_quantities.map((price) => Number(price) / baseCoin.scalar),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get level 2 order book ticks from mid-price for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} ticks Number of ticks from mid-price\n\t * @returns {Promise<{ bid_prices: Array<number>, bid_quantities: Array<number>, ask_prices: Array<number>, ask_quantities: Array<number> }>}\n\t * An object with arrays of prices and quantities\n\t */\n\tasync getLevel2TicksFromMid(poolKey: string, ticks: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(this.deepBook.getLevel2TicksFromMid(poolKey, ticks));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bid_prices = res.results![0].returnValues![0][0];\n\t\tconst bid_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_prices));\n\t\tconst bid_quantities = res.results![0].returnValues![1][0];\n\t\tconst bid_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_quantities));\n\n\t\tconst ask_prices = res.results![0].returnValues![2][0];\n\t\tconst ask_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_prices));\n\t\tconst ask_quantities = res.results![0].returnValues![3][0];\n\t\tconst ask_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_quantities));\n\n\t\treturn {\n\t\t\tbid_prices: bid_parsed_prices.map(\n\t\t\t\t(price) => (Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar,\n\t\t\t),\n\t\t\tbid_quantities: bid_parsed_quantities.map((quantity) => Number(quantity) / baseCoin.scalar),\n\t\t\task_prices: ask_parsed_prices.map(\n\t\t\t\t(price) => (Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar,\n\t\t\t),\n\t\t\task_quantities: ask_parsed_quantities.map((quantity) => Number(quantity) / baseCoin.scalar),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the vault balances for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ base: number, quote: number, deep: number }>}\n\t * An object with base, quote, and deep balances in the vault\n\t */\n\tasync vaultBalances(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.vaultBalances(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbase: baseInVault / baseScalar,\n\t\t\tquote: quoteInVault / quoteScalar,\n\t\t\tdeep: deepInVault / DEEP_SCALAR,\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the pool ID by asset types\n\t * @param {string} baseType Type of the base asset\n\t * @param {string} quoteType Type of the quote asset\n\t * @returns {Promise<string>} The address of the pool\n\t */\n\tasync getPoolIdByAssets(baseType: string, quoteType: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.deepBook.getPoolIdByAssets(baseType, quoteType));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst ID = bcs.struct('ID', {\n\t\t\tbytes: bcs.Address,\n\t\t});\n\t\tconst address = ID.parse(new Uint8Array(res.results![0].returnValues![0][0]))['bytes'];\n\n\t\treturn address;\n\t}\n\n\t/**\n\t * @description Get the mid price for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<number>} The mid price\n\t */\n\tasync midPrice(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\ttx.add(this.deepBook.midPrice(poolKey));\n\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst parsed_mid_price = Number(bcs.U64.parse(new Uint8Array(bytes)));\n\t\tconst adjusted_mid_price =\n\t\t\t(parsed_mid_price * baseCoin.scalar) / quoteCoin.scalar / FLOAT_SCALAR;\n\n\t\treturn adjusted_mid_price;\n\t}\n}\n"],
5
- "mappings": ";;;;;;;AAAA;AAEA,SAAS,WAAW;AAEpB,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AAEpC,SAAS,8BAA8B;AACvC,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AAEnC,SAAS,aAAa,gBAAgB,oBAAoB;AAMnD,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmB3B,YAAY;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,GAQG;AAjCH;AACA;AAiCC,SAAK,SAAS;AACd,uBAAK,UAAW,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mBAAK,SAAQ,QAAQ,KAAK,SAAS;AAErD,UAAM,MAAM,MAAM,KAAK,OAAO,2BAA2B;AAAA,MACxD,QAAQ,oBAAoB,mBAAK,SAAQ;AAAA,MACzC,kBAAkB;AAAA,IACnB,CAAC;AAED,UAAM,QAAQ,IAAI,QAAS,CAAC,EAAE,aAAc,CAAC,EAAE,CAAC;AAChD,UAAM,mBAAmB,OAAO,IAAI,IAAI,MAAM,IAAI,WAAW,KAAK,CAAC,CAAC;AACpE,UAAM,qBACJ,mBAAmB,SAAS,SAAU,UAAU,SAAS;AAE3D,WAAO;AAAA,EACR;AACD;AAvZC;AACA;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { bcs } from '@mysten/sui/bcs';\nimport type { SuiClient } from '@mysten/sui/client';\nimport { Transaction } from '@mysten/sui/transactions';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport { BalanceManagerContract } from './transactions/balanceManager.js';\nimport { DeepBookContract } from './transactions/deepbook.js';\nimport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nimport { FlashLoanContract } from './transactions/flashLoans.js';\nimport { GovernanceContract } from './transactions/governance.js';\nimport type { BalanceManager, Environment } from './types/index.js';\nimport { DEEP_SCALAR, DeepBookConfig, FLOAT_SCALAR } from './utils/config.js';\nimport type { CoinMap, PoolMap } from './utils/constants.js';\n\n/**\n * DeepBookClient class for managing DeepBook operations.\n */\nexport class DeepBookClient {\n\tclient: SuiClient;\n\t#config: DeepBookConfig;\n\t#address: string;\n\tbalanceManager: BalanceManagerContract;\n\tdeepBook: DeepBookContract;\n\tdeepBookAdmin: DeepBookAdminContract;\n\tflashLoans: FlashLoanContract;\n\tgovernance: GovernanceContract;\n\n\t/**\n\t * @param {SuiClient} client SuiClient instance\n\t * @param {string} address Address of the client\n\t * @param {Environment} env Environment configuration\n\t * @param {Object.<string, BalanceManager>} [balanceManagers] Optional initial BalanceManager map\n\t * @param {CoinMap} [coins] Optional initial CoinMap\n\t * @param {PoolMap} [pools] Optional initial PoolMap\n\t * @param {string} [adminCap] Optional admin capability\n\t */\n\tconstructor({\n\t\tclient,\n\t\taddress,\n\t\tenv,\n\t\tbalanceManagers,\n\t\tcoins,\n\t\tpools,\n\t\tadminCap,\n\t}: {\n\t\tclient: SuiClient;\n\t\taddress: string;\n\t\tenv: Environment;\n\t\tbalanceManagers?: { [key: string]: BalanceManager };\n\t\tcoins?: CoinMap;\n\t\tpools?: PoolMap;\n\t\tadminCap?: string;\n\t}) {\n\t\tthis.client = client;\n\t\tthis.#address = normalizeSuiAddress(address);\n\t\tthis.#config = new DeepBookConfig({\n\t\t\taddress: this.#address,\n\t\t\tenv,\n\t\t\tbalanceManagers,\n\t\t\tcoins,\n\t\t\tpools,\n\t\t\tadminCap,\n\t\t});\n\t\tthis.balanceManager = new BalanceManagerContract(this.#config);\n\t\tthis.deepBook = new DeepBookContract(this.#config);\n\t\tthis.deepBookAdmin = new DeepBookAdminContract(this.#config);\n\t\tthis.flashLoans = new FlashLoanContract(this.#config);\n\t\tthis.governance = new GovernanceContract(this.#config);\n\t}\n\n\t/**\n\t * @description Check the balance of a balance manager for a specific coin\n\t * @param {string} managerKey Key of the balance manager\n\t * @param {string} coinKey Key of the coin\n\t * @returns {Promise<{ coinType: string, balance: number }>} An object with coin type and balance\n\t */\n\tasync checkManagerBalance(managerKey: string, coinKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst coin = this.#config.getCoin(coinKey);\n\n\t\ttx.add(this.balanceManager.checkManagerBalance(managerKey, coinKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: this.#address,\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst parsed_balance = bcs.U64.parse(new Uint8Array(bytes));\n\t\tconst balanceNumber = Number(parsed_balance);\n\t\tconst adjusted_balance = balanceNumber / coin.scalar;\n\n\t\treturn {\n\t\t\tcoinType: coin.type,\n\t\t\tbalance: Number(adjusted_balance.toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Check if a pool is whitelisted\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<boolean>} Boolean indicating if the pool is whitelisted\n\t */\n\tasync whitelisted(poolKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.whitelisted(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst whitelisted = bcs.Bool.parse(new Uint8Array(bytes));\n\n\t\treturn whitelisted;\n\t}\n\n\t/**\n\t * @description Get the quote quantity out for a given base quantity\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @returns {Promise<{ baseQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with base quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getQuoteQuantityOut(poolKey: string, baseQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getQuoteQuantityOut(poolKey, baseQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbaseQuantity,\n\t\t\tbaseOut: Number((baseOut / baseScalar).toFixed(9)),\n\t\t\tquoteOut: Number((quoteOut / quoteScalar).toFixed(9)),\n\t\t\tdeepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the base quantity out for a given quote quantity\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns {Promise<{ quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with quote quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getBaseQuantityOut(poolKey: string, quoteQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getBaseQuantityOut(poolKey, quoteQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tquoteQuantity: quoteQuantity,\n\t\t\tbaseOut: Number((baseOut / baseScalar).toFixed(9)),\n\t\t\tquoteOut: Number((quoteOut / quoteScalar).toFixed(9)),\n\t\t\tdeepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the output quantities for given base and quote quantities. Only one quantity can be non-zero\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns {Promise<{ baseQuantity: number, quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}\n\t * An object with base quantity, quote quantity, base out, quote out, and deep required for the dry run\n\t */\n\tasync getQuantityOut(poolKey: string, baseQuantity: number, quoteQuantity: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.getQuantityOut(poolKey, baseQuantity, quoteQuantity));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteOut = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepRequired = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbaseQuantity,\n\t\t\tquoteQuantity,\n\t\t\tbaseOut: Number((baseOut / baseScalar).toFixed(9)),\n\t\t\tquoteOut: Number((quoteOut / quoteScalar).toFixed(9)),\n\t\t\tdeepRequired: Number((deepRequired / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get open orders for a balance manager in a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} managerKey Key of the balance manager\n\t * @returns {Promise<Array>} An array of open order IDs\n\t */\n\tasync accountOpenOrders(poolKey: string, managerKey: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.accountOpenOrders(poolKey, managerKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst order_ids = res.results![0].returnValues![0][0];\n\t\tconst VecSet = bcs.struct('VecSet', {\n\t\t\tconstants: bcs.vector(bcs.U128),\n\t\t});\n\n\t\treturn VecSet.parse(new Uint8Array(order_ids)).constants;\n\t}\n\n\t/**\n\t * @description Get the order information for a specific order in a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {string} orderId Order ID\n\t * @returns {Promise<Object>} A promise that resolves to an object containing the order information\n\t */\n\tasync getOrder(poolKey: string, orderId: string) {\n\t\tconst tx = new Transaction();\n\n\t\ttx.add(this.deepBook.getOrder(poolKey, orderId));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst ID = bcs.struct('ID', {\n\t\t\tbytes: bcs.Address,\n\t\t});\n\t\tconst OrderDeepPrice = bcs.struct('OrderDeepPrice', {\n\t\t\tasset_is_base: bcs.bool(),\n\t\t\tdeep_per_asset: bcs.u64(),\n\t\t});\n\t\tconst Order = bcs.struct('Order', {\n\t\t\tbalance_manager_id: ID,\n\t\t\torder_id: bcs.u128(),\n\t\t\tclient_order_id: bcs.u64(),\n\t\t\tquantity: bcs.u64(),\n\t\t\tfilled_quantity: bcs.u64(),\n\t\t\tfee_is_deep: bcs.bool(),\n\t\t\torder_deep_price: OrderDeepPrice,\n\t\t\tepoch: bcs.u64(),\n\t\t\tstatus: bcs.u8(),\n\t\t\texpire_timestamp: bcs.u64(),\n\t\t});\n\n\t\tconst orderInformation = res.results![0].returnValues![0][0];\n\t\treturn Order.parse(new Uint8Array(orderInformation));\n\t}\n\n\t/**\n\t * @description Get level 2 order book specifying range of price\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} priceLow Lower bound of the price range\n\t * @param {number} priceHigh Upper bound of the price range\n\t * @param {boolean} isBid Whether to get bid or ask orders\n\t * @returns {Promise<{ prices: Array<number>, quantities: Array<number> }>}\n\t * An object with arrays of prices and quantities\n\t */\n\tasync getLevel2Range(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(this.deepBook.getLevel2Range(poolKey, priceLow, priceHigh, isBid));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst prices = res.results![0].returnValues![0][0];\n\t\tconst parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(prices));\n\t\tconst quantities = res.results![0].returnValues![1][0];\n\t\tconst parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(quantities));\n\n\t\treturn {\n\t\t\tprices: parsed_prices.map((price) =>\n\t\t\t\tNumber(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\tquantities: parsed_quantities.map((price) =>\n\t\t\t\tNumber((Number(price) / baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get level 2 order book ticks from mid-price for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @param {number} ticks Number of ticks from mid-price\n\t * @returns {Promise<{ bid_prices: Array<number>, bid_quantities: Array<number>, ask_prices: Array<number>, ask_quantities: Array<number> }>}\n\t * An object with arrays of prices and quantities\n\t */\n\tasync getLevel2TicksFromMid(poolKey: string, ticks: number) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.add(this.deepBook.getLevel2TicksFromMid(poolKey, ticks));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bid_prices = res.results![0].returnValues![0][0];\n\t\tconst bid_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_prices));\n\t\tconst bid_quantities = res.results![0].returnValues![1][0];\n\t\tconst bid_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(bid_quantities));\n\n\t\tconst ask_prices = res.results![0].returnValues![2][0];\n\t\tconst ask_parsed_prices = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_prices));\n\t\tconst ask_quantities = res.results![0].returnValues![3][0];\n\t\tconst ask_parsed_quantities = bcs.vector(bcs.u64()).parse(new Uint8Array(ask_quantities));\n\n\t\treturn {\n\t\t\tbid_prices: bid_parsed_prices.map((price) =>\n\t\t\t\tNumber(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\tbid_quantities: bid_parsed_quantities.map((quantity) =>\n\t\t\t\tNumber((Number(quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\task_prices: ask_parsed_prices.map((price) =>\n\t\t\t\tNumber(((Number(price) / FLOAT_SCALAR / quoteCoin.scalar) * baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t\task_quantities: ask_parsed_quantities.map((quantity) =>\n\t\t\t\tNumber((Number(quantity) / baseCoin.scalar).toFixed(9)),\n\t\t\t),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the vault balances for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<{ base: number, quote: number, deep: number }>}\n\t * An object with base, quote, and deep balances in the vault\n\t */\n\tasync vaultBalances(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseScalar = this.#config.getCoin(pool.baseCoin).scalar;\n\t\tconst quoteScalar = this.#config.getCoin(pool.quoteCoin).scalar;\n\n\t\ttx.add(this.deepBook.vaultBalances(poolKey));\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst baseInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![0][0])));\n\t\tconst quoteInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![1][0])));\n\t\tconst deepInVault = Number(bcs.U64.parse(new Uint8Array(res.results![0].returnValues![2][0])));\n\n\t\treturn {\n\t\t\tbase: Number((baseInVault / baseScalar).toFixed(9)),\n\t\t\tquote: Number((quoteInVault / quoteScalar).toFixed(9)),\n\t\t\tdeep: Number((deepInVault / DEEP_SCALAR).toFixed(9)),\n\t\t};\n\t}\n\n\t/**\n\t * @description Get the pool ID by asset types\n\t * @param {string} baseType Type of the base asset\n\t * @param {string} quoteType Type of the quote asset\n\t * @returns {Promise<string>} The address of the pool\n\t */\n\tasync getPoolIdByAssets(baseType: string, quoteType: string) {\n\t\tconst tx = new Transaction();\n\t\ttx.add(this.deepBook.getPoolIdByAssets(baseType, quoteType));\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst ID = bcs.struct('ID', {\n\t\t\tbytes: bcs.Address,\n\t\t});\n\t\tconst address = ID.parse(new Uint8Array(res.results![0].returnValues![0][0]))['bytes'];\n\n\t\treturn address;\n\t}\n\n\t/**\n\t * @description Get the mid price for a pool\n\t * @param {string} poolKey Key of the pool\n\t * @returns {Promise<number>} The mid price\n\t */\n\tasync midPrice(poolKey: string) {\n\t\tconst tx = new Transaction();\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\ttx.add(this.deepBook.midPrice(poolKey));\n\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst res = await this.client.devInspectTransactionBlock({\n\t\t\tsender: normalizeSuiAddress(this.#address),\n\t\t\ttransactionBlock: tx,\n\t\t});\n\n\t\tconst bytes = res.results![0].returnValues![0][0];\n\t\tconst parsed_mid_price = Number(bcs.U64.parse(new Uint8Array(bytes)));\n\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AACnD,UAAM,YAAY,mBAAK,SAAQ,QAAQ,KAAK,SAAS;AAErD,UAAM,MAAM,MAAM,KAAK,OAAO,2BAA2B;AAAA,MACxD,QAAQ,oBAAoB,mBAAK,SAAQ;AAAA,MACzC,kBAAkB;AAAA,IACnB,CAAC;AAED,UAAM,QAAQ,IAAI,QAAS,CAAC,EAAE,aAAc,CAAC,EAAE,CAAC;AAChD,UAAM,mBAAmB,OAAO,IAAI,IAAI,MAAM,IAAI,WAAW,KAAK,CAAC,CAAC;AACpE,UAAM,qBACJ,mBAAmB,SAAS,SAAU,UAAU,SAAS;AAE3D,WAAO,OAAO,mBAAmB,QAAQ,CAAC,CAAC;AAAA,EAC5C;AACD;AA7ZC;AACA;",
6
6
  "names": []
7
7
  }
@@ -5,3 +5,5 @@ export { DeepBookAdminContract } from './transactions/deepbookAdmin.js';
5
5
  export { FlashLoanContract } from './transactions/flashLoans.js';
6
6
  export { GovernanceContract } from './transactions/governance.js';
7
7
  export { DeepBookConfig } from './utils/config.js';
8
+ export type { BalanceManager, Coin, Pool } from './types/index.js';
9
+ export type { CoinMap, PoolMap } from './utils/constants.js';
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { DeepBookClient } from './client.js';\nexport { BalanceManagerContract } from './transactions/balanceManager.js';\nexport { DeepBookContract } from './transactions/deepbook.js';\nexport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nexport { FlashLoanContract } from './transactions/flashLoans.js';\nexport { GovernanceContract } from './transactions/governance.js';\nexport { DeepBookConfig } from './utils/config.js';\n"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nexport { DeepBookClient } from './client.js';\nexport { BalanceManagerContract } from './transactions/balanceManager.js';\nexport { DeepBookContract } from './transactions/deepbook.js';\nexport { DeepBookAdminContract } from './transactions/deepbookAdmin.js';\nexport { FlashLoanContract } from './transactions/flashLoans.js';\nexport { GovernanceContract } from './transactions/governance.js';\nexport { DeepBookConfig } from './utils/config.js';\nexport type { BalanceManager, Coin, Pool } from './types/index.js';\nexport type { CoinMap, PoolMap } from './utils/constants.js';\n"],
5
5
  "mappings": "AAGA,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AACvC,SAAS,wBAAwB;AACjC,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;",
6
6
  "names": []
7
7
  }
@@ -38,9 +38,10 @@ class BalanceManagerContract {
38
38
  tx.setSenderIfNotSet(__privateGet(this, _config).address);
39
39
  const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
40
40
  const coin = __privateGet(this, _config).getCoin(coinKey);
41
+ const depositInput = Math.round(amountToDeposit * coin.scalar);
41
42
  const deposit = coinWithBalance({
42
43
  type: coin.type,
43
- balance: amountToDeposit * coin.scalar
44
+ balance: depositInput
44
45
  });
45
46
  tx.moveCall({
46
47
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::deposit`,
@@ -59,9 +60,10 @@ class BalanceManagerContract {
59
60
  this.withdrawFromManager = (managerKey, coinKey, amountToWithdraw, recipient) => (tx) => {
60
61
  const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
61
62
  const coin = __privateGet(this, _config).getCoin(coinKey);
63
+ const withdrawInput = Math.round(amountToWithdraw * coin.scalar);
62
64
  const coinObject = tx.moveCall({
63
65
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,
64
- arguments: [tx.object(managerId), tx.pure.u64(amountToWithdraw * coin.scalar)],
66
+ arguments: [tx.object(managerId), tx.pure.u64(withdrawInput)],
65
67
  typeArguments: [coin.type]
66
68
  });
67
69
  tx.transferObjects([coinObject], recipient);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/transactions/balanceManager.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@mysten/sui/transactions';\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\n\n/**\n * BalanceManagerContract class for managing BalanceManager operations.\n */\nexport class BalanceManagerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for BalanceManagerContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Create and share a new BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateAndShareBalanceManager = () => (tx: Transaction) => {\n\t\tconst manager = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::new`,\n\t\t});\n\n\t\ttx.moveCall({\n\t\t\ttarget: '0x2::transfer::public_share_object',\n\t\t\targuments: [manager],\n\t\t\ttypeArguments: [`${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::BalanceManager`],\n\t\t});\n\t};\n\n\t/**\n\t * @description Deposit funds into the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to deposit\n\t * @param {number} amountToDeposit The amount to deposit\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositIntoManager =\n\t\t(managerKey: string, coinKey: string, amountToDeposit: number) => (tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst deposit = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: amountToDeposit * coin.scalar,\n\t\t\t});\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::deposit`,\n\t\t\t\targuments: [tx.object(managerId), deposit],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw funds from the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to withdraw\n\t * @param {number} amountToWithdraw The amount to withdraw\n\t * @param {string} recipient The recipient of the withdrawn funds\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawFromManager =\n\t\t(managerKey: string, coinKey: string, amountToWithdraw: number, recipient: string) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst coinObject = tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,\n\t\t\t\targuments: [tx.object(managerId), tx.pure.u64(amountToWithdraw * coin.scalar)],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\n\t\t\ttx.transferObjects([coinObject], recipient);\n\t\t};\n\n\t/**\n\t * @description Withdraw all funds from the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to withdraw\n\t * @param {string} recipient The recipient of the withdrawn funds\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawAllFromManager =\n\t\t(managerKey: string, coinKey: string, recipient: string) => (tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawalCoin = tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_all`,\n\t\t\t\targuments: [tx.object(managerId)],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\n\t\t\ttx.transferObjects([withdrawalCoin], recipient);\n\t\t};\n\n\t/**\n\t * @description Check the balance of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to check the balance of\n\t * @returns A function that takes a Transaction object\n\t */\n\tcheckManagerBalance = (managerKey: string, coinKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::balance`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Generate a trade proof for the BalanceManager. Calls the appropriate function based on whether tradeCap is set.\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProof = (managerKey: string) => (tx: Transaction) => {\n\t\tconst balanceManager = this.#config.getBalanceManager(managerKey);\n\t\treturn tx.add(\n\t\t\tbalanceManager.tradeCap\n\t\t\t\t? this.generateProofAsTrader(balanceManager.address, balanceManager.tradeCap)\n\t\t\t\t: this.generateProofAsOwner(balanceManager.address),\n\t\t);\n\t};\n\n\t/**\n\t * @description Generate a trade proof as the owner\n\t * @param {string} managerId The ID of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProofAsOwner = (managerId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_owner`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Generate a trade proof as a trader\n\t * @param {string} managerId The ID of the BalanceManager\n\t * @param {string} tradeCapId The ID of the tradeCap\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProofAsTrader = (managerId: string, tradeCapId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_trader`,\n\t\t\targuments: [tx.object(managerId), tx.object(tradeCapId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the owner of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\towner = (managerKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::owner`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the ID of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tid = (managerKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::id`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n}\n"],
5
- "mappings": ";;;;;;;AAAA;AAEA,SAAS,uBAAuB;AAQzB,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAMnC,YAAY,QAAwB;AALpC;AAaA;AAAA;AAAA;AAAA;AAAA,wCAA+B,MAAM,CAAC,OAAoB;AACzD,YAAM,UAAU,GAAG,SAAS;AAAA,QAC3B,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,MAC5C,CAAC;AAED,SAAG,SAAS;AAAA,QACX,QAAQ;AAAA,QACR,WAAW,CAAC,OAAO;AAAA,QACnB,eAAe,CAAC,GAAG,mBAAK,SAAQ,mBAAmB,mCAAmC;AAAA,MACvF,CAAC;AAAA,IACF;AASA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,8BACC,CAAC,YAAoB,SAAiB,oBAA4B,CAAC,OAAoB;AACtF,SAAG,kBAAkB,mBAAK,SAAQ,OAAO;AACzC,YAAM,YAAY,mBAAK,SAAQ,kBAAkB,UAAU,EAAE;AAC7D,YAAM,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACzC,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ACX,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,SAAS,CAAC;AAAA,MACjC,CAAC;AAAA,IACF;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA,cAAK,CAAC,eAAuB,CAAC,OAAoB;AACjD,YAAM,YAAY,mBAAK,SAAQ,kBAAkB,UAAU,EAAE;AAC7D,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,SAAS,CAAC;AAAA,MACjC,CAAC;AAAA,IACF;AApKC,uBAAK,SAAU;AAAA,EAChB;AAoKD;AA3KC;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@mysten/sui/transactions';\nimport type { Transaction } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\n\n/**\n * BalanceManagerContract class for managing BalanceManager operations.\n */\nexport class BalanceManagerContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for BalanceManagerContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Create and share a new BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcreateAndShareBalanceManager = () => (tx: Transaction) => {\n\t\tconst manager = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::new`,\n\t\t});\n\n\t\ttx.moveCall({\n\t\t\ttarget: '0x2::transfer::public_share_object',\n\t\t\targuments: [manager],\n\t\t\ttypeArguments: [`${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::BalanceManager`],\n\t\t});\n\t};\n\n\t/**\n\t * @description Deposit funds into the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to deposit\n\t * @param {number} amountToDeposit The amount to deposit\n\t * @returns A function that takes a Transaction object\n\t */\n\tdepositIntoManager =\n\t\t(managerKey: string, coinKey: string, amountToDeposit: number) => (tx: Transaction) => {\n\t\t\ttx.setSenderIfNotSet(this.#config.address);\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst depositInput = Math.round(amountToDeposit * coin.scalar);\n\t\t\tconst deposit = coinWithBalance({\n\t\t\t\ttype: coin.type,\n\t\t\t\tbalance: depositInput,\n\t\t\t});\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::deposit`,\n\t\t\t\targuments: [tx.object(managerId), deposit],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Withdraw funds from the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to withdraw\n\t * @param {number} amountToWithdraw The amount to withdraw\n\t * @param {string} recipient The recipient of the withdrawn funds\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawFromManager =\n\t\t(managerKey: string, coinKey: string, amountToWithdraw: number, recipient: string) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawInput = Math.round(amountToWithdraw * coin.scalar);\n\t\t\tconst coinObject = tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,\n\t\t\t\targuments: [tx.object(managerId), tx.pure.u64(withdrawInput)],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\n\t\t\ttx.transferObjects([coinObject], recipient);\n\t\t};\n\n\t/**\n\t * @description Withdraw all funds from the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to withdraw\n\t * @param {string} recipient The recipient of the withdrawn funds\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawAllFromManager =\n\t\t(managerKey: string, coinKey: string, recipient: string) => (tx: Transaction) => {\n\t\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\t\tconst coin = this.#config.getCoin(coinKey);\n\t\t\tconst withdrawalCoin = tx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_all`,\n\t\t\t\targuments: [tx.object(managerId)],\n\t\t\t\ttypeArguments: [coin.type],\n\t\t\t});\n\n\t\t\ttx.transferObjects([withdrawalCoin], recipient);\n\t\t};\n\n\t/**\n\t * @description Check the balance of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @param {string} coinKey The key of the coin to check the balance of\n\t * @returns A function that takes a Transaction object\n\t */\n\tcheckManagerBalance = (managerKey: string, coinKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\tconst coin = this.#config.getCoin(coinKey);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::balance`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t\ttypeArguments: [coin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Generate a trade proof for the BalanceManager. Calls the appropriate function based on whether tradeCap is set.\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProof = (managerKey: string) => (tx: Transaction) => {\n\t\tconst balanceManager = this.#config.getBalanceManager(managerKey);\n\t\treturn tx.add(\n\t\t\tbalanceManager.tradeCap\n\t\t\t\t? this.generateProofAsTrader(balanceManager.address, balanceManager.tradeCap)\n\t\t\t\t: this.generateProofAsOwner(balanceManager.address),\n\t\t);\n\t};\n\n\t/**\n\t * @description Generate a trade proof as the owner\n\t * @param {string} managerId The ID of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProofAsOwner = (managerId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_owner`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Generate a trade proof as a trader\n\t * @param {string} managerId The ID of the BalanceManager\n\t * @param {string} tradeCapId The ID of the tradeCap\n\t * @returns A function that takes a Transaction object\n\t */\n\tgenerateProofAsTrader = (managerId: string, tradeCapId: string) => (tx: Transaction) => {\n\t\treturn tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_trader`,\n\t\t\targuments: [tx.object(managerId), tx.object(tradeCapId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the owner of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\towner = (managerKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::owner`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the ID of the BalanceManager\n\t * @param {string} managerKey The key of the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tid = (managerKey: string) => (tx: Transaction) => {\n\t\tconst managerId = this.#config.getBalanceManager(managerKey).address;\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::id`,\n\t\t\targuments: [tx.object(managerId)],\n\t\t});\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;AAAA;AAEA,SAAS,uBAAuB;AAQzB,MAAM,uBAAuB;AAAA;AAAA;AAAA;AAAA,EAMnC,YAAY,QAAwB;AALpC;AAaA;AAAA;AAAA;AAAA;AAAA,wCAA+B,MAAM,CAAC,OAAoB;AACzD,YAAM,UAAU,GAAG,SAAS;AAA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;AAAA,QAClB,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,SAAS,CAAC;AAAA,MACjC,CAAC;AAAA,IACF;AAQA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAwB,CAAC,WAAmB,eAAuB,CAAC,OAAoB;AACvF,aAAO,GAAG,SAAS;AAAA,QAClB,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,SAAS,GAAG,GAAG,OAAO,UAAU,CAAC;AAAA,MACxD,CAAC;AAAA,IACF;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAQ,CAAC,eAAuB,CAAC,OAAoB;AACpD,YAAM,YAAY,mBAAK,SAAQ,kBAAkB,UAAU,EAAE;AAC7D,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,SAAS,CAAC;AAAA,MACjC,CAAC;AAAA,IACF;AAOA;AAAA;AAAA;AAAA;AAAA;AAAA,cAAK,CAAC,eAAuB,CAAC,OAAoB;AACjD,YAAM,YAAY,mBAAK,SAAQ,kBAAkB,UAAU,EAAE;AAC7D,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,SAAS,CAAC;AAAA,MACjC,CAAC;AAAA,IACF;AAtKC,uBAAK,SAAU;AAAA,EAChB;AAsKD;AA7KC;",
6
6
  "names": []
7
7
  }
@@ -39,8 +39,8 @@ class DeepBookContract {
39
39
  const balanceManager = __privateGet(this, _config).getBalanceManager(balanceManagerKey);
40
40
  const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
41
41
  const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
42
- const inputPrice = price * FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar;
43
- const inputQuantity = quantity * baseCoin.scalar;
42
+ const inputPrice = Math.round(price * FLOAT_SCALAR * quoteCoin.scalar / baseCoin.scalar);
43
+ const inputQuantity = Math.round(quantity * baseCoin.scalar);
44
44
  const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
45
45
  tx.moveCall({
46
46
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::place_limit_order`,
@@ -82,6 +82,7 @@ class DeepBookContract {
82
82
  const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
83
83
  const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
84
84
  const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
85
+ const inputQuantity = Math.round(quantity * baseCoin.scalar);
85
86
  tx.moveCall({
86
87
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::place_market_order`,
87
88
  arguments: [
@@ -90,7 +91,7 @@ class DeepBookContract {
90
91
  tradeProof,
91
92
  tx.pure.u64(clientOrderId),
92
93
  tx.pure.u8(selfMatchingOption),
93
- tx.pure.u64(quantity * baseCoin.scalar),
94
+ tx.pure.u64(inputQuantity),
94
95
  tx.pure.bool(isBid),
95
96
  tx.pure.bool(payWithDeep),
96
97
  tx.object(SUI_CLOCK_OBJECT_ID)
@@ -112,6 +113,7 @@ class DeepBookContract {
112
113
  const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
113
114
  const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
114
115
  const tradeProof = tx.add(__privateGet(this, _config).balanceManager.generateProof(balanceManagerKey));
116
+ const inputQuantity = Math.round(newQuantity * baseCoin.scalar);
115
117
  tx.moveCall({
116
118
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::modify_order`,
117
119
  arguments: [
@@ -119,7 +121,7 @@ class DeepBookContract {
119
121
  tx.object(balanceManager.address),
120
122
  tradeProof,
121
123
  tx.pure.u128(orderId),
122
- tx.pure.u64(newQuantity),
124
+ tx.pure.u64(inputQuantity),
123
125
  tx.object(SUI_CLOCK_OBJECT_ID)
124
126
  ],
125
127
  typeArguments: [baseCoin.type, quoteCoin.type]
@@ -469,15 +471,16 @@ class DeepBookContract {
469
471
  let deepCoinType = __privateGet(this, _config).getCoin("DEEP").type;
470
472
  const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
471
473
  const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
472
- const baseCoinInput = params.baseCoin ?? coinWithBalance({ type: baseCoin.type, balance: baseAmount * baseCoin.scalar });
473
- const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });
474
+ const baseCoinInput = params.baseCoin ?? coinWithBalance({ type: baseCoin.type, balance: Math.round(baseAmount * baseCoin.scalar) });
475
+ const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: Math.round(deepAmount * DEEP_SCALAR) });
476
+ const minQuoteInput = Math.round(minQuote * quoteCoin.scalar);
474
477
  const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({
475
478
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,
476
479
  arguments: [
477
480
  tx.object(pool.address),
478
481
  baseCoinInput,
479
482
  deepCoin,
480
- tx.pure.u64(quoteCoin.scalar * minQuote),
483
+ tx.pure.u64(minQuoteInput),
481
484
  tx.object(SUI_CLOCK_OBJECT_ID)
482
485
  ],
483
486
  typeArguments: [baseCoin.type, quoteCoin.type]
@@ -500,15 +503,19 @@ class DeepBookContract {
500
503
  let deepCoinType = __privateGet(this, _config).getCoin("DEEP").type;
501
504
  const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
502
505
  const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
503
- const quoteCoinInput = params.quoteCoin ?? coinWithBalance({ type: quoteCoin.type, balance: quoteAmount * quoteCoin.scalar });
504
- const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });
506
+ const quoteCoinInput = params.quoteCoin ?? coinWithBalance({
507
+ type: quoteCoin.type,
508
+ balance: Math.round(quoteAmount * quoteCoin.scalar)
509
+ });
510
+ const deepCoin = params.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: Math.round(deepAmount * DEEP_SCALAR) });
511
+ const minBaseInput = Math.round(minBase * baseCoin.scalar);
505
512
  const [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({
506
513
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,
507
514
  arguments: [
508
515
  tx.object(pool.address),
509
516
  quoteCoinInput,
510
517
  deepCoin,
511
- tx.pure.u64(baseCoin.scalar * minBase),
518
+ tx.pure.u64(minBaseInput),
512
519
  tx.object(SUI_CLOCK_OBJECT_ID)
513
520
  ],
514
521
  typeArguments: [baseCoin.type, quoteCoin.type]
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/transactions/deepbook.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@mysten/sui/transactions';\nimport type { Transaction } from '@mysten/sui/transactions';\nimport { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';\n\nimport { OrderType, SelfMatchingOptions } from '../types/index.js';\nimport type { PlaceLimitOrderParams, PlaceMarketOrderParams, SwapParams } from '../types/index.js';\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { DEEP_SCALAR, FLOAT_SCALAR, GAS_BUDGET, MAX_TIMESTAMP } from '../utils/config.js';\n\n/**\n * DeepBookContract class for managing DeepBook operations.\n */\nexport class DeepBookContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for DeepBookContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Place a limit order\n\t * @param {PlaceLimitOrderParams} params Parameters for placing a limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceLimitOrder = (params: PlaceLimitOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tbalanceManagerKey,\n\t\t\tclientOrderId,\n\t\t\tprice,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\texpiration = MAX_TIMESTAMP,\n\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst inputPrice = (price * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar;\n\t\tconst inputQuantity = quantity * baseCoin.scalar;\n\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::place_limit_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\ttradeProof,\n\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\ttx.pure.u8(orderType),\n\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\ttx.pure.u64(inputPrice),\n\t\t\t\ttx.pure.u64(inputQuantity),\n\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\ttx.pure.u64(expiration),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Place a market order\n\t * @param {PlaceMarketOrderParams} params Parameters for placing a market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceMarketOrder = (params: PlaceMarketOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tbalanceManagerKey,\n\t\t\tclientOrderId,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::place_market_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\ttradeProof,\n\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\ttx.pure.u64(quantity * baseCoin.scalar),\n\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Modify an existing order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @param {string} orderId Order ID to modify\n\t * @param {number} newQuantity New quantity for the order\n\t * @returns A function that takes a Transaction object\n\t */\n\tmodifyOrder =\n\t\t(poolKey: string, balanceManagerKey: string, orderId: string, newQuantity: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::modify_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\t\ttradeProof,\n\t\t\t\t\ttx.pure.u128(orderId),\n\t\t\t\t\ttx.pure.u64(newQuantity),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Cancel an existing order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @param {string} orderId Order ID to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelOrder =\n\t\t(poolKey: string, balanceManagerKey: string, orderId: string) => (tx: Transaction) => {\n\t\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::cancel_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\t\ttradeProof,\n\t\t\t\t\ttx.pure.u128(orderId),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Cancel all open orders for a balance manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelAllOrders = (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => {\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::cancel_all_orders`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\ttradeProof,\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Withdraw settled amounts for a balance manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawSettledAmounts = (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::withdraw_settled_amounts`,\n\t\t\targuments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Add a deep price point for a target pool using a reference pool\n\t * @param {string} targetPoolKey The key to identify the target pool\n\t * @param {string} referencePoolKey The key to identify the reference pool\n\t * @returns A function that takes a Transaction object\n\t */\n\taddDeepPricePoint = (targetPoolKey: string, referencePoolKey: string) => (tx: Transaction) => {\n\t\tconst targetPool = this.#config.getPool(targetPoolKey);\n\t\tconst referencePool = this.#config.getPool(referencePoolKey);\n\t\tconst targetBaseCoin = this.#config.getCoin(targetPool.baseCoin);\n\t\tconst targetQuoteCoin = this.#config.getCoin(targetPool.quoteCoin);\n\t\tconst referenceBaseCoin = this.#config.getCoin(referencePool.baseCoin);\n\t\tconst referenceQuoteCoin = this.#config.getCoin(referencePool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::add_deep_price_point`,\n\t\t\targuments: [\n\t\t\t\ttx.object(targetPool.address),\n\t\t\t\ttx.object(referencePool.address),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [\n\t\t\t\ttargetBaseCoin.type,\n\t\t\t\ttargetQuoteCoin.type,\n\t\t\t\treferenceBaseCoin.type,\n\t\t\t\treferenceQuoteCoin.type,\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Claim rebates for a balance manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tclaimRebates = (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::claim_rebates`,\n\t\t\targuments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Gets an order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} orderId Order ID to get\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetOrder = (poolKey: string, orderId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_order`,\n\t\t\targuments: [tx.object(pool.address), tx.pure.u128(orderId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Burn DEEP tokens from the pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tburnDeep = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::burn_deep`,\n\t\t\targuments: [tx.object(pool.address), tx.object(this.#config.DEEP_TREASURY_ID)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the mid price for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmidPrice = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::mid_price`,\n\t\t\targuments: [tx.object(pool.address), tx.object(SUI_CLOCK_OBJECT_ID)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Check if a pool is whitelisted\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\twhitelisted = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::whitelisted`,\n\t\t\targuments: [tx.object(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the quote quantity out for a given base quantity in\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetQuoteQuantityOut = (poolKey: string, baseQuantity: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quote_quantity_out`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(baseQuantity * baseCoin.scalar),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the base quantity out for a given quote quantity in\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetBaseQuantityOut = (poolKey: string, quoteQuantity: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_base_quantity_out`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(quoteQuantity * quoteScalar),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the quantity out for a given base or quote quantity\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetQuantityOut =\n\t\t(poolKey: string, baseQuantity: number, quoteQuantity: number) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quantity_out`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.pure.u64(baseQuantity * baseCoin.scalar),\n\t\t\t\t\ttx.pure.u64(quoteQuantity * quoteScalar),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Get open orders for a balance manager in a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} managerKey Key of the balance manager\n\t * @returns A function that takes a Transaction object\n\t */\n\taccountOpenOrders = (poolKey: string, managerKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getBalanceManager(managerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::account_open_orders`,\n\t\t\targuments: [tx.object(pool.address), tx.object(manager.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get level 2 order book specifying range of price\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} priceLow Lower bound of the price range\n\t * @param {number} priceHigh Upper bound of the price range\n\t * @param {boolean} isBid Whether to get bid or ask orders\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetLevel2Range =\n\t\t(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_level2_range`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.pure.u64((priceLow * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar),\n\t\t\t\t\ttx.pure.u64((priceHigh * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar),\n\t\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Get level 2 order book ticks from mid-price for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} tickFromMid Number of ticks from mid-price\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetLevel2TicksFromMid = (poolKey: string, tickFromMid: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_level2_ticks_from_mid`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(tickFromMid),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the vault balances for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tvaultBalances = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::vault_balances`,\n\t\t\targuments: [tx.object(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the pool ID by asset types\n\t * @param {string} baseType Type of the base asset\n\t * @param {string} quoteType Type of the quote asset\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetPoolIdByAssets = (baseType: string, quoteType: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_pool_id_by_asset`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID)],\n\t\t\ttypeArguments: [baseType, quoteType],\n\t\t});\n\t};\n\n\t/**\n\t * @description Swap exact base amount for quote amount\n\t * @param {SwapParams} params Parameters for the swap\n\t * @returns A function that takes a Transaction object\n\t */\n\tswapExactBaseForQuote = (params: SwapParams) => (tx: Transaction) => {\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\n\t\tif (params.quoteCoin) {\n\t\t\tthrow new Error('quoteCoin is not accepted for swapping base asset');\n\t\t}\n\t\tconst { poolKey, amount: baseAmount, deepAmount, minOut: minQuote } = params;\n\n\t\tlet pool = this.#config.getPool(poolKey);\n\t\tlet deepCoinType = this.#config.getCoin('DEEP').type;\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst baseCoinInput =\n\t\t\tparams.baseCoin ??\n\t\t\tcoinWithBalance({ type: baseCoin.type, balance: baseAmount * baseCoin.scalar });\n\n\t\tconst deepCoin =\n\t\t\tparams.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });\n\n\t\tconst [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\tbaseCoinInput,\n\t\t\t\tdeepCoin,\n\t\t\t\ttx.pure.u64(quoteCoin.scalar * minQuote),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\n\t\treturn [baseCoinResult, quoteCoinResult, deepCoinResult] as const;\n\t};\n\n\t/**\n\t * @description Swap exact quote amount for base amount\n\t * @param {SwapParams} params Parameters for the swap\n\t * @returns A function that takes a Transaction object\n\t */\n\tswapExactQuoteForBase = (params: SwapParams) => (tx: Transaction) => {\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\n\t\tif (params.baseCoin) {\n\t\t\tthrow new Error('baseCoin is not accepted for swapping quote asset');\n\t\t}\n\t\tconst { poolKey, amount: quoteAmount, deepAmount, minOut: minBase } = params;\n\n\t\tlet pool = this.#config.getPool(poolKey);\n\t\tlet deepCoinType = this.#config.getCoin('DEEP').type;\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst quoteCoinInput =\n\t\t\tparams.quoteCoin ??\n\t\t\tcoinWithBalance({ type: quoteCoin.type, balance: quoteAmount * quoteCoin.scalar });\n\n\t\tconst deepCoin =\n\t\t\tparams.deepCoin ?? coinWithBalance({ type: deepCoinType, balance: deepAmount * DEEP_SCALAR });\n\n\t\tconst [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\tquoteCoinInput,\n\t\t\t\tdeepCoin,\n\t\t\t\ttx.pure.u64(baseCoin.scalar * minBase),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\n\t\treturn [baseCoinResult, quoteCoinResult, deepCoinResult] as const;\n\t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I,OAAO,UAAU;AACpB,cAAM,IAAI,MAAM,mDAAmD;AAAA,MACpE;AACA,YAAM,EAAE,SAAS,QAAQ,aAAa,YAAY,QAAQ,QAAQ,IAAI;AAEtE,UAAI,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACvC,UAAI,eAAe,mBAAK,SAAQ,QAAQ,MAAM,EAAE;AAChD,YAAM,WAAW,mBAAK,SAAQ,QAAQ,KAAK,QAAQ;AACnD,YAAM,YAAY,mBAAK,SAAQ,QAAQ,KAAK,SAAS;AAErD,YAAM,iBACL,OAAO,aACP,gBAAgB,EAAE,MAAM,UAAU,MAAM,SAAS,cAAc,UAAU,OAAO,CAAC;AAElF,YAAM,WACL,OAAO,YAAY,gBAAgB,EAAE,MAAM,cAAc,SAAS,aAAa,YAAY,CAAC;AAE7F,YAAM,CAAC,gBAAgB,iBAAiB,cAAc,IAAI,GAAG,SAAS;AAAA,QACrE,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW;AAAA,UACV,GAAG,OAAO,KAAK,OAAO;AAAA,UACtB;AAAA,UACA;AAAA,UACA,GAAG,KAAK,IAAI,SAAS,SAAS,OAAO;AAAA,UACrC,GAAG,OAAO,mBAAmB;AAAA,QAC9B;AAAA,QACA,eAAe,CAAC,SAAS,MAAM,UAAU,IAAI;AAAA,MAC9C,CAAC;AAED,aAAO,CAAC,gBAAgB,iBAAiB,cAAc;AAAA,IACxD;AApjBC,uBAAK,SAAU;AAAA,EAChB;AAojBD;AA3jBC;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { coinWithBalance } from '@mysten/sui/transactions';\nimport type { Transaction } from '@mysten/sui/transactions';\nimport { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';\n\nimport { OrderType, SelfMatchingOptions } from '../types/index.js';\nimport type { PlaceLimitOrderParams, PlaceMarketOrderParams, SwapParams } from '../types/index.js';\nimport type { DeepBookConfig } from '../utils/config.js';\nimport { DEEP_SCALAR, FLOAT_SCALAR, GAS_BUDGET, MAX_TIMESTAMP } from '../utils/config.js';\n\n/**\n * DeepBookContract class for managing DeepBook operations.\n */\nexport class DeepBookContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration for DeepBookContract\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Place a limit order\n\t * @param {PlaceLimitOrderParams} params Parameters for placing a limit order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceLimitOrder = (params: PlaceLimitOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tbalanceManagerKey,\n\t\t\tclientOrderId,\n\t\t\tprice,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\texpiration = MAX_TIMESTAMP,\n\t\t\torderType = OrderType.NO_RESTRICTION,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst inputPrice = Math.round((price * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar);\n\t\tconst inputQuantity = Math.round(quantity * baseCoin.scalar);\n\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::place_limit_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\ttradeProof,\n\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\ttx.pure.u8(orderType),\n\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\ttx.pure.u64(inputPrice),\n\t\t\t\ttx.pure.u64(inputQuantity),\n\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\ttx.pure.u64(expiration),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Place a market order\n\t * @param {PlaceMarketOrderParams} params Parameters for placing a market order\n\t * @returns A function that takes a Transaction object\n\t */\n\tplaceMarketOrder = (params: PlaceMarketOrderParams) => (tx: Transaction) => {\n\t\tconst {\n\t\t\tpoolKey,\n\t\t\tbalanceManagerKey,\n\t\t\tclientOrderId,\n\t\t\tquantity,\n\t\t\tisBid,\n\t\t\tselfMatchingOption = SelfMatchingOptions.SELF_MATCHING_ALLOWED,\n\t\t\tpayWithDeep = true,\n\t\t} = params;\n\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\t\tconst inputQuantity = Math.round(quantity * baseCoin.scalar);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::place_market_order`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\ttradeProof,\n\t\t\t\ttx.pure.u64(clientOrderId),\n\t\t\t\ttx.pure.u8(selfMatchingOption),\n\t\t\t\ttx.pure.u64(inputQuantity),\n\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\ttx.pure.bool(payWithDeep),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Modify an existing order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @param {string} orderId Order ID to modify\n\t * @param {number} newQuantity New quantity for the order\n\t * @returns A function that takes a Transaction object\n\t */\n\tmodifyOrder =\n\t\t(poolKey: string, balanceManagerKey: string, orderId: string, newQuantity: number) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\t\t\tconst inputQuantity = Math.round(newQuantity * baseCoin.scalar);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::modify_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\t\ttradeProof,\n\t\t\t\t\ttx.pure.u128(orderId),\n\t\t\t\t\ttx.pure.u64(inputQuantity),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Cancel an existing order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @param {string} orderId Order ID to cancel\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelOrder =\n\t\t(poolKey: string, balanceManagerKey: string, orderId: string) => (tx: Transaction) => {\n\t\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::cancel_order`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\t\ttradeProof,\n\t\t\t\t\ttx.pure.u128(orderId),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Cancel all open orders for a balance manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tcancelAllOrders = (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => {\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::cancel_all_orders`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.object(balanceManager.address),\n\t\t\t\ttradeProof,\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Withdraw settled amounts for a balance manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\twithdrawSettledAmounts = (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::withdraw_settled_amounts`,\n\t\t\targuments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Add a deep price point for a target pool using a reference pool\n\t * @param {string} targetPoolKey The key to identify the target pool\n\t * @param {string} referencePoolKey The key to identify the reference pool\n\t * @returns A function that takes a Transaction object\n\t */\n\taddDeepPricePoint = (targetPoolKey: string, referencePoolKey: string) => (tx: Transaction) => {\n\t\tconst targetPool = this.#config.getPool(targetPoolKey);\n\t\tconst referencePool = this.#config.getPool(referencePoolKey);\n\t\tconst targetBaseCoin = this.#config.getCoin(targetPool.baseCoin);\n\t\tconst targetQuoteCoin = this.#config.getCoin(targetPool.quoteCoin);\n\t\tconst referenceBaseCoin = this.#config.getCoin(referencePool.baseCoin);\n\t\tconst referenceQuoteCoin = this.#config.getCoin(referencePool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::add_deep_price_point`,\n\t\t\targuments: [\n\t\t\t\ttx.object(targetPool.address),\n\t\t\t\ttx.object(referencePool.address),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [\n\t\t\t\ttargetBaseCoin.type,\n\t\t\t\ttargetQuoteCoin.type,\n\t\t\t\treferenceBaseCoin.type,\n\t\t\t\treferenceQuoteCoin.type,\n\t\t\t],\n\t\t});\n\t};\n\n\t/**\n\t * @description Claim rebates for a balance manager\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} balanceManagerKey The key to identify the BalanceManager\n\t * @returns A function that takes a Transaction object\n\t */\n\tclaimRebates = (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst balanceManager = this.#config.getBalanceManager(balanceManagerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst tradeProof = tx.add(this.#config.balanceManager.generateProof(balanceManagerKey));\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::claim_rebates`,\n\t\t\targuments: [tx.object(pool.address), tx.object(balanceManager.address), tradeProof],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Gets an order\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} orderId Order ID to get\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetOrder = (poolKey: string, orderId: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_order`,\n\t\t\targuments: [tx.object(pool.address), tx.pure.u128(orderId)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Burn DEEP tokens from the pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tburnDeep = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::burn_deep`,\n\t\t\targuments: [tx.object(pool.address), tx.object(this.#config.DEEP_TREASURY_ID)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the mid price for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tmidPrice = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::mid_price`,\n\t\t\targuments: [tx.object(pool.address), tx.object(SUI_CLOCK_OBJECT_ID)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Check if a pool is whitelisted\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\twhitelisted = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::whitelisted`,\n\t\t\targuments: [tx.object(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the quote quantity out for a given base quantity in\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetQuoteQuantityOut = (poolKey: string, baseQuantity: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quote_quantity_out`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(baseQuantity * baseCoin.scalar),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the base quantity out for a given quote quantity in\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetBaseQuantityOut = (poolKey: string, quoteQuantity: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_base_quantity_out`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(quoteQuantity * quoteScalar),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the quantity out for a given base or quote quantity\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} baseQuantity Base quantity to convert\n\t * @param {number} quoteQuantity Quote quantity to convert\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetQuantityOut =\n\t\t(poolKey: string, baseQuantity: number, quoteQuantity: number) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst quoteScalar = quoteCoin.scalar;\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_quantity_out`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.pure.u64(baseQuantity * baseCoin.scalar),\n\t\t\t\t\ttx.pure.u64(quoteQuantity * quoteScalar),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Get open orders for a balance manager in a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {string} managerKey Key of the balance manager\n\t * @returns A function that takes a Transaction object\n\t */\n\taccountOpenOrders = (poolKey: string, managerKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst manager = this.#config.getBalanceManager(managerKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::account_open_orders`,\n\t\t\targuments: [tx.object(pool.address), tx.object(manager.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get level 2 order book specifying range of price\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} priceLow Lower bound of the price range\n\t * @param {number} priceHigh Upper bound of the price range\n\t * @param {boolean} isBid Whether to get bid or ask orders\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetLevel2Range =\n\t\t(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) => (tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_level2_range`,\n\t\t\t\targuments: [\n\t\t\t\t\ttx.object(pool.address),\n\t\t\t\t\ttx.pure.u64((priceLow * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar),\n\t\t\t\t\ttx.pure.u64((priceHigh * FLOAT_SCALAR * quoteCoin.scalar) / baseCoin.scalar),\n\t\t\t\t\ttx.pure.bool(isBid),\n\t\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t\t],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\t\t};\n\n\t/**\n\t * @description Get level 2 order book ticks from mid-price for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} tickFromMid Number of ticks from mid-price\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetLevel2TicksFromMid = (poolKey: string, tickFromMid: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_level2_ticks_from_mid`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\ttx.pure.u64(tickFromMid),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the vault balances for a pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @returns A function that takes a Transaction object\n\t */\n\tvaultBalances = (poolKey: string) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::vault_balances`,\n\t\t\targuments: [tx.object(pool.address)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t};\n\n\t/**\n\t * @description Get the pool ID by asset types\n\t * @param {string} baseType Type of the base asset\n\t * @param {string} quoteType Type of the quote asset\n\t * @returns A function that takes a Transaction object\n\t */\n\tgetPoolIdByAssets = (baseType: string, quoteType: string) => (tx: Transaction) => {\n\t\ttx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::get_pool_id_by_asset`,\n\t\t\targuments: [tx.object(this.#config.REGISTRY_ID)],\n\t\t\ttypeArguments: [baseType, quoteType],\n\t\t});\n\t};\n\n\t/**\n\t * @description Swap exact base amount for quote amount\n\t * @param {SwapParams} params Parameters for the swap\n\t * @returns A function that takes a Transaction object\n\t */\n\tswapExactBaseForQuote = (params: SwapParams) => (tx: Transaction) => {\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\n\t\tif (params.quoteCoin) {\n\t\t\tthrow new Error('quoteCoin is not accepted for swapping base asset');\n\t\t}\n\t\tconst { poolKey, amount: baseAmount, deepAmount, minOut: minQuote } = params;\n\n\t\tlet pool = this.#config.getPool(poolKey);\n\t\tlet deepCoinType = this.#config.getCoin('DEEP').type;\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst baseCoinInput =\n\t\t\tparams.baseCoin ??\n\t\t\tcoinWithBalance({ type: baseCoin.type, balance: Math.round(baseAmount * baseCoin.scalar) });\n\n\t\tconst deepCoin =\n\t\t\tparams.deepCoin ??\n\t\t\tcoinWithBalance({ type: deepCoinType, balance: Math.round(deepAmount * DEEP_SCALAR) });\n\n\t\tconst minQuoteInput = Math.round(minQuote * quoteCoin.scalar);\n\n\t\tconst [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_base_for_quote`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\tbaseCoinInput,\n\t\t\t\tdeepCoin,\n\t\t\t\ttx.pure.u64(minQuoteInput),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\n\t\treturn [baseCoinResult, quoteCoinResult, deepCoinResult] as const;\n\t};\n\n\t/**\n\t * @description Swap exact quote amount for base amount\n\t * @param {SwapParams} params Parameters for the swap\n\t * @returns A function that takes a Transaction object\n\t */\n\tswapExactQuoteForBase = (params: SwapParams) => (tx: Transaction) => {\n\t\ttx.setGasBudgetIfNotSet(GAS_BUDGET);\n\t\ttx.setSenderIfNotSet(this.#config.address);\n\n\t\tif (params.baseCoin) {\n\t\t\tthrow new Error('baseCoin is not accepted for swapping quote asset');\n\t\t}\n\t\tconst { poolKey, amount: quoteAmount, deepAmount, minOut: minBase } = params;\n\n\t\tlet pool = this.#config.getPool(poolKey);\n\t\tlet deepCoinType = this.#config.getCoin('DEEP').type;\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\n\t\tconst quoteCoinInput =\n\t\t\tparams.quoteCoin ??\n\t\t\tcoinWithBalance({\n\t\t\t\ttype: quoteCoin.type,\n\t\t\t\tbalance: Math.round(quoteAmount * quoteCoin.scalar),\n\t\t\t});\n\n\t\tconst deepCoin =\n\t\t\tparams.deepCoin ??\n\t\t\tcoinWithBalance({ type: deepCoinType, balance: Math.round(deepAmount * DEEP_SCALAR) });\n\n\t\tconst minBaseInput = Math.round(minBase * baseCoin.scalar);\n\n\t\tconst [baseCoinResult, quoteCoinResult, deepCoinResult] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::swap_exact_quote_for_base`,\n\t\t\targuments: [\n\t\t\t\ttx.object(pool.address),\n\t\t\t\tquoteCoinInput,\n\t\t\t\tdeepCoin,\n\t\t\t\ttx.pure.u64(minBaseInput),\n\t\t\t\ttx.object(SUI_CLOCK_OBJECT_ID),\n\t\t\t],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\n\t\treturn [baseCoinResult, quoteCoinResult, deepCoinResult] as const;\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;AAAA;AAEA,SAAS,uBAAuB;AAEhC,SAAS,2BAA2B;AAEpC,SAAS,WAAW,2BAA2B;AAG/C,SAAS,aAAa,cAAc,YAAY,qBAAqB;AAK9D,MAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA,EAM7B,YAAY,QAAwB;AALpC;AAcA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAkB,CAAC,WAAkC,CAAC,OAAoB;AACzE,YAAM;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,aAAa;AAAA,QACb,YAAY,UAAU;AAAA,QACtB,qBAAqB,oBAAoB;AAAA,QACzC,cAAc;AAAA,MACf,IAAI;AAEJ,SAAG,qBAAqB,UAAU;AAClC,YAAM,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACzC,YAAM,iBAAiB,mBAAK,SAAQ,kBAAkB,iBAAiB;AACvE,YAAM,WAAW,mBAAK,SAAQ,QAAQ,KAAK,QAAQ;AACnD,YAAM,YAAY,mBAAK,SAAQ,QAAQ,KAAK,SAAS;AACrD,YAAM,aAAa,KAAK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aAAa,WAAW,EAAE,CAAC;AAEtF,YAAM,eAAe,KAAK,MAAM,UAAU,SAAS,MAAM;AAEzD,YAAM,CAAC,gBAAgB,iBAAiB,cAAc,IAAI,GAAG,SAAS;AAAA,QACrE,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW;AAAA,UACV,GAAG,OAAO,KAAK,OAAO;AAAA,UACtB;AAAA,UACA;AAAA,UACA,GAAG,KAAK,IAAI,YAAY;AAAA,UACxB,GAAG,OAAO,mBAAmB;AAAA,QAC9B;AAAA,QACA,eAAe,CAAC,SAAS,MAAM,UAAU,IAAI;AAAA,MAC9C,CAAC;AAED,aAAO,CAAC,gBAAgB,iBAAiB,cAAc;AAAA,IACxD;AA/jBC,uBAAK,SAAU;AAAA,EAChB;AA+jBD;AAtkBC;",
6
6
  "names": []
7
7
  }
@@ -22,9 +22,10 @@ class FlashLoanContract {
22
22
  const pool = __privateGet(this, _config).getPool(poolKey);
23
23
  const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
24
24
  const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
25
+ const inputQuantity = Math.round(borrowAmount * baseCoin.scalar);
25
26
  const [baseCoinResult, flashLoan] = tx.moveCall({
26
27
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_base`,
27
- arguments: [tx.object(pool.address), tx.pure.u64(borrowAmount * baseCoin.scalar)],
28
+ arguments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],
28
29
  typeArguments: [baseCoin.type, quoteCoin.type]
29
30
  });
30
31
  return [baseCoinResult, flashLoan];
@@ -43,7 +44,7 @@ class FlashLoanContract {
43
44
  const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
44
45
  const borrowScalar = baseCoin.scalar;
45
46
  const [baseCoinReturn] = tx.splitCoins(baseCoinInput, [
46
- tx.pure.u64(borrowAmount * borrowScalar)
47
+ tx.pure.u64(Math.round(borrowAmount * borrowScalar))
47
48
  ]);
48
49
  tx.moveCall({
49
50
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::return_flashloan_base`,
@@ -62,9 +63,10 @@ class FlashLoanContract {
62
63
  const pool = __privateGet(this, _config).getPool(poolKey);
63
64
  const baseCoin = __privateGet(this, _config).getCoin(pool.baseCoin);
64
65
  const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
66
+ const inputQuantity = Math.round(borrowAmount * quoteCoin.scalar);
65
67
  const [quoteCoinResult, flashLoan] = tx.moveCall({
66
68
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_quote`,
67
- arguments: [tx.object(pool.address), tx.pure.u64(borrowAmount * quoteCoin.scalar)],
69
+ arguments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],
68
70
  typeArguments: [baseCoin.type, quoteCoin.type]
69
71
  });
70
72
  return [quoteCoinResult, flashLoan];
@@ -83,7 +85,7 @@ class FlashLoanContract {
83
85
  const quoteCoin = __privateGet(this, _config).getCoin(pool.quoteCoin);
84
86
  const borrowScalar = quoteCoin.scalar;
85
87
  const [quoteCoinReturn] = tx.splitCoins(quoteCoinInput, [
86
- tx.pure.u64(borrowAmount * borrowScalar)
88
+ tx.pure.u64(Math.round(borrowAmount * borrowScalar))
87
89
  ]);
88
90
  tx.moveCall({
89
91
  target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::pool::return_flashloan_quote`,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/transactions/flashLoans.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\n\n/**\n * FlashLoanContract class for managing flash loans.\n */\nexport class FlashLoanContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration object for DeepBook\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Borrow base asset from the pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} borrowAmount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowBaseAsset = (poolKey: string, borrowAmount: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst [baseCoinResult, flashLoan] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_base`,\n\t\t\targuments: [tx.object(pool.address), tx.pure.u64(borrowAmount * baseCoin.scalar)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t\treturn [baseCoinResult, flashLoan] as const;\n\t};\n\n\t/**\n\t * @description Return base asset to the pool after a flash loan.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} borrowAmount The amount of the base asset to return\n\t * @param {TransactionObjectArgument} baseCoinInput Coin object representing the base asset to be returned\n\t * @param {TransactionObjectArgument} flashLoan FlashLoan object representing the loan to be settled\n\t * @returns A function that takes a Transaction object\n\t */\n\treturnBaseAsset =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tborrowAmount: number,\n\t\t\tbaseCoinInput: TransactionObjectArgument,\n\t\t\tflashLoan: TransactionObjectArgument,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst borrowScalar = baseCoin.scalar;\n\n\t\t\tconst [baseCoinReturn] = tx.splitCoins(baseCoinInput, [\n\t\t\t\ttx.pure.u64(borrowAmount * borrowScalar),\n\t\t\t]);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::return_flashloan_base`,\n\t\t\t\targuments: [tx.object(pool.address), baseCoinReturn, flashLoan],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\n\t\t\treturn baseCoinInput;\n\t\t};\n\n\t/**\n\t * @description Borrow quote asset from the pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} borrowAmount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowQuoteAsset = (poolKey: string, borrowAmount: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst [quoteCoinResult, flashLoan] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_quote`,\n\t\t\targuments: [tx.object(pool.address), tx.pure.u64(borrowAmount * quoteCoin.scalar)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t\treturn [quoteCoinResult, flashLoan] as const;\n\t};\n\n\t/**\n\t * @description Return quote asset to the pool after a flash loan.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} borrowAmount The amount of the quote asset to return\n\t * @param {TransactionObjectArgument} quoteCoinInput Coin object representing the quote asset to be returned\n\t * @param {TransactionObjectArgument} flashLoan FlashLoan object representing the loan to be settled\n\t * @returns A function that takes a Transaction object\n\t */\n\treturnQuoteAsset =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tborrowAmount: number,\n\t\t\tquoteCoinInput: TransactionObjectArgument,\n\t\t\tflashLoan: TransactionObjectArgument,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst borrowScalar = quoteCoin.scalar;\n\n\t\t\tconst [quoteCoinReturn] = tx.splitCoins(quoteCoinInput, [\n\t\t\t\ttx.pure.u64(borrowAmount * borrowScalar),\n\t\t\t]);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::return_flashloan_quote`,\n\t\t\t\targuments: [tx.object(pool.address), quoteCoinReturn, flashLoan],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\n\t\t\treturn quoteCoinInput;\n\t\t};\n}\n"],
5
- "mappings": ";;;;;;;AAAA;AASO,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA,EAM9B,YAAY,QAAwB;AALpC;AAeA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAkB,CAAC,SAAiB,iBAAyB,CAAC,OAAoB;AACjF,YAAM,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACzC,YAAM,WAAW,mBAAK,SAAQ,QAAQ,KAAK,QAAQ;AACnD,YAAM,YAAY,mBAAK,SAAQ,QAAQ,KAAK,SAAS;AACrD,YAAM,CAAC,gBAAgB,SAAS,IAAI,GAAG,SAAS;AAAA,QAC/C,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,KAAK,OAAO,GAAG,GAAG,KAAK,IAAI,eAAe,SAAS,MAAM,CAAC;AAAA,QAChF,eAAe,CAAC,SAAS,MAAM,UAAU,IAAI;AAAA,MAC9C,CAAC;AACD,aAAO,CAAC,gBAAgB,SAAS;AAAA,IAClC;AAUA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BACC,CACC,SACA,cACA,eACA,cAED,CAAC,OAAoB;AACpB,YAAM,OAAO,mBAAK,SAAQ,QAAQ,OAAO;AACzC,YAAM,WAAW,mBAAK,SAAQ,QAAQ,KAAK,QAAQ;AACnD,YAAM,YAAY,m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AAI,GAAG,WAAW,gBAAgB;AAAA,QACvD,GAAG,KAAK,IAAI,eAAe,YAAY;AAAA,MACxC,CAAC;AACD,SAAG,SAAS;AAAA,QACX,QAAQ,GAAG,mBAAK,SAAQ,mBAAmB;AAAA,QAC3C,WAAW,CAAC,GAAG,OAAO,KAAK,OAAO,GAAG,iBAAiB,SAAS;AAAA,QAC/D,eAAe,CAAC,SAAS,MAAM,UAAU,IAAI;AAAA,MAC9C,CAAC;AAED,aAAO;AAAA,IACR;AAvGA,uBAAK,SAAU;AAAA,EAChB;AAuGD;AA9GC;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';\n\nimport type { DeepBookConfig } from '../utils/config.js';\n\n/**\n * FlashLoanContract class for managing flash loans.\n */\nexport class FlashLoanContract {\n\t#config: DeepBookConfig;\n\n\t/**\n\t * @param {DeepBookConfig} config Configuration object for DeepBook\n\t */\n\tconstructor(config: DeepBookConfig) {\n\t\tthis.#config = config;\n\t}\n\n\t/**\n\t * @description Borrow base asset from the pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} borrowAmount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowBaseAsset = (poolKey: string, borrowAmount: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst inputQuantity = Math.round(borrowAmount * baseCoin.scalar);\n\t\tconst [baseCoinResult, flashLoan] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_base`,\n\t\t\targuments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t\treturn [baseCoinResult, flashLoan] as const;\n\t};\n\n\t/**\n\t * @description Return base asset to the pool after a flash loan.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} borrowAmount The amount of the base asset to return\n\t * @param {TransactionObjectArgument} baseCoinInput Coin object representing the base asset to be returned\n\t * @param {TransactionObjectArgument} flashLoan FlashLoan object representing the loan to be settled\n\t * @returns A function that takes a Transaction object\n\t */\n\treturnBaseAsset =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tborrowAmount: number,\n\t\t\tbaseCoinInput: TransactionObjectArgument,\n\t\t\tflashLoan: TransactionObjectArgument,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst borrowScalar = baseCoin.scalar;\n\n\t\t\tconst [baseCoinReturn] = tx.splitCoins(baseCoinInput, [\n\t\t\t\ttx.pure.u64(Math.round(borrowAmount * borrowScalar)),\n\t\t\t]);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::return_flashloan_base`,\n\t\t\t\targuments: [tx.object(pool.address), baseCoinReturn, flashLoan],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\n\t\t\treturn baseCoinInput;\n\t\t};\n\n\t/**\n\t * @description Borrow quote asset from the pool\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} borrowAmount The amount to borrow\n\t * @returns A function that takes a Transaction object\n\t */\n\tborrowQuoteAsset = (poolKey: string, borrowAmount: number) => (tx: Transaction) => {\n\t\tconst pool = this.#config.getPool(poolKey);\n\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\tconst inputQuantity = Math.round(borrowAmount * quoteCoin.scalar);\n\t\tconst [quoteCoinResult, flashLoan] = tx.moveCall({\n\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::borrow_flashloan_quote`,\n\t\t\targuments: [tx.object(pool.address), tx.pure.u64(inputQuantity)],\n\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t});\n\t\treturn [quoteCoinResult, flashLoan] as const;\n\t};\n\n\t/**\n\t * @description Return quote asset to the pool after a flash loan.\n\t * @param {string} poolKey The key to identify the pool\n\t * @param {number} borrowAmount The amount of the quote asset to return\n\t * @param {TransactionObjectArgument} quoteCoinInput Coin object representing the quote asset to be returned\n\t * @param {TransactionObjectArgument} flashLoan FlashLoan object representing the loan to be settled\n\t * @returns A function that takes a Transaction object\n\t */\n\treturnQuoteAsset =\n\t\t(\n\t\t\tpoolKey: string,\n\t\t\tborrowAmount: number,\n\t\t\tquoteCoinInput: TransactionObjectArgument,\n\t\t\tflashLoan: TransactionObjectArgument,\n\t\t) =>\n\t\t(tx: Transaction) => {\n\t\t\tconst pool = this.#config.getPool(poolKey);\n\t\t\tconst baseCoin = this.#config.getCoin(pool.baseCoin);\n\t\t\tconst quoteCoin = this.#config.getCoin(pool.quoteCoin);\n\t\t\tconst borrowScalar = quoteCoin.scalar;\n\n\t\t\tconst [quoteCoinReturn] = tx.splitCoins(quoteCoinInput, [\n\t\t\t\ttx.pure.u64(Math.round(borrowAmount * borrowScalar)),\n\t\t\t]);\n\t\t\ttx.moveCall({\n\t\t\t\ttarget: `${this.#config.DEEPBOOK_PACKAGE_ID}::pool::return_flashloan_quote`,\n\t\t\t\targuments: [tx.object(pool.address), quoteCoinReturn, flashLoan],\n\t\t\t\ttypeArguments: [baseCoin.type, quoteCoin.type],\n\t\t\t});\n\n\t\t\treturn quoteCoinInput;\n\t\t};\n}\n"],
5
+ "mappings": ";;;;;;;AAAA;AASO,MAAM,kBAAkB;AAAA;AAAA;AAAA;AAAA,EAM9B,YAAY,QAAwB;AALpC;AAeA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAkB,CAAC,SAAiB,iBAAyB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