@mysten/deepbook-v3 0.0.0-experimental-20240730220552

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 (78) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +201 -0
  3. package/README.md +1 -0
  4. package/dist/cjs/client.d.ts +177 -0
  5. package/dist/cjs/client.js +387 -0
  6. package/dist/cjs/client.js.map +7 -0
  7. package/dist/cjs/index.d.ts +7 -0
  8. package/dist/cjs/index.js +37 -0
  9. package/dist/cjs/index.js.map +7 -0
  10. package/dist/cjs/package.json +4 -0
  11. package/dist/cjs/transactions/balanceManager.d.ts +80 -0
  12. package/dist/cjs/transactions/balanceManager.js +185 -0
  13. package/dist/cjs/transactions/balanceManager.js.map +7 -0
  14. package/dist/cjs/transactions/deepbook.d.ts +183 -0
  15. package/dist/cjs/transactions/deepbook.js +545 -0
  16. package/dist/cjs/transactions/deepbook.js.map +7 -0
  17. package/dist/cjs/transactions/deepbookAdmin.d.ts +43 -0
  18. package/dist/cjs/transactions/deepbookAdmin.js +159 -0
  19. package/dist/cjs/transactions/deepbookAdmin.js.map +7 -0
  20. package/dist/cjs/transactions/flashLoans.d.ts +56 -0
  21. package/dist/cjs/transactions/flashLoans.js +122 -0
  22. package/dist/cjs/transactions/flashLoans.js.map +7 -0
  23. package/dist/cjs/transactions/governance.d.ts +42 -0
  24. package/dist/cjs/transactions/governance.js +131 -0
  25. package/dist/cjs/transactions/governance.js.map +7 -0
  26. package/dist/cjs/types/index.d.ts +80 -0
  27. package/dist/cjs/types/index.js +38 -0
  28. package/dist/cjs/types/index.js.map +7 -0
  29. package/dist/cjs/utils/config.d.ts +38 -0
  30. package/dist/cjs/utils/config.js +103 -0
  31. package/dist/cjs/utils/config.js.map +7 -0
  32. package/dist/cjs/utils/constants.d.ts +22 -0
  33. package/dist/cjs/utils/constants.js +117 -0
  34. package/dist/cjs/utils/constants.js.map +7 -0
  35. package/dist/esm/client.d.ts +177 -0
  36. package/dist/esm/client.js +367 -0
  37. package/dist/esm/client.js.map +7 -0
  38. package/dist/esm/index.d.ts +7 -0
  39. package/dist/esm/index.js +17 -0
  40. package/dist/esm/index.js.map +7 -0
  41. package/dist/esm/package.json +4 -0
  42. package/dist/esm/transactions/balanceManager.d.ts +80 -0
  43. package/dist/esm/transactions/balanceManager.js +165 -0
  44. package/dist/esm/transactions/balanceManager.js.map +7 -0
  45. package/dist/esm/transactions/deepbook.d.ts +183 -0
  46. package/dist/esm/transactions/deepbook.js +525 -0
  47. package/dist/esm/transactions/deepbook.js.map +7 -0
  48. package/dist/esm/transactions/deepbookAdmin.d.ts +43 -0
  49. package/dist/esm/transactions/deepbookAdmin.js +139 -0
  50. package/dist/esm/transactions/deepbookAdmin.js.map +7 -0
  51. package/dist/esm/transactions/flashLoans.d.ts +56 -0
  52. package/dist/esm/transactions/flashLoans.js +102 -0
  53. package/dist/esm/transactions/flashLoans.js.map +7 -0
  54. package/dist/esm/transactions/governance.d.ts +42 -0
  55. package/dist/esm/transactions/governance.js +111 -0
  56. package/dist/esm/transactions/governance.js.map +7 -0
  57. package/dist/esm/types/index.d.ts +80 -0
  58. package/dist/esm/types/index.js +18 -0
  59. package/dist/esm/types/index.js.map +7 -0
  60. package/dist/esm/utils/config.d.ts +38 -0
  61. package/dist/esm/utils/config.js +90 -0
  62. package/dist/esm/utils/config.js.map +7 -0
  63. package/dist/esm/utils/constants.d.ts +22 -0
  64. package/dist/esm/utils/constants.js +97 -0
  65. package/dist/esm/utils/constants.js.map +7 -0
  66. package/dist/tsconfig.esm.tsbuildinfo +1 -0
  67. package/dist/tsconfig.tsbuildinfo +1 -0
  68. package/package.json +52 -0
  69. package/src/client.ts +429 -0
  70. package/src/index.ts +10 -0
  71. package/src/transactions/balanceManager.ts +182 -0
  72. package/src/transactions/deepbook.ts +587 -0
  73. package/src/transactions/deepbookAdmin.ts +140 -0
  74. package/src/transactions/flashLoans.ts +121 -0
  75. package/src/transactions/governance.ts +119 -0
  76. package/src/types/index.ts +98 -0
  77. package/src/utils/config.ts +103 -0
  78. package/src/utils/constants.ts +106 -0
