@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.
- package/CHANGELOG.md +8 -0
- package/LICENSE +201 -0
- package/README.md +1 -0
- package/dist/cjs/client.d.ts +177 -0
- package/dist/cjs/client.js +387 -0
- package/dist/cjs/client.js.map +7 -0
- package/dist/cjs/index.d.ts +7 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/transactions/balanceManager.d.ts +80 -0
- package/dist/cjs/transactions/balanceManager.js +185 -0
- package/dist/cjs/transactions/balanceManager.js.map +7 -0
- package/dist/cjs/transactions/deepbook.d.ts +183 -0
- package/dist/cjs/transactions/deepbook.js +545 -0
- package/dist/cjs/transactions/deepbook.js.map +7 -0
- package/dist/cjs/transactions/deepbookAdmin.d.ts +43 -0
- package/dist/cjs/transactions/deepbookAdmin.js +159 -0
- package/dist/cjs/transactions/deepbookAdmin.js.map +7 -0
- package/dist/cjs/transactions/flashLoans.d.ts +56 -0
- package/dist/cjs/transactions/flashLoans.js +122 -0
- package/dist/cjs/transactions/flashLoans.js.map +7 -0
- package/dist/cjs/transactions/governance.d.ts +42 -0
- package/dist/cjs/transactions/governance.js +131 -0
- package/dist/cjs/transactions/governance.js.map +7 -0
- package/dist/cjs/types/index.d.ts +80 -0
- package/dist/cjs/types/index.js +38 -0
- package/dist/cjs/types/index.js.map +7 -0
- package/dist/cjs/utils/config.d.ts +38 -0
- package/dist/cjs/utils/config.js +103 -0
- package/dist/cjs/utils/config.js.map +7 -0
- package/dist/cjs/utils/constants.d.ts +22 -0
- package/dist/cjs/utils/constants.js +117 -0
- package/dist/cjs/utils/constants.js.map +7 -0
- package/dist/esm/client.d.ts +177 -0
- package/dist/esm/client.js +367 -0
- package/dist/esm/client.js.map +7 -0
- package/dist/esm/index.d.ts +7 -0
- package/dist/esm/index.js +17 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/package.json +4 -0
- package/dist/esm/transactions/balanceManager.d.ts +80 -0
- package/dist/esm/transactions/balanceManager.js +165 -0
- package/dist/esm/transactions/balanceManager.js.map +7 -0
- package/dist/esm/transactions/deepbook.d.ts +183 -0
- package/dist/esm/transactions/deepbook.js +525 -0
- package/dist/esm/transactions/deepbook.js.map +7 -0
- package/dist/esm/transactions/deepbookAdmin.d.ts +43 -0
- package/dist/esm/transactions/deepbookAdmin.js +139 -0
- package/dist/esm/transactions/deepbookAdmin.js.map +7 -0
- package/dist/esm/transactions/flashLoans.d.ts +56 -0
- package/dist/esm/transactions/flashLoans.js +102 -0
- package/dist/esm/transactions/flashLoans.js.map +7 -0
- package/dist/esm/transactions/governance.d.ts +42 -0
- package/dist/esm/transactions/governance.js +111 -0
- package/dist/esm/transactions/governance.js.map +7 -0
- package/dist/esm/types/index.d.ts +80 -0
- package/dist/esm/types/index.js +18 -0
- package/dist/esm/types/index.js.map +7 -0
- package/dist/esm/utils/config.d.ts +38 -0
- package/dist/esm/utils/config.js +90 -0
- package/dist/esm/utils/config.js.map +7 -0
- package/dist/esm/utils/constants.d.ts +22 -0
- package/dist/esm/utils/constants.js +97 -0
- package/dist/esm/utils/constants.js.map +7 -0
- package/dist/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +52 -0
- package/src/client.ts +429 -0
- package/src/index.ts +10 -0
- package/src/transactions/balanceManager.ts +182 -0
- package/src/transactions/deepbook.ts +587 -0
- package/src/transactions/deepbookAdmin.ts +140 -0
- package/src/transactions/flashLoans.ts +121 -0
- package/src/transactions/governance.ts +119 -0
- package/src/types/index.ts +98 -0
- package/src/utils/config.ts +103 -0
- package/src/utils/constants.ts +106 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
2
|
+
export interface BalanceManager {
|
|
3
|
+
address: string;
|
|
4
|
+
tradeCap: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface Coin {
|
|
7
|
+
address: string;
|
|
8
|
+
type: string;
|
|
9
|
+
scalar: number;
|
|
10
|
+
}
|
|
11
|
+
export interface Pool {
|
|
12
|
+
address: string;
|
|
13
|
+
baseCoin: string;
|
|
14
|
+
quoteCoin: string;
|
|
15
|
+
}
|
|
16
|
+
export declare enum OrderType {
|
|
17
|
+
NO_RESTRICTION = 0,
|
|
18
|
+
IMMEDIATE_OR_CANCEL = 1,
|
|
19
|
+
FILL_OR_KILL = 2,
|
|
20
|
+
POST_ONLY = 3
|
|
21
|
+
}
|
|
22
|
+
export declare enum SelfMatchingOptions {
|
|
23
|
+
SELF_MATCHING_ALLOWED = 0,
|
|
24
|
+
CANCEL_TAKER = 1,
|
|
25
|
+
CANCEL_MAKER = 2
|
|
26
|
+
}
|
|
27
|
+
export interface PlaceLimitOrderParams {
|
|
28
|
+
poolKey: string;
|
|
29
|
+
balanceManagerKey: string;
|
|
30
|
+
clientOrderId: string;
|
|
31
|
+
price: number;
|
|
32
|
+
quantity: number;
|
|
33
|
+
isBid: boolean;
|
|
34
|
+
expiration?: number | bigint;
|
|
35
|
+
orderType?: OrderType;
|
|
36
|
+
selfMatchingOption?: SelfMatchingOptions;
|
|
37
|
+
payWithDeep?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface PlaceMarketOrderParams {
|
|
40
|
+
poolKey: string;
|
|
41
|
+
balanceManagerKey: string;
|
|
42
|
+
clientOrderId: string;
|
|
43
|
+
quantity: number;
|
|
44
|
+
isBid: boolean;
|
|
45
|
+
selfMatchingOption?: SelfMatchingOptions;
|
|
46
|
+
payWithDeep?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface ProposalParams {
|
|
49
|
+
poolKey: string;
|
|
50
|
+
balanceManagerKey: string;
|
|
51
|
+
takerFee: number;
|
|
52
|
+
makerFee: number;
|
|
53
|
+
stakeRequired: number;
|
|
54
|
+
}
|
|
55
|
+
export interface SwapParams {
|
|
56
|
+
poolKey: string;
|
|
57
|
+
amount: number;
|
|
58
|
+
deepAmount: number;
|
|
59
|
+
minOut: number;
|
|
60
|
+
deepCoin?: TransactionObjectArgument;
|
|
61
|
+
baseCoin?: TransactionObjectArgument;
|
|
62
|
+
quoteCoin?: TransactionObjectArgument;
|
|
63
|
+
}
|
|
64
|
+
export interface CreatePoolAdminParams {
|
|
65
|
+
baseCoinKey: string;
|
|
66
|
+
quoteCoinKey: string;
|
|
67
|
+
tickSize: number;
|
|
68
|
+
lotSize: number;
|
|
69
|
+
minSize: number;
|
|
70
|
+
whitelisted: boolean;
|
|
71
|
+
stablePool: boolean;
|
|
72
|
+
deepCoin?: TransactionObjectArgument;
|
|
73
|
+
baseCoin?: TransactionObjectArgument;
|
|
74
|
+
}
|
|
75
|
+
export interface Config {
|
|
76
|
+
DEEPBOOK_PACKAGE_ID: string;
|
|
77
|
+
REGISTRY_ID: string;
|
|
78
|
+
DEEP_TREASURY_ID: string;
|
|
79
|
+
}
|
|
80
|
+
export type Environment = 'mainnet' | 'testnet';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var types_exports = {};
|
|
20
|
+
__export(types_exports, {
|
|
21
|
+
OrderType: () => OrderType,
|
|
22
|
+
SelfMatchingOptions: () => SelfMatchingOptions
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(types_exports);
|
|
25
|
+
var OrderType = /* @__PURE__ */ ((OrderType2) => {
|
|
26
|
+
OrderType2[OrderType2["NO_RESTRICTION"] = 0] = "NO_RESTRICTION";
|
|
27
|
+
OrderType2[OrderType2["IMMEDIATE_OR_CANCEL"] = 1] = "IMMEDIATE_OR_CANCEL";
|
|
28
|
+
OrderType2[OrderType2["FILL_OR_KILL"] = 2] = "FILL_OR_KILL";
|
|
29
|
+
OrderType2[OrderType2["POST_ONLY"] = 3] = "POST_ONLY";
|
|
30
|
+
return OrderType2;
|
|
31
|
+
})(OrderType || {});
|
|
32
|
+
var SelfMatchingOptions = /* @__PURE__ */ ((SelfMatchingOptions2) => {
|
|
33
|
+
SelfMatchingOptions2[SelfMatchingOptions2["SELF_MATCHING_ALLOWED"] = 0] = "SELF_MATCHING_ALLOWED";
|
|
34
|
+
SelfMatchingOptions2[SelfMatchingOptions2["CANCEL_TAKER"] = 1] = "CANCEL_TAKER";
|
|
35
|
+
SelfMatchingOptions2[SelfMatchingOptions2["CANCEL_MAKER"] = 2] = "CANCEL_MAKER";
|
|
36
|
+
return SelfMatchingOptions2;
|
|
37
|
+
})(SelfMatchingOptions || {});
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/types/index.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { TransactionObjectArgument } from '@mysten/sui/transactions';\n\n// SPDX-License-Identifier: Apache-2.0\nexport interface BalanceManager {\n\taddress: string;\n\ttradeCap: string | undefined;\n}\n\nexport interface Coin {\n\taddress: string;\n\ttype: string;\n\tscalar: number;\n}\n\nexport interface Pool {\n\taddress: string;\n\tbaseCoin: string;\n\tquoteCoin: string;\n}\n\n// Trading constants\nexport enum OrderType {\n\tNO_RESTRICTION,\n\tIMMEDIATE_OR_CANCEL,\n\tFILL_OR_KILL,\n\tPOST_ONLY,\n}\n\n// Self matching options\nexport enum SelfMatchingOptions {\n\tSELF_MATCHING_ALLOWED,\n\tCANCEL_TAKER,\n\tCANCEL_MAKER,\n}\n\nexport interface PlaceLimitOrderParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\tclientOrderId: string;\n\tprice: number;\n\tquantity: number;\n\tisBid: boolean;\n\texpiration?: number | bigint;\n\torderType?: OrderType;\n\tselfMatchingOption?: SelfMatchingOptions;\n\tpayWithDeep?: boolean;\n}\n\nexport interface PlaceMarketOrderParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\tclientOrderId: string;\n\tquantity: number;\n\tisBid: boolean;\n\tselfMatchingOption?: SelfMatchingOptions;\n\tpayWithDeep?: boolean;\n}\n\nexport interface ProposalParams {\n\tpoolKey: string;\n\tbalanceManagerKey: string;\n\ttakerFee: number;\n\tmakerFee: number;\n\tstakeRequired: number;\n}\n\nexport interface SwapParams {\n\tpoolKey: string;\n\tamount: number;\n\tdeepAmount: number;\n\tminOut: number;\n\tdeepCoin?: TransactionObjectArgument;\n\tbaseCoin?: TransactionObjectArgument;\n\tquoteCoin?: TransactionObjectArgument;\n}\n\nexport interface CreatePoolAdminParams {\n\tbaseCoinKey: string;\n\tquoteCoinKey: string;\n\ttickSize: number;\n\tlotSize: number;\n\tminSize: number;\n\twhitelisted: boolean;\n\tstablePool: boolean;\n\tdeepCoin?: TransactionObjectArgument;\n\tbaseCoin?: TransactionObjectArgument;\n}\n\nexport interface Config {\n\tDEEPBOOK_PACKAGE_ID: string;\n\tREGISTRY_ID: string;\n\tDEEP_TREASURY_ID: string;\n}\n\nexport type Environment = 'mainnet' | 'testnet';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAwBO,IAAK,YAAL,kBAAKA,eAAL;AACN,EAAAA,sBAAA;AACA,EAAAA,sBAAA;AACA,EAAAA,sBAAA;AACA,EAAAA,sBAAA;AAJW,SAAAA;AAAA,GAAA;AAQL,IAAK,sBAAL,kBAAKC,yBAAL;AACN,EAAAA,0CAAA;AACA,EAAAA,0CAAA;AACA,EAAAA,0CAAA;AAHW,SAAAA;AAAA,GAAA;",
|
|
6
|
+
"names": ["OrderType", "SelfMatchingOptions"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { BalanceManagerContract } from '../transactions/balanceManager.js';
|
|
2
|
+
import type { BalanceManager, Environment } from '../types/index.js';
|
|
3
|
+
import type { CoinMap, PoolMap } from './constants.js';
|
|
4
|
+
export declare const FLOAT_SCALAR = 1000000000;
|
|
5
|
+
export declare const POOL_CREATION_FEE: number;
|
|
6
|
+
export declare const MAX_TIMESTAMP = 1844674407370955161n;
|
|
7
|
+
export declare const GAS_BUDGET: number;
|
|
8
|
+
export declare const DEEP_SCALAR = 1000000;
|
|
9
|
+
export declare class DeepBookConfig {
|
|
10
|
+
#private;
|
|
11
|
+
balanceManagers: {
|
|
12
|
+
[key: string]: BalanceManager;
|
|
13
|
+
};
|
|
14
|
+
address: string;
|
|
15
|
+
DEEPBOOK_PACKAGE_ID: string;
|
|
16
|
+
REGISTRY_ID: string;
|
|
17
|
+
DEEP_TREASURY_ID: string;
|
|
18
|
+
adminCap?: string;
|
|
19
|
+
balanceManager: BalanceManagerContract;
|
|
20
|
+
constructor({ env, address, adminCap, balanceManagers, coins, pools, }: {
|
|
21
|
+
env: Environment;
|
|
22
|
+
address: string;
|
|
23
|
+
adminCap?: string;
|
|
24
|
+
balanceManagers?: {
|
|
25
|
+
[key: string]: BalanceManager;
|
|
26
|
+
};
|
|
27
|
+
coins?: CoinMap;
|
|
28
|
+
pools?: PoolMap;
|
|
29
|
+
});
|
|
30
|
+
getCoin(key: string): import("../types/index.js").Coin;
|
|
31
|
+
getPool(key: string): import("../types/index.js").Pool;
|
|
32
|
+
/**
|
|
33
|
+
* @description Get the balance manager by key
|
|
34
|
+
* @param managerKey Key of the balance manager
|
|
35
|
+
* @returns The BalanceManager object
|
|
36
|
+
*/
|
|
37
|
+
getBalanceManager(managerKey: string): BalanceManager;
|
|
38
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __typeError = (msg) => {
|
|
7
|
+
throw TypeError(msg);
|
|
8
|
+
};
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
23
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
24
|
+
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);
|
|
25
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
26
|
+
var config_exports = {};
|
|
27
|
+
__export(config_exports, {
|
|
28
|
+
DEEP_SCALAR: () => DEEP_SCALAR,
|
|
29
|
+
DeepBookConfig: () => DeepBookConfig,
|
|
30
|
+
FLOAT_SCALAR: () => FLOAT_SCALAR,
|
|
31
|
+
GAS_BUDGET: () => GAS_BUDGET,
|
|
32
|
+
MAX_TIMESTAMP: () => MAX_TIMESTAMP,
|
|
33
|
+
POOL_CREATION_FEE: () => POOL_CREATION_FEE
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(config_exports);
|
|
36
|
+
var import_utils = require("@mysten/sui/utils");
|
|
37
|
+
var import_balanceManager = require("../transactions/balanceManager.js");
|
|
38
|
+
var import_constants = require("./constants.js");
|
|
39
|
+
var _coins, _pools;
|
|
40
|
+
const FLOAT_SCALAR = 1e9;
|
|
41
|
+
const POOL_CREATION_FEE = 1e4 * 1e6;
|
|
42
|
+
const MAX_TIMESTAMP = 1844674407370955161n;
|
|
43
|
+
const GAS_BUDGET = 0.5 * 5e8;
|
|
44
|
+
const DEEP_SCALAR = 1e6;
|
|
45
|
+
class DeepBookConfig {
|
|
46
|
+
constructor({
|
|
47
|
+
env,
|
|
48
|
+
address,
|
|
49
|
+
adminCap,
|
|
50
|
+
balanceManagers,
|
|
51
|
+
coins,
|
|
52
|
+
pools
|
|
53
|
+
}) {
|
|
54
|
+
__privateAdd(this, _coins);
|
|
55
|
+
__privateAdd(this, _pools);
|
|
56
|
+
this.address = (0, import_utils.normalizeSuiAddress)(address);
|
|
57
|
+
this.adminCap = adminCap;
|
|
58
|
+
this.balanceManagers = balanceManagers || {};
|
|
59
|
+
if (env === "mainnet") {
|
|
60
|
+
__privateSet(this, _coins, coins || import_constants.mainnetCoins);
|
|
61
|
+
__privateSet(this, _pools, pools || import_constants.mainnetPools);
|
|
62
|
+
this.DEEPBOOK_PACKAGE_ID = import_constants.mainnetPackageIds.DEEPBOOK_PACKAGE_ID;
|
|
63
|
+
this.REGISTRY_ID = import_constants.mainnetPackageIds.REGISTRY_ID;
|
|
64
|
+
this.DEEP_TREASURY_ID = import_constants.mainnetPackageIds.DEEP_TREASURY_ID;
|
|
65
|
+
} else {
|
|
66
|
+
__privateSet(this, _coins, coins || import_constants.testnetCoins);
|
|
67
|
+
__privateSet(this, _pools, pools || import_constants.testnetPools);
|
|
68
|
+
this.DEEPBOOK_PACKAGE_ID = import_constants.testnetPackageIds.DEEPBOOK_PACKAGE_ID;
|
|
69
|
+
this.REGISTRY_ID = import_constants.testnetPackageIds.REGISTRY_ID;
|
|
70
|
+
this.DEEP_TREASURY_ID = import_constants.testnetPackageIds.DEEP_TREASURY_ID;
|
|
71
|
+
}
|
|
72
|
+
this.balanceManager = new import_balanceManager.BalanceManagerContract(this);
|
|
73
|
+
}
|
|
74
|
+
// Getters
|
|
75
|
+
getCoin(key) {
|
|
76
|
+
const coin = __privateGet(this, _coins)[key];
|
|
77
|
+
if (!coin) {
|
|
78
|
+
throw new Error(`Coin not found for key: ${key}`);
|
|
79
|
+
}
|
|
80
|
+
return coin;
|
|
81
|
+
}
|
|
82
|
+
getPool(key) {
|
|
83
|
+
const pool = __privateGet(this, _pools)[key];
|
|
84
|
+
if (!pool) {
|
|
85
|
+
throw new Error(`Pool not found for key: ${key}`);
|
|
86
|
+
}
|
|
87
|
+
return pool;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @description Get the balance manager by key
|
|
91
|
+
* @param managerKey Key of the balance manager
|
|
92
|
+
* @returns The BalanceManager object
|
|
93
|
+
*/
|
|
94
|
+
getBalanceManager(managerKey) {
|
|
95
|
+
if (!Object.hasOwn(this.balanceManagers, managerKey)) {
|
|
96
|
+
throw new Error(`Balance manager with key ${managerKey} not found.`);
|
|
97
|
+
}
|
|
98
|
+
return this.balanceManagers[managerKey];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
_coins = new WeakMap();
|
|
102
|
+
_pools = new WeakMap();
|
|
103
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/config.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\n\nimport { BalanceManagerContract } from '../transactions/balanceManager.js';\nimport type { BalanceManager, Environment } from '../types/index.js';\nimport type { CoinMap, PoolMap } from './constants.js';\nimport {\n\tmainnetCoins,\n\tmainnetPackageIds,\n\tmainnetPools,\n\ttestnetCoins,\n\ttestnetPackageIds,\n\ttestnetPools,\n} from './constants.js';\n\nexport const FLOAT_SCALAR = 1000000000;\nexport const POOL_CREATION_FEE = 10000 * 1000000;\nexport const MAX_TIMESTAMP = 1844674407370955161n;\nexport const GAS_BUDGET = 0.5 * 500000000; // Adjust based on benchmarking\nexport const DEEP_SCALAR = 1000000;\n\nexport class DeepBookConfig {\n\t#coins: CoinMap;\n\t#pools: PoolMap;\n\tbalanceManagers: { [key: string]: BalanceManager };\n\taddress: string;\n\n\tDEEPBOOK_PACKAGE_ID: string;\n\tREGISTRY_ID: string;\n\tDEEP_TREASURY_ID: string;\n\tadminCap?: string;\n\n\tbalanceManager: BalanceManagerContract;\n\n\tconstructor({\n\t\tenv,\n\t\taddress,\n\t\tadminCap,\n\t\tbalanceManagers,\n\t\tcoins,\n\t\tpools,\n\t}: {\n\t\tenv: Environment;\n\t\taddress: string;\n\t\tadminCap?: string;\n\t\tbalanceManagers?: { [key: string]: BalanceManager };\n\t\tcoins?: CoinMap;\n\t\tpools?: PoolMap;\n\t}) {\n\t\tthis.address = normalizeSuiAddress(address);\n\t\tthis.adminCap = adminCap;\n\t\tthis.balanceManagers = balanceManagers || {};\n\n\t\tif (env === 'mainnet') {\n\t\t\tthis.#coins = coins || mainnetCoins;\n\t\t\tthis.#pools = pools || mainnetPools;\n\t\t\tthis.DEEPBOOK_PACKAGE_ID = mainnetPackageIds.DEEPBOOK_PACKAGE_ID;\n\t\t\tthis.REGISTRY_ID = mainnetPackageIds.REGISTRY_ID;\n\t\t\tthis.DEEP_TREASURY_ID = mainnetPackageIds.DEEP_TREASURY_ID;\n\t\t} else {\n\t\t\tthis.#coins = coins || testnetCoins;\n\t\t\tthis.#pools = pools || testnetPools;\n\t\t\tthis.DEEPBOOK_PACKAGE_ID = testnetPackageIds.DEEPBOOK_PACKAGE_ID;\n\t\t\tthis.REGISTRY_ID = testnetPackageIds.REGISTRY_ID;\n\t\t\tthis.DEEP_TREASURY_ID = testnetPackageIds.DEEP_TREASURY_ID;\n\t\t}\n\n\t\tthis.balanceManager = new BalanceManagerContract(this);\n\t}\n\n\t// Getters\n\tgetCoin(key: string) {\n\t\tconst coin = this.#coins[key];\n\t\tif (!coin) {\n\t\t\tthrow new Error(`Coin not found for key: ${key}`);\n\t\t}\n\n\t\treturn coin;\n\t}\n\n\tgetPool(key: string) {\n\t\tconst pool = this.#pools[key];\n\t\tif (!pool) {\n\t\t\tthrow new Error(`Pool not found for key: ${key}`);\n\t\t}\n\n\t\treturn pool;\n\t}\n\n\t/**\n\t * @description Get the balance manager by key\n\t * @param managerKey Key of the balance manager\n\t * @returns The BalanceManager object\n\t */\n\tgetBalanceManager(managerKey: string): BalanceManager {\n\t\tif (!Object.hasOwn(this.balanceManagers, managerKey)) {\n\t\t\tthrow new Error(`Balance manager with key ${managerKey} not found.`);\n\t\t}\n\n\t\treturn this.balanceManagers[managerKey];\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAoC;AAEpC,4BAAuC;AAGvC,uBAOO;AAdP;AAgBO,MAAM,eAAe;AACrB,MAAM,oBAAoB,MAAQ;AAClC,MAAM,gBAAgB;AACtB,MAAM,aAAa,MAAM;AACzB,MAAM,cAAc;AAEpB,MAAM,eAAe;AAAA,EAa3B,YAAY;AAAA,IACX;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,GAOG;AA1BH;AACA;AA0BC,SAAK,cAAU,kCAAoB,OAAO;AAC1C,SAAK,WAAW;AAChB,SAAK,kBAAkB,mBAAmB,CAAC;AAE3C,QAAI,QAAQ,WAAW;AACtB,yBAAK,QAAS,SAAS;AACvB,yBAAK,QAAS,SAAS;AACvB,WAAK,sBAAsB,mCAAkB;AAC7C,WAAK,cAAc,mCAAkB;AACrC,WAAK,mBAAmB,mCAAkB;AAAA,IAC3C,OAAO;AACN,yBAAK,QAAS,SAAS;AACvB,yBAAK,QAAS,SAAS;AACvB,WAAK,sBAAsB,mCAAkB;AAC7C,WAAK,cAAc,mCAAkB;AACrC,WAAK,mBAAmB,mCAAkB;AAAA,IAC3C;AAEA,SAAK,iBAAiB,IAAI,6CAAuB,IAAI;AAAA,EACtD;AAAA;AAAA,EAGA,QAAQ,KAAa;AACpB,UAAM,OAAO,mBAAK,QAAO,GAAG;AAC5B,QAAI,CAAC,MAAM;AACV,YAAM,IAAI,MAAM,2BAA2B,GAAG,EAAE;AAAA,IACjD;AAEA,WAAO;AAAA,EACR;AAAA,EAEA,QAAQ,KAAa;AACpB,UAAM,OAAO,mBAAK,QAAO,GAAG;AAC5B,QAAI,CAAC,MAAM;AACV,YAAM,IAAI,MAAM,2BAA2B,GAAG,EAAE;AAAA,IACjD;AAEA,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAAkB,YAAoC;AACrD,QAAI,CAAC,OAAO,OAAO,KAAK,iBAAiB,UAAU,GAAG;AACrD,YAAM,IAAI,MAAM,4BAA4B,UAAU,aAAa;AAAA,IACpE;AAEA,WAAO,KAAK,gBAAgB,UAAU;AAAA,EACvC;AACD;AA/EC;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Coin, Pool } from '../types/index.js';
|
|
2
|
+
export type CoinMap = Record<string, Coin>;
|
|
3
|
+
export type PoolMap = Record<string, Pool>;
|
|
4
|
+
export interface DeepbookPackageIds {
|
|
5
|
+
DEEPBOOK_PACKAGE_ID: string;
|
|
6
|
+
REGISTRY_ID: string;
|
|
7
|
+
DEEP_TREASURY_ID: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const testnetPackageIds: {
|
|
10
|
+
DEEPBOOK_PACKAGE_ID: string;
|
|
11
|
+
REGISTRY_ID: string;
|
|
12
|
+
DEEP_TREASURY_ID: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const mainnetPackageIds: {
|
|
15
|
+
DEEPBOOK_PACKAGE_ID: string;
|
|
16
|
+
REGISTRY_ID: string;
|
|
17
|
+
DEEP_TREASURY_ID: string;
|
|
18
|
+
};
|
|
19
|
+
export declare const testnetCoins: CoinMap;
|
|
20
|
+
export declare const mainnetCoins: CoinMap;
|
|
21
|
+
export declare const testnetPools: PoolMap;
|
|
22
|
+
export declare const mainnetPools: PoolMap;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var constants_exports = {};
|
|
20
|
+
__export(constants_exports, {
|
|
21
|
+
mainnetCoins: () => mainnetCoins,
|
|
22
|
+
mainnetPackageIds: () => mainnetPackageIds,
|
|
23
|
+
mainnetPools: () => mainnetPools,
|
|
24
|
+
testnetCoins: () => testnetCoins,
|
|
25
|
+
testnetPackageIds: () => testnetPackageIds,
|
|
26
|
+
testnetPools: () => testnetPools
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(constants_exports);
|
|
29
|
+
const testnetPackageIds = {
|
|
30
|
+
DEEPBOOK_PACKAGE_ID: "0xbf8c499152c205dc5af0a89e95911e2c7d6d1c8b6a4d3a96058aee5fef3ae03a",
|
|
31
|
+
REGISTRY_ID: "0x1e9619bb7e1ffb94f2ba9d1bd55d922921931e138dd0b7a1a3c5ede8d1cf9424",
|
|
32
|
+
DEEP_TREASURY_ID: "0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb"
|
|
33
|
+
};
|
|
34
|
+
const mainnetPackageIds = {
|
|
35
|
+
DEEPBOOK_PACKAGE_ID: "",
|
|
36
|
+
REGISTRY_ID: "",
|
|
37
|
+
DEEP_TREASURY_ID: ""
|
|
38
|
+
};
|
|
39
|
+
const testnetCoins = {
|
|
40
|
+
DEEP: {
|
|
41
|
+
address: `0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8`,
|
|
42
|
+
type: `0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP`,
|
|
43
|
+
scalar: 1e6
|
|
44
|
+
},
|
|
45
|
+
SUI: {
|
|
46
|
+
address: `0x0000000000000000000000000000000000000000000000000000000000000002`,
|
|
47
|
+
type: `0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI`,
|
|
48
|
+
scalar: 1e9
|
|
49
|
+
},
|
|
50
|
+
DBUSDC: {
|
|
51
|
+
address: `0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7`,
|
|
52
|
+
type: `0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDC::DBUSDC`,
|
|
53
|
+
scalar: 1e6
|
|
54
|
+
},
|
|
55
|
+
DBUSDT: {
|
|
56
|
+
address: `0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7`,
|
|
57
|
+
type: `0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDT::DBUSDT`,
|
|
58
|
+
scalar: 1e6
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const mainnetCoins = {
|
|
62
|
+
DEEP: {
|
|
63
|
+
address: `0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270`,
|
|
64
|
+
type: `0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP`,
|
|
65
|
+
scalar: 1e6
|
|
66
|
+
},
|
|
67
|
+
SUI: {
|
|
68
|
+
address: `0x0000000000000000000000000000000000000000000000000000000000000002`,
|
|
69
|
+
type: `0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI`,
|
|
70
|
+
scalar: 1e9
|
|
71
|
+
},
|
|
72
|
+
USDC: {
|
|
73
|
+
address: `0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf`,
|
|
74
|
+
type: `0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN`,
|
|
75
|
+
scalar: 1e6
|
|
76
|
+
},
|
|
77
|
+
WETH: {
|
|
78
|
+
address: `0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5`,
|
|
79
|
+
type: `0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN`,
|
|
80
|
+
scalar: 1e8
|
|
81
|
+
},
|
|
82
|
+
USDT: {
|
|
83
|
+
address: `0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c`,
|
|
84
|
+
type: `0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN`,
|
|
85
|
+
scalar: 1e6
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const testnetPools = {
|
|
89
|
+
DEEP_SUI: {
|
|
90
|
+
address: `0xfd25055cdcfff6ef7031c941d4fd407880fa19dd24d0f526c3b38c633fefe49e`,
|
|
91
|
+
baseCoin: "DEEP",
|
|
92
|
+
quoteCoin: "SUI"
|
|
93
|
+
},
|
|
94
|
+
SUI_DBUSDC: {
|
|
95
|
+
address: `0x9b7d3cf0c35cdebb9909705548249c4240004f7300e1b0dfc90ac232c8f431d1`,
|
|
96
|
+
baseCoin: "SUI",
|
|
97
|
+
quoteCoin: "DBUSDC"
|
|
98
|
+
},
|
|
99
|
+
DEEP_DBUSDC: {
|
|
100
|
+
address: `0xa136f878686acd23ea6881f31b937ffd378bbdb4eaebf54bd793c5f9e2ab53f0`,
|
|
101
|
+
baseCoin: "DEEP",
|
|
102
|
+
quoteCoin: "DBUSDC"
|
|
103
|
+
},
|
|
104
|
+
DBUSDT_DBUSDC: {
|
|
105
|
+
address: `0x19a667bb5c80ee40155b8bf9aada0d787d7a86cb44f51b4b8a88df7d5a4cd0d0`,
|
|
106
|
+
baseCoin: "DBUSDT",
|
|
107
|
+
quoteCoin: "DBUSDC"
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const mainnetPools = {
|
|
111
|
+
DEEP_SUI: {
|
|
112
|
+
address: ``,
|
|
113
|
+
baseCoin: "DEEP",
|
|
114
|
+
quoteCoin: "SUI"
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/utils/constants.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Coin, Pool } from '../types/index.js';\n\nexport type CoinMap = Record<string, Coin>;\nexport type PoolMap = Record<string, Pool>;\nexport interface DeepbookPackageIds {\n\tDEEPBOOK_PACKAGE_ID: string;\n\tREGISTRY_ID: string;\n\tDEEP_TREASURY_ID: string;\n}\n\nexport const testnetPackageIds = {\n\tDEEPBOOK_PACKAGE_ID: '0xbf8c499152c205dc5af0a89e95911e2c7d6d1c8b6a4d3a96058aee5fef3ae03a',\n\tREGISTRY_ID: '0x1e9619bb7e1ffb94f2ba9d1bd55d922921931e138dd0b7a1a3c5ede8d1cf9424',\n\tDEEP_TREASURY_ID: '0x69fffdae0075f8f71f4fa793549c11079266910e8905169845af1f5d00e09dcb',\n} satisfies DeepbookPackageIds;\n\nexport const mainnetPackageIds = {\n\tDEEPBOOK_PACKAGE_ID: '',\n\tREGISTRY_ID: '',\n\tDEEP_TREASURY_ID: '',\n};\n\nexport const testnetCoins: CoinMap = {\n\tDEEP: {\n\t\taddress: `0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8`,\n\t\ttype: `0x36dbef866a1d62bf7328989a10fb2f07d769f4ee587c0de4a0a256e57e0a58a8::deep::DEEP`,\n\t\tscalar: 1000000,\n\t},\n\tSUI: {\n\t\taddress: `0x0000000000000000000000000000000000000000000000000000000000000002`,\n\t\ttype: `0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI`,\n\t\tscalar: 1000000000,\n\t},\n\tDBUSDC: {\n\t\taddress: `0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7`,\n\t\ttype: `0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDC::DBUSDC`,\n\t\tscalar: 1000000,\n\t},\n\tDBUSDT: {\n\t\taddress: `0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7`,\n\t\ttype: `0xf7152c05930480cd740d7311b5b8b45c6f488e3a53a11c3f74a6fac36a52e0d7::DBUSDT::DBUSDT`,\n\t\tscalar: 1000000,\n\t},\n};\n\nexport const mainnetCoins: CoinMap = {\n\tDEEP: {\n\t\taddress: `0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270`,\n\t\ttype: `0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP`,\n\t\tscalar: 1000000,\n\t},\n\tSUI: {\n\t\taddress: `0x0000000000000000000000000000000000000000000000000000000000000002`,\n\t\ttype: `0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI`,\n\t\tscalar: 1000000000,\n\t},\n\tUSDC: {\n\t\taddress: `0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf`,\n\t\ttype: `0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN`,\n\t\tscalar: 1000000,\n\t},\n\tWETH: {\n\t\taddress: `0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5`,\n\t\ttype: `0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5::coin::COIN`,\n\t\tscalar: 100000000,\n\t},\n\tUSDT: {\n\t\taddress: `0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c`,\n\t\ttype: `0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN`,\n\t\tscalar: 1000000,\n\t},\n};\n\nexport const testnetPools: PoolMap = {\n\tDEEP_SUI: {\n\t\taddress: `0xfd25055cdcfff6ef7031c941d4fd407880fa19dd24d0f526c3b38c633fefe49e`,\n\t\tbaseCoin: 'DEEP',\n\t\tquoteCoin: 'SUI',\n\t},\n\tSUI_DBUSDC: {\n\t\taddress: `0x9b7d3cf0c35cdebb9909705548249c4240004f7300e1b0dfc90ac232c8f431d1`,\n\t\tbaseCoin: 'SUI',\n\t\tquoteCoin: 'DBUSDC',\n\t},\n\tDEEP_DBUSDC: {\n\t\taddress: `0xa136f878686acd23ea6881f31b937ffd378bbdb4eaebf54bd793c5f9e2ab53f0`,\n\t\tbaseCoin: 'DEEP',\n\t\tquoteCoin: 'DBUSDC',\n\t},\n\tDBUSDT_DBUSDC: {\n\t\taddress: `0x19a667bb5c80ee40155b8bf9aada0d787d7a86cb44f51b4b8a88df7d5a4cd0d0`,\n\t\tbaseCoin: 'DBUSDT',\n\t\tquoteCoin: 'DBUSDC',\n\t},\n};\n\nexport const mainnetPools: PoolMap = {\n\tDEEP_SUI: {\n\t\taddress: ``,\n\t\tbaseCoin: 'DEEP',\n\t\tquoteCoin: 'SUI',\n\t},\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,MAAM,oBAAoB;AAAA,EAChC,qBAAqB;AAAA,EACrB,aAAa;AAAA,EACb,kBAAkB;AACnB;AAEO,MAAM,oBAAoB;AAAA,EAChC,qBAAqB;AAAA,EACrB,aAAa;AAAA,EACb,kBAAkB;AACnB;AAEO,MAAM,eAAwB;AAAA,EACpC,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAAA,EACA,KAAK;AAAA,IACJ,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACP,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AACD;AAEO,MAAM,eAAwB;AAAA,EACpC,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAAA,EACA,KAAK;AAAA,IACJ,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAAA,EACA,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAAA,EACA,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAAA,EACA,MAAM;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AACD;AAEO,MAAM,eAAwB;AAAA,EACpC,UAAU;AAAA,IACT,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,EACZ;AAAA,EACA,YAAY;AAAA,IACX,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,EACZ;AAAA,EACA,aAAa;AAAA,IACZ,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,EACZ;AAAA,EACA,eAAe;AAAA,IACd,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,EACZ;AACD;AAEO,MAAM,eAAwB;AAAA,EACpC,UAAU;AAAA,IACT,SAAS;AAAA,IACT,UAAU;AAAA,IACV,WAAW;AAAA,EACZ;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { SuiClient } from '@mysten/sui/client';
|
|
2
|
+
import { BalanceManagerContract } from './transactions/balanceManager.js';
|
|
3
|
+
import { DeepBookContract } from './transactions/deepbook.js';
|
|
4
|
+
import { DeepBookAdminContract } from './transactions/deepbookAdmin.js';
|
|
5
|
+
import { FlashLoanContract } from './transactions/flashLoans.js';
|
|
6
|
+
import { GovernanceContract } from './transactions/governance.js';
|
|
7
|
+
import type { BalanceManager, Environment } from './types/index.js';
|
|
8
|
+
import type { CoinMap, PoolMap } from './utils/constants.js';
|
|
9
|
+
/**
|
|
10
|
+
* DeepBookClient class for managing DeepBook operations.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DeepBookClient {
|
|
13
|
+
#private;
|
|
14
|
+
client: SuiClient;
|
|
15
|
+
balanceManager: BalanceManagerContract;
|
|
16
|
+
deepBook: DeepBookContract;
|
|
17
|
+
deepBookAdmin: DeepBookAdminContract;
|
|
18
|
+
flashLoans: FlashLoanContract;
|
|
19
|
+
governance: GovernanceContract;
|
|
20
|
+
/**
|
|
21
|
+
* @param {SuiClient} client SuiClient instance
|
|
22
|
+
* @param {string} address Address of the client
|
|
23
|
+
* @param {Environment} env Environment configuration
|
|
24
|
+
* @param {Object.<string, BalanceManager>} [balanceManagers] Optional initial BalanceManager map
|
|
25
|
+
* @param {CoinMap} [coins] Optional initial CoinMap
|
|
26
|
+
* @param {PoolMap} [pools] Optional initial PoolMap
|
|
27
|
+
* @param {string} [adminCap] Optional admin capability
|
|
28
|
+
*/
|
|
29
|
+
constructor({ client, address, env, balanceManagers, coins, pools, adminCap, }: {
|
|
30
|
+
client: SuiClient;
|
|
31
|
+
address: string;
|
|
32
|
+
env: Environment;
|
|
33
|
+
balanceManagers?: {
|
|
34
|
+
[key: string]: BalanceManager;
|
|
35
|
+
};
|
|
36
|
+
coins?: CoinMap;
|
|
37
|
+
pools?: PoolMap;
|
|
38
|
+
adminCap?: string;
|
|
39
|
+
});
|
|
40
|
+
/**
|
|
41
|
+
* @description Check the balance of a balance manager for a specific coin
|
|
42
|
+
* @param {string} managerKey Key of the balance manager
|
|
43
|
+
* @param {string} coinKey Key of the coin
|
|
44
|
+
* @returns {Promise<{ coinType: string, balance: number }>} An object with coin type and balance
|
|
45
|
+
*/
|
|
46
|
+
checkManagerBalance(managerKey: string, coinKey: string): Promise<{
|
|
47
|
+
coinType: string;
|
|
48
|
+
balance: number;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* @description Check if a pool is whitelisted
|
|
52
|
+
* @param {string} poolKey Key of the pool
|
|
53
|
+
* @returns {Promise<boolean>} Boolean indicating if the pool is whitelisted
|
|
54
|
+
*/
|
|
55
|
+
whitelisted(poolKey: string): Promise<boolean>;
|
|
56
|
+
/**
|
|
57
|
+
* @description Get the quote quantity out for a given base quantity
|
|
58
|
+
* @param {string} poolKey Key of the pool
|
|
59
|
+
* @param {number} baseQuantity Base quantity to convert
|
|
60
|
+
* @returns {Promise<{ baseQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}
|
|
61
|
+
* An object with base quantity, base out, quote out, and deep required for the dry run
|
|
62
|
+
*/
|
|
63
|
+
getQuoteQuantityOut(poolKey: string, baseQuantity: number): Promise<{
|
|
64
|
+
baseQuantity: number;
|
|
65
|
+
baseOut: number;
|
|
66
|
+
quoteOut: number;
|
|
67
|
+
deepRequired: number;
|
|
68
|
+
}>;
|
|
69
|
+
/**
|
|
70
|
+
* @description Get the base quantity out for a given quote quantity
|
|
71
|
+
* @param {string} poolKey Key of the pool
|
|
72
|
+
* @param {number} quoteQuantity Quote quantity to convert
|
|
73
|
+
* @returns {Promise<{ quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}
|
|
74
|
+
* An object with quote quantity, base out, quote out, and deep required for the dry run
|
|
75
|
+
*/
|
|
76
|
+
getBaseQuantityOut(poolKey: string, quoteQuantity: number): Promise<{
|
|
77
|
+
quoteQuantity: number;
|
|
78
|
+
baseOut: number;
|
|
79
|
+
quoteOut: number;
|
|
80
|
+
deepRequired: number;
|
|
81
|
+
}>;
|
|
82
|
+
/**
|
|
83
|
+
* @description Get the output quantities for given base and quote quantities. Only one quantity can be non-zero
|
|
84
|
+
* @param {string} poolKey Key of the pool
|
|
85
|
+
* @param {number} baseQuantity Base quantity to convert
|
|
86
|
+
* @param {number} quoteQuantity Quote quantity to convert
|
|
87
|
+
* @returns {Promise<{ baseQuantity: number, quoteQuantity: number, baseOut: number, quoteOut: number, deepRequired: number }>}
|
|
88
|
+
* An object with base quantity, quote quantity, base out, quote out, and deep required for the dry run
|
|
89
|
+
*/
|
|
90
|
+
getQuantityOut(poolKey: string, baseQuantity: number, quoteQuantity: number): Promise<{
|
|
91
|
+
baseQuantity: number;
|
|
92
|
+
quoteQuantity: number;
|
|
93
|
+
baseOut: number;
|
|
94
|
+
quoteOut: number;
|
|
95
|
+
deepRequired: number;
|
|
96
|
+
}>;
|
|
97
|
+
/**
|
|
98
|
+
* @description Get open orders for a balance manager in a pool
|
|
99
|
+
* @param {string} poolKey Key of the pool
|
|
100
|
+
* @param {string} managerKey Key of the balance manager
|
|
101
|
+
* @returns {Promise<Array>} An array of open order IDs
|
|
102
|
+
*/
|
|
103
|
+
accountOpenOrders(poolKey: string, managerKey: string): Promise<string[]>;
|
|
104
|
+
/**
|
|
105
|
+
* @description Get the order information for a specific order in a pool
|
|
106
|
+
* @param {string} poolKey Key of the pool
|
|
107
|
+
* @param {string} orderId Order ID
|
|
108
|
+
* @returns {Promise<Object>} A promise that resolves to an object containing the order information
|
|
109
|
+
*/
|
|
110
|
+
getOrder(poolKey: string, orderId: string): Promise<{
|
|
111
|
+
balance_manager_id: {
|
|
112
|
+
bytes: string;
|
|
113
|
+
};
|
|
114
|
+
order_id: string;
|
|
115
|
+
client_order_id: string;
|
|
116
|
+
quantity: string;
|
|
117
|
+
filled_quantity: string;
|
|
118
|
+
fee_is_deep: boolean;
|
|
119
|
+
order_deep_price: {
|
|
120
|
+
asset_is_base: boolean;
|
|
121
|
+
deep_per_asset: string;
|
|
122
|
+
};
|
|
123
|
+
epoch: string;
|
|
124
|
+
status: number;
|
|
125
|
+
expire_timestamp: string;
|
|
126
|
+
}>;
|
|
127
|
+
/**
|
|
128
|
+
* @description Get level 2 order book specifying range of price
|
|
129
|
+
* @param {string} poolKey Key of the pool
|
|
130
|
+
* @param {number} priceLow Lower bound of the price range
|
|
131
|
+
* @param {number} priceHigh Upper bound of the price range
|
|
132
|
+
* @param {boolean} isBid Whether to get bid or ask orders
|
|
133
|
+
* @returns {Promise<{ prices: Array<number>, quantities: Array<number> }>}
|
|
134
|
+
* An object with arrays of prices and quantities
|
|
135
|
+
*/
|
|
136
|
+
getLevel2Range(poolKey: string, priceLow: number, priceHigh: number, isBid: boolean): Promise<{
|
|
137
|
+
prices: number[];
|
|
138
|
+
quantities: number[];
|
|
139
|
+
}>;
|
|
140
|
+
/**
|
|
141
|
+
* @description Get level 2 order book ticks from mid-price for a pool
|
|
142
|
+
* @param {string} poolKey Key of the pool
|
|
143
|
+
* @param {number} ticks Number of ticks from mid-price
|
|
144
|
+
* @returns {Promise<{ bid_prices: Array<number>, bid_quantities: Array<number>, ask_prices: Array<number>, ask_quantities: Array<number> }>}
|
|
145
|
+
* An object with arrays of prices and quantities
|
|
146
|
+
*/
|
|
147
|
+
getLevel2TicksFromMid(poolKey: string, ticks: number): Promise<{
|
|
148
|
+
bid_prices: number[];
|
|
149
|
+
bid_quantities: number[];
|
|
150
|
+
ask_prices: number[];
|
|
151
|
+
ask_quantities: number[];
|
|
152
|
+
}>;
|
|
153
|
+
/**
|
|
154
|
+
* @description Get the vault balances for a pool
|
|
155
|
+
* @param {string} poolKey Key of the pool
|
|
156
|
+
* @returns {Promise<{ base: number, quote: number, deep: number }>}
|
|
157
|
+
* An object with base, quote, and deep balances in the vault
|
|
158
|
+
*/
|
|
159
|
+
vaultBalances(poolKey: string): Promise<{
|
|
160
|
+
base: number;
|
|
161
|
+
quote: number;
|
|
162
|
+
deep: number;
|
|
163
|
+
}>;
|
|
164
|
+
/**
|
|
165
|
+
* @description Get the pool ID by asset types
|
|
166
|
+
* @param {string} baseType Type of the base asset
|
|
167
|
+
* @param {string} quoteType Type of the quote asset
|
|
168
|
+
* @returns {Promise<string>} The address of the pool
|
|
169
|
+
*/
|
|
170
|
+
getPoolIdByAssets(baseType: string, quoteType: string): Promise<string>;
|
|
171
|
+
/**
|
|
172
|
+
* @description Get the mid price for a pool
|
|
173
|
+
* @param {string} poolKey Key of the pool
|
|
174
|
+
* @returns {Promise<number>} The mid price
|
|
175
|
+
*/
|
|
176
|
+
midPrice(poolKey: string): Promise<number>;
|
|
177
|
+
}
|