@@ -0,0 +1,165 @@
1
+ var __typeError = (msg) => {
2
+ throw TypeError(msg);
3
+ };
4
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
5
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
6
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
7
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
8
+ var _config;
9
+ import { coinWithBalance } from "@mysten/sui/transactions";
10
+ class BalanceManagerContract {
11
+ /**
12
+ * @param {DeepBookConfig} config Configuration for BalanceManagerContract
13
+ */
14
+ constructor(config) {
15
+ __privateAdd(this, _config);
16
+ /**
17
+ * @description Create and share a new BalanceManager
18
+ * @returns A function that takes a Transaction object
19
+ */
20
+ this.createAndShareBalanceManager = () => (tx) => {
21
+ const manager = tx.moveCall({
22
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::new`
23
+ });
24
+ tx.moveCall({
25
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::share`,
26
+ arguments: [manager]
27
+ });
28
+ };
29
+ /**
30
+ * @description Deposit funds into the BalanceManager
31
+ * @param {string} managerKey The key of the BalanceManager
32
+ * @param {string} coinKey The key of the coin to deposit
33
+ * @param {number} amountToDeposit The amount to deposit
34
+ * @returns A function that takes a Transaction object
35
+ */
36
+ this.depositIntoManager = (managerKey, coinKey, amountToDeposit) => (tx) => {
37
+ tx.setSenderIfNotSet(__privateGet(this, _config).address);
38
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
39
+ const coin = __privateGet(this, _config).getCoin(coinKey);
40
+ const deposit = coinWithBalance({
41
+ type: coin.type,
42
+ balance: amountToDeposit * coin.scalar
43
+ });
44
+ tx.moveCall({
45
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::deposit`,
46
+ arguments: [tx.object(managerId), deposit],
47
+ typeArguments: [coin.type]
48
+ });
49
+ };
50
+ /**
51
+ * @description Withdraw funds from the BalanceManager
52
+ * @param {string} managerKey The key of the BalanceManager
53
+ * @param {string} coinKey The key of the coin to withdraw
54
+ * @param {number} amountToWithdraw The amount to withdraw
55
+ * @param {string} recipient The recipient of the withdrawn funds
56
+ * @returns A function that takes a Transaction object
57
+ */
58
+ this.withdrawFromManager = (managerKey, coinKey, amountToWithdraw, recipient) => (tx) => {
59
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
60
+ const coin = __privateGet(this, _config).getCoin(coinKey);
61
+ const coinObject = tx.moveCall({
62
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw`,
63
+ arguments: [tx.object(managerId), tx.pure.u64(amountToWithdraw * coin.scalar)],
64
+ typeArguments: [coin.type]
65
+ });
66
+ tx.transferObjects([coinObject], recipient);
67
+ };
68
+ /**
69
+ * @description Withdraw all funds from the BalanceManager
70
+ * @param {string} managerKey The key of the BalanceManager
71
+ * @param {string} coinKey The key of the coin to withdraw
72
+ * @param {string} recipient The recipient of the withdrawn funds
73
+ * @returns A function that takes a Transaction object
74
+ */
75
+ this.withdrawAllFromManager = (managerKey, coinKey, recipient) => (tx) => {
76
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
77
+ const coin = __privateGet(this, _config).getCoin(coinKey);
78
+ const withdrawalCoin = tx.moveCall({
79
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::withdraw_all`,
80
+ arguments: [tx.object(managerId)],
81
+ typeArguments: [coin.type]
82
+ });
83
+ tx.transferObjects([withdrawalCoin], recipient);
84
+ };
85
+ /**
86
+ * @description Check the balance of the BalanceManager
87
+ * @param {string} managerKey The key of the BalanceManager
88
+ * @param {string} coinKey The key of the coin to check the balance of
89
+ * @returns A function that takes a Transaction object
90
+ */
91
+ this.checkManagerBalance = (managerKey, coinKey) => (tx) => {
92
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
93
+ const coin = __privateGet(this, _config).getCoin(coinKey);
94
+ tx.moveCall({
95
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::balance`,
96
+ arguments: [tx.object(managerId)],
97
+ typeArguments: [coin.type]
98
+ });
99
+ };
100
+ /**
101
+ * @description Generate a trade proof for the BalanceManager. Calls the appropriate function based on whether tradeCap is set.
102
+ * @param {string} managerKey The key of the BalanceManager
103
+ * @returns A function that takes a Transaction object
104
+ */
105
+ this.generateProof = (managerKey) => (tx) => {
106
+ const balanceManager = __privateGet(this, _config).getBalanceManager(managerKey);
107
+ return tx.add(
108
+ balanceManager.tradeCap ? this.generateProofAsTrader(balanceManager.address, balanceManager.tradeCap) : this.generateProofAsOwner(balanceManager.address)
109
+ );
110
+ };
111
+ /**
112
+ * @description Generate a trade proof as the owner
113
+ * @param {string} managerId The ID of the BalanceManager
114
+ * @returns A function that takes a Transaction object
115
+ */
116
+ this.generateProofAsOwner = (managerId) => (tx) => {
117
+ return tx.moveCall({
118
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_owner`,
119
+ arguments: [tx.object(managerId)]
120
+ });
121
+ };
122
+ /**
123
+ * @description Generate a trade proof as a trader
124
+ * @param {string} managerId The ID of the BalanceManager
125
+ * @param {string} tradeCapId The ID of the tradeCap
126
+ * @returns A function that takes a Transaction object
127
+ */
128
+ this.generateProofAsTrader = (managerId, tradeCapId) => (tx) => {
129
+ return tx.moveCall({
130
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::generate_proof_as_trader`,
131
+ arguments: [tx.object(managerId), tx.object(tradeCapId)]
132
+ });
133
+ };
134
+ /**
135
+ * @description Get the owner of the BalanceManager
136
+ * @param {string} managerKey The key of the BalanceManager
137
+ * @returns A function that takes a Transaction object
138
+ */
139
+ this.owner = (managerKey) => (tx) => {
140
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
141
+ tx.moveCall({
142
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::owner`,
143
+ arguments: [tx.object(managerId)]
144
+ });
145
+ };
146
+ /**
147
+ * @description Get the ID of the BalanceManager
148
+ * @param {string} managerKey The key of the BalanceManager
149
+ * @returns A function that takes a Transaction object
150
+ */
151
+ this.id = (managerKey) => (tx) => {
152
+ const managerId = __privateGet(this, _config).getBalanceManager(managerKey).address;
153
+ tx.moveCall({
154
+ target: `${__privateGet(this, _config).DEEPBOOK_PACKAGE_ID}::balance_manager::id`,
155
+ arguments: [tx.object(managerId)]
156
+ });
157
+ };
158
+ __privateSet(this, _config, config);
159
+ }
160
+ }
161
+ _config = new WeakMap();
162
+ export {
163
+ BalanceManagerContract
164
+ };
165
+ //# sourceMappingURL=balanceManager.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 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: `${this.#config.DEEPBOOK_PACKAGE_ID}::balance_manager::share`,\n\t\t\targuments: [manager],\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": 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AOA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAuB,CAAC,cAAsB,CAAC,OAAoB;AAClE,aAAO,GAAG,SAAS;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;AAnKC,uBAAK,SAAU;AAAA,EAChB;AAmKD;AA1KC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,183 @@
1
+ import type { Transaction } from '@mysten/sui/transactions';
2
+ import type { PlaceLimitOrderParams, PlaceMarketOrderParams, SwapParams } from '../types/index.js';
3
+ import type { DeepBookConfig } from '../utils/config.js';
4
+ /**
5
+ * DeepBookContract class for managing DeepBook operations.
6
+ */
7
+ export declare class DeepBookContract {
8
+ #private;
9
+ /**
10
+ * @param {DeepBookConfig} config Configuration for DeepBookContract
11
+ */
12
+ constructor(config: DeepBookConfig);
13
+ /**
14
+ * @description Place a limit order
15
+ * @param {PlaceLimitOrderParams} params Parameters for placing a limit order
16
+ * @returns A function that takes a Transaction object
17
+ */
18
+ placeLimitOrder: (params: PlaceLimitOrderParams) => (tx: Transaction) => void;
19
+ /**
20
+ * @description Place a market order
21
+ * @param {PlaceMarketOrderParams} params Parameters for placing a market order
22
+ * @returns A function that takes a Transaction object
23
+ */
24
+ placeMarketOrder: (params: PlaceMarketOrderParams) => (tx: Transaction) => void;
25
+ /**
26
+ * @description Modify an existing order
27
+ * @param {string} poolKey The key to identify the pool
28
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
29
+ * @param {string} orderId Order ID to modify
30
+ * @param {number} newQuantity New quantity for the order
31
+ * @returns A function that takes a Transaction object
32
+ */
33
+ modifyOrder: (poolKey: string, balanceManagerKey: string, orderId: string, newQuantity: number) => (tx: Transaction) => void;
34
+ /**
35
+ * @description Cancel an existing order
36
+ * @param {string} poolKey The key to identify the pool
37
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
38
+ * @param {string} orderId Order ID to cancel
39
+ * @returns A function that takes a Transaction object
40
+ */
41
+ cancelOrder: (poolKey: string, balanceManagerKey: string, orderId: string) => (tx: Transaction) => void;
42
+ /**
43
+ * @description Cancel all open orders for a balance manager
44
+ * @param {string} poolKey The key to identify the pool
45
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
46
+ * @returns A function that takes a Transaction object
47
+ */
48
+ cancelAllOrders: (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => void;
49
+ /**
50
+ * @description Withdraw settled amounts for a balance manager
51
+ * @param {string} poolKey The key to identify the pool
52
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
53
+ * @returns A function that takes a Transaction object
54
+ */
55
+ withdrawSettledAmounts: (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => void;
56
+ /**
57
+ * @description Add a deep price point for a target pool using a reference pool
58
+ * @param {string} targetPoolKey The key to identify the target pool
59
+ * @param {string} referencePoolKey The key to identify the reference pool
60
+ * @returns A function that takes a Transaction object
61
+ */
62
+ addDeepPricePoint: (targetPoolKey: string, referencePoolKey: string) => (tx: Transaction) => void;
63
+ /**
64
+ * @description Claim rebates for a balance manager
65
+ * @param {string} poolKey The key to identify the pool
66
+ * @param {string} balanceManagerKey The key to identify the BalanceManager
67
+ * @returns A function that takes a Transaction object
68
+ */
69
+ claimRebates: (poolKey: string, balanceManagerKey: string) => (tx: Transaction) => void;
70
+ /**
71
+ * @description Gets an order
72
+ * @param {string} poolKey The key to identify the pool
73
+ * @param {string} orderId Order ID to get
74
+ * @returns A function that takes a Transaction object
75
+ */
76
+ getOrder: (poolKey: string, orderId: string) => (tx: Transaction) => void;
77
+ /**
78
+ * @description Burn DEEP tokens from the pool
79
+ * @param {string} poolKey The key to identify the pool
80
+ * @returns A function that takes a Transaction object
81
+ */
82
+ burnDeep: (poolKey: string) => (tx: Transaction) => void;
83
+ /**
84
+ * @description Get the mid price for a pool
85
+ * @param {string} poolKey The key to identify the pool
86
+ * @returns A function that takes a Transaction object
87
+ */
88
+ midPrice: (poolKey: string) => (tx: Transaction) => void;
89
+ /**
90
+ * @description Check if a pool is whitelisted
91
+ * @param {string} poolKey The key to identify the pool
92
+ * @returns A function that takes a Transaction object
93
+ */
94
+ whitelisted: (poolKey: string) => (tx: Transaction) => void;
95
+ /**
96
+ * @description Get the quote quantity out for a given base quantity in
97
+ * @param {string} poolKey The key to identify the pool
98
+ * @param {number} baseQuantity Base quantity to convert
99
+ * @returns A function that takes a Transaction object
100
+ */
101
+ getQuoteQuantityOut: (poolKey: string, baseQuantity: number) => (tx: Transaction) => void;
102
+ /**
103
+ * @description Get the base quantity out for a given quote quantity in
104
+ * @param {string} poolKey The key to identify the pool
105
+ * @param {number} quoteQuantity Quote quantity to convert
106
+ * @returns A function that takes a Transaction object
107
+ */
108
+ getBaseQuantityOut: (poolKey: string, quoteQuantity: number) => (tx: Transaction) => void;
109
+ /**
110
+ * @description Get the quantity out for a given base or quote quantity
111
+ * @param {string} poolKey The key to identify the pool
112
+ * @param {number} baseQuantity Base quantity to convert
113
+ * @param {number} quoteQuantity Quote quantity to convert
114
+ * @returns A function that takes a Transaction object
115
+ */
116
+ getQuantityOut: (poolKey: string, baseQuantity: number, quoteQuantity: number) => (tx: Transaction) => void;
117
+ /**
118
+ * @description Get open orders for a balance manager in a pool
119
+ * @param {string} poolKey The key to identify the pool
120
+ * @param {string} managerKey Key of the balance manager
121
+ * @returns A function that takes a Transaction object
122
+ */
123
+ accountOpenOrders: (poolKey: string, managerKey: string) => (tx: Transaction) => void;
124
+ /**
125
+ * @description Get level 2 order book specifying range of price
126
+ * @param {string} poolKey The key to identify the pool
127
+ * @param {number} priceLow Lower bound of the price range
128
+ * @param {number} priceHigh Upper bound of the price range
129
+ * @param {boolean} isBid Whether to get bid or ask orders
130
+ * @returns A function that takes a Transaction object
131
+ */
132
+ getLevel2Range: (poolKey: string, priceLow: number, priceHigh: number, isBid: boolean) => (tx: Transaction) => void;
133
+ /**
134
+ * @description Get level 2 order book ticks from mid-price for a pool
135
+ * @param {string} poolKey The key to identify the pool
136
+ * @param {number} tickFromMid Number of ticks from mid-price
137
+ * @returns A function that takes a Transaction object
138
+ */
139
+ getLevel2TicksFromMid: (poolKey: string, tickFromMid: number) => (tx: Transaction) => void;
140
+ /**
141
+ * @description Get the vault balances for a pool
142
+ * @param {string} poolKey The key to identify the pool
143
+ * @returns A function that takes a Transaction object
144
+ */
145
+ vaultBalances: (poolKey: string) => (tx: Transaction) => void;
146
+ /**
147
+ * @description Get the pool ID by asset types
148
+ * @param {string} baseType Type of the base asset
149
+ * @param {string} quoteType Type of the quote asset
150
+ * @returns A function that takes a Transaction object
151
+ */
152
+ getPoolIdByAssets: (baseType: string, quoteType: string) => (tx: Transaction) => void;
153
+ /**
154
+ * @description Swap exact base amount for quote amount
155
+ * @param {SwapParams} params Parameters for the swap
156
+ * @returns A function that takes a Transaction object
157
+ */
158
+ swapExactBaseForQuote: (params: SwapParams) => (tx: Transaction) => readonly [{
159
+ $kind: "NestedResult";
160
+ NestedResult: [number, number];
161
+ }, {
162
+ $kind: "NestedResult";
163
+ NestedResult: [number, number];
164
+ }, {
165
+ $kind: "NestedResult";
166
+ NestedResult: [number, number];
167
+ }];
168
+ /**
169
+ * @description Swap exact quote amount for base amount
170
+ * @param {SwapParams} params Parameters for the swap
171
+ * @returns A function that takes a Transaction object
172
+ */
173
+ swapExactQuoteForBase: (params: SwapParams) => (tx: Transaction) => readonly [{
174
+ $kind: "NestedResult";
175
+ NestedResult: [number, number];
176
+ }, {
177
+ $kind: "NestedResult";
178
+ NestedResult: [number, number];
179
+ }, {
180
+ $kind: "NestedResult";
181
+ NestedResult: [number, number];
182
+ }];
183
+ }