@decibeltrade/sdk 0.2.5 → 0.2.6
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/.github/workflows/npm_publish.yml +26 -0
- package/dist/base.d.ts +4 -2
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +40 -49
- package/dist/constants.d.ts +2 -11
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +21 -29
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/read/account-overview/account-overview.reader.d.ts +2 -1
- package/dist/read/account-overview/account-overview.reader.d.ts.map +1 -1
- package/dist/read/account-overview/account-overview.reader.js +4 -3
- package/dist/read/account-overview/account-overview.types.d.ts +10 -7
- package/dist/read/account-overview/account-overview.types.d.ts.map +1 -1
- package/dist/read/account-overview/account-overview.types.js +1 -0
- package/dist/read/index.d.ts +9 -2
- package/dist/read/index.d.ts.map +1 -1
- package/dist/read/index.js +18 -2
- package/dist/read/types.d.ts +1 -0
- package/dist/read/types.d.ts.map +1 -1
- package/dist/read/user-positions/user-positions.types.d.ts +14 -14
- package/dist/read/ws-subscription.js +1 -1
- package/dist/release-config.d.ts +23 -0
- package/dist/release-config.d.ts.map +1 -0
- package/dist/release-config.js +34 -0
- package/dist/transaction-builder.d.ts +1 -0
- package/dist/transaction-builder.d.ts.map +1 -1
- package/dist/transaction-builder.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils.d.ts +2 -4
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +5 -15
- package/dist/write.d.ts.map +1 -1
- package/dist/write.js +3 -3
- package/package.json +33 -25
- package/readme.md +1 -1
- package/src/base.ts +60 -56
- package/src/constants.ts +22 -32
- package/src/index.ts +1 -0
- package/src/read/account-overview/account-overview.reader.ts +8 -4
- package/src/read/account-overview/account-overview.types.ts +2 -0
- package/src/read/index.ts +19 -2
- package/src/read/types.ts +1 -0
- package/src/read/ws-subscription.ts +1 -1
- package/src/release-config.ts +47 -0
- package/src/transaction-builder.ts +2 -1
- package/src/utils.ts +8 -20
- package/src/write.ts +9 -3
- package/.env +0 -2
- package/.turbo/turbo-build.log +0 -4
- package/.turbo/turbo-lint$colon$check.log +0 -5
- package/.turbo/turbo-lint.log +0 -5
|
@@ -59,20 +59,20 @@ export declare const UserPositionWsMessageSchema: z.ZodObject<{
|
|
|
59
59
|
has_fixed_sized_tpsls: z.ZodBoolean;
|
|
60
60
|
};
|
|
61
61
|
keyof: () => z.ZodEnum<{
|
|
62
|
+
user: "user";
|
|
62
63
|
market: "market";
|
|
63
64
|
size: "size";
|
|
64
|
-
user: "user";
|
|
65
|
-
user_leverage: "user_leverage";
|
|
66
|
-
entry_price: "entry_price";
|
|
67
|
-
is_isolated: "is_isolated";
|
|
68
|
-
unrealized_funding: "unrealized_funding";
|
|
69
|
-
estimated_liquidation_price: "estimated_liquidation_price";
|
|
70
65
|
tp_order_id: "tp_order_id";
|
|
71
66
|
tp_trigger_price: "tp_trigger_price";
|
|
72
67
|
tp_limit_price: "tp_limit_price";
|
|
73
68
|
sl_order_id: "sl_order_id";
|
|
74
69
|
sl_trigger_price: "sl_trigger_price";
|
|
75
70
|
sl_limit_price: "sl_limit_price";
|
|
71
|
+
user_leverage: "user_leverage";
|
|
72
|
+
entry_price: "entry_price";
|
|
73
|
+
is_isolated: "is_isolated";
|
|
74
|
+
unrealized_funding: "unrealized_funding";
|
|
75
|
+
estimated_liquidation_price: "estimated_liquidation_price";
|
|
76
76
|
has_fixed_sized_tpsls: "has_fixed_sized_tpsls";
|
|
77
77
|
}>;
|
|
78
78
|
catchall: <T extends z.core.SomeType>(schema: T) => z.ZodObject<{
|
|
@@ -160,7 +160,7 @@ export declare const UserPositionWsMessageSchema: z.ZodObject<{
|
|
|
160
160
|
sl_limit_price: z.ZodNullable<z.ZodNumber>;
|
|
161
161
|
has_fixed_sized_tpsls: z.ZodBoolean;
|
|
162
162
|
}, z.core.$strip>;
|
|
163
|
-
extend: <U extends z.core.$ZodLooseShape & Partial<Record<"
|
|
163
|
+
extend: <U extends z.core.$ZodLooseShape & Partial<Record<"user" | "market" | "size" | "tp_order_id" | "tp_trigger_price" | "tp_limit_price" | "sl_order_id" | "sl_trigger_price" | "sl_limit_price" | "user_leverage" | "entry_price" | "is_isolated" | "unrealized_funding" | "estimated_liquidation_price" | "has_fixed_sized_tpsls", z.core.SomeType>>>(shape: U) => z.ZodObject<(("user" | "market" | "size" | "tp_order_id" | "tp_trigger_price" | "tp_limit_price" | "sl_order_id" | "sl_trigger_price" | "sl_limit_price" | "user_leverage" | "entry_price" | "is_isolated" | "unrealized_funding" | "estimated_liquidation_price" | "has_fixed_sized_tpsls") & keyof U extends never ? {
|
|
164
164
|
market: z.ZodString;
|
|
165
165
|
user: z.ZodString;
|
|
166
166
|
size: z.ZodNumber;
|
|
@@ -193,7 +193,7 @@ export declare const UserPositionWsMessageSchema: z.ZodObject<{
|
|
|
193
193
|
sl_limit_price: z.ZodNullable<z.ZodNumber>;
|
|
194
194
|
has_fixed_sized_tpsls: z.ZodBoolean;
|
|
195
195
|
} extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof U ? never : K]: T_1[K]; } : never) & { [K_1 in keyof U]: U[K_1]; }) extends infer T ? { [k in keyof T]: T[k]; } : never, z.core.$strip>;
|
|
196
|
-
merge: <U extends z.ZodObject>(other: U) => z.ZodObject<(("
|
|
196
|
+
merge: <U extends z.ZodObject>(other: U) => z.ZodObject<(("user" | "market" | "size" | "tp_order_id" | "tp_trigger_price" | "tp_limit_price" | "sl_order_id" | "sl_trigger_price" | "sl_limit_price" | "user_leverage" | "entry_price" | "is_isolated" | "unrealized_funding" | "estimated_liquidation_price" | "has_fixed_sized_tpsls") & keyof U["shape"] extends never ? {
|
|
197
197
|
market: z.ZodString;
|
|
198
198
|
user: z.ZodString;
|
|
199
199
|
size: z.ZodNumber;
|
|
@@ -226,7 +226,7 @@ export declare const UserPositionWsMessageSchema: z.ZodObject<{
|
|
|
226
226
|
sl_limit_price: z.ZodNullable<z.ZodNumber>;
|
|
227
227
|
has_fixed_sized_tpsls: z.ZodBoolean;
|
|
228
228
|
} extends infer T_1 extends z.core.util.SomeObject ? { [K in keyof T_1 as K extends keyof U["shape"] ? never : K]: T_1[K]; } : never) & (U["shape"] extends infer T_2 extends z.core.util.SomeObject ? { [K_1 in keyof T_2]: T_2[K_1]; } : never)) extends infer T ? { [k in keyof T]: T[k]; } : never, U["_zod"]["config"]>;
|
|
229
|
-
pick: <M extends z.core.util.Mask<"
|
|
229
|
+
pick: <M extends z.core.util.Mask<"user" | "market" | "size" | "tp_order_id" | "tp_trigger_price" | "tp_limit_price" | "sl_order_id" | "sl_trigger_price" | "sl_limit_price" | "user_leverage" | "entry_price" | "is_isolated" | "unrealized_funding" | "estimated_liquidation_price" | "has_fixed_sized_tpsls">>(mask: M) => z.ZodObject<Pick<{
|
|
230
230
|
market: z.ZodString;
|
|
231
231
|
user: z.ZodString;
|
|
232
232
|
size: z.ZodNumber;
|
|
@@ -242,8 +242,8 @@ export declare const UserPositionWsMessageSchema: z.ZodObject<{
|
|
|
242
242
|
sl_trigger_price: z.ZodNullable<z.ZodNumber>;
|
|
243
243
|
sl_limit_price: z.ZodNullable<z.ZodNumber>;
|
|
244
244
|
has_fixed_sized_tpsls: z.ZodBoolean;
|
|
245
|
-
}, Extract<"
|
|
246
|
-
omit: <M extends z.core.util.Mask<"
|
|
245
|
+
}, Extract<"user", keyof M> | Extract<"market", keyof M> | Extract<"size", keyof M> | Extract<"tp_order_id", keyof M> | Extract<"tp_trigger_price", keyof M> | Extract<"tp_limit_price", keyof M> | Extract<"sl_order_id", keyof M> | Extract<"sl_trigger_price", keyof M> | Extract<"sl_limit_price", keyof M> | Extract<"user_leverage", keyof M> | Extract<"entry_price", keyof M> | Extract<"is_isolated", keyof M> | Extract<"unrealized_funding", keyof M> | Extract<"estimated_liquidation_price", keyof M> | Extract<"has_fixed_sized_tpsls", keyof M>> extends infer T ? { [k in keyof T]: T[k]; } : never, z.core.$strip>;
|
|
246
|
+
omit: <M extends z.core.util.Mask<"user" | "market" | "size" | "tp_order_id" | "tp_trigger_price" | "tp_limit_price" | "sl_order_id" | "sl_trigger_price" | "sl_limit_price" | "user_leverage" | "entry_price" | "is_isolated" | "unrealized_funding" | "estimated_liquidation_price" | "has_fixed_sized_tpsls">>(mask: M) => z.ZodObject<Omit<{
|
|
247
247
|
market: z.ZodString;
|
|
248
248
|
user: z.ZodString;
|
|
249
249
|
size: z.ZodNumber;
|
|
@@ -259,7 +259,7 @@ export declare const UserPositionWsMessageSchema: z.ZodObject<{
|
|
|
259
259
|
sl_trigger_price: z.ZodNullable<z.ZodNumber>;
|
|
260
260
|
sl_limit_price: z.ZodNullable<z.ZodNumber>;
|
|
261
261
|
has_fixed_sized_tpsls: z.ZodBoolean;
|
|
262
|
-
}, Extract<"
|
|
262
|
+
}, Extract<"user", keyof M> | Extract<"market", keyof M> | Extract<"size", keyof M> | Extract<"tp_order_id", keyof M> | Extract<"tp_trigger_price", keyof M> | Extract<"tp_limit_price", keyof M> | Extract<"sl_order_id", keyof M> | Extract<"sl_trigger_price", keyof M> | Extract<"sl_limit_price", keyof M> | Extract<"user_leverage", keyof M> | Extract<"entry_price", keyof M> | Extract<"is_isolated", keyof M> | Extract<"unrealized_funding", keyof M> | Extract<"estimated_liquidation_price", keyof M> | Extract<"has_fixed_sized_tpsls", keyof M>> extends infer T ? { [k in keyof T]: T[k]; } : never, z.core.$strip>;
|
|
263
263
|
partial: {
|
|
264
264
|
(): z.ZodObject<{
|
|
265
265
|
market: z.ZodOptional<z.ZodString>;
|
|
@@ -278,7 +278,7 @@ export declare const UserPositionWsMessageSchema: z.ZodObject<{
|
|
|
278
278
|
sl_limit_price: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
279
279
|
has_fixed_sized_tpsls: z.ZodOptional<z.ZodBoolean>;
|
|
280
280
|
}, z.core.$strip>;
|
|
281
|
-
<M extends z.core.util.Mask<"
|
|
281
|
+
<M extends z.core.util.Mask<"user" | "market" | "size" | "tp_order_id" | "tp_trigger_price" | "tp_limit_price" | "sl_order_id" | "sl_trigger_price" | "sl_limit_price" | "user_leverage" | "entry_price" | "is_isolated" | "unrealized_funding" | "estimated_liquidation_price" | "has_fixed_sized_tpsls">>(mask: M): z.ZodObject<{
|
|
282
282
|
market: "market" extends infer T ? T extends "market" ? T extends keyof M ? z.ZodOptional<{
|
|
283
283
|
market: z.ZodString;
|
|
284
284
|
user: z.ZodString;
|
|
@@ -794,7 +794,7 @@ export declare const UserPositionWsMessageSchema: z.ZodObject<{
|
|
|
794
794
|
sl_limit_price: z.ZodNonOptional<z.ZodNullable<z.ZodNumber>>;
|
|
795
795
|
has_fixed_sized_tpsls: z.ZodNonOptional<z.ZodBoolean>;
|
|
796
796
|
}, z.core.$strip>;
|
|
797
|
-
<M extends z.core.util.Mask<"
|
|
797
|
+
<M extends z.core.util.Mask<"user" | "market" | "size" | "tp_order_id" | "tp_trigger_price" | "tp_limit_price" | "sl_order_id" | "sl_trigger_price" | "sl_limit_price" | "user_leverage" | "entry_price" | "is_isolated" | "unrealized_funding" | "estimated_liquidation_price" | "has_fixed_sized_tpsls">>(mask: M): z.ZodObject<{
|
|
798
798
|
market: "market" extends infer T ? T extends "market" ? T extends keyof M ? z.ZodNonOptional<{
|
|
799
799
|
market: z.ZodString;
|
|
800
800
|
user: z.ZodString;
|
|
@@ -42,7 +42,7 @@ export class DecibelWsSubscription {
|
|
|
42
42
|
const ws = new WebSocket(this.config.tradingWsUrl);
|
|
43
43
|
ws.addEventListener("open", () => {
|
|
44
44
|
this.#reconnectAttempts = 0;
|
|
45
|
-
for (const topic of
|
|
45
|
+
for (const topic of this.#subscriptions.keys()) {
|
|
46
46
|
ws.send(this.#getSubscribeMessage(topic));
|
|
47
47
|
}
|
|
48
48
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare enum CompatVersion {
|
|
2
|
+
V0_0 = "v0.0",// decibel-testnet-release-v0.0
|
|
3
|
+
V0_1 = "v0.1",// decibel-testnet-release-v0.1
|
|
4
|
+
V0_2 = "v0.2",// decibel-testnet-release-v0.2
|
|
5
|
+
V0_3 = "v0.3"
|
|
6
|
+
}
|
|
7
|
+
export type SubaccountVariant = "v0" | "v1" | "v2";
|
|
8
|
+
export interface ReleaseConfig {
|
|
9
|
+
compatVersion: CompatVersion;
|
|
10
|
+
subaccountVariant: SubaccountVariant;
|
|
11
|
+
}
|
|
12
|
+
export declare const PACKAGE: {
|
|
13
|
+
NETNA: string;
|
|
14
|
+
TESTNET: string;
|
|
15
|
+
};
|
|
16
|
+
export declare const DEFAULT_COMPAT_VERSION = CompatVersion.V0_3;
|
|
17
|
+
export declare const RELEASE_CONFIGS: {
|
|
18
|
+
NETNA: ReleaseConfig;
|
|
19
|
+
TESTNET: ReleaseConfig;
|
|
20
|
+
LOCAL: ReleaseConfig;
|
|
21
|
+
DOCKER: ReleaseConfig;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=release-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"release-config.d.ts","sourceRoot":"","sources":["../src/release-config.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa;IACvB,IAAI,SAAS,CAAE,+BAA+B;IAC9C,IAAI,SAAS,CAAE,+BAA+B;IAC9C,IAAI,SAAS,CAAE,+BAA+B;IAC9C,IAAI,SAAS;CACd;AAED,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED,eAAO,MAAM,OAAO;;;CAGnB,CAAC;AAEF,eAAO,MAAM,sBAAsB,qBAAqB,CAAC;AAsBzD,eAAO,MAAM,eAAe;;;;;CAK3B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export var CompatVersion;
|
|
2
|
+
(function (CompatVersion) {
|
|
3
|
+
CompatVersion["V0_0"] = "v0.0";
|
|
4
|
+
CompatVersion["V0_1"] = "v0.1";
|
|
5
|
+
CompatVersion["V0_2"] = "v0.2";
|
|
6
|
+
CompatVersion["V0_3"] = "v0.3";
|
|
7
|
+
})(CompatVersion || (CompatVersion = {}));
|
|
8
|
+
export const PACKAGE = {
|
|
9
|
+
NETNA: "0xb8a5788314451ce4d2fbbad32e1bad88d4184b73943b7fe5166eab93cf1a5a95",
|
|
10
|
+
TESTNET: "0x9f830083a19fb8b87395983ca9edaea2b0379c97be6dfe234bb914e6c6672844",
|
|
11
|
+
};
|
|
12
|
+
export const DEFAULT_COMPAT_VERSION = CompatVersion.V0_3;
|
|
13
|
+
const NETNA_RELEASE_CONFIG = {
|
|
14
|
+
compatVersion: DEFAULT_COMPAT_VERSION,
|
|
15
|
+
subaccountVariant: "v2",
|
|
16
|
+
};
|
|
17
|
+
const TESTNET_RELEASE_CONFIG = {
|
|
18
|
+
compatVersion: CompatVersion.V0_2,
|
|
19
|
+
subaccountVariant: "v2",
|
|
20
|
+
};
|
|
21
|
+
const LOCAL_RELEASE_CONFIG = {
|
|
22
|
+
compatVersion: DEFAULT_COMPAT_VERSION,
|
|
23
|
+
subaccountVariant: "v1",
|
|
24
|
+
};
|
|
25
|
+
const DOCKER_RELEASE_CONFIG = {
|
|
26
|
+
compatVersion: DEFAULT_COMPAT_VERSION,
|
|
27
|
+
subaccountVariant: "v1",
|
|
28
|
+
};
|
|
29
|
+
export const RELEASE_CONFIGS = {
|
|
30
|
+
NETNA: NETNA_RELEASE_CONFIG,
|
|
31
|
+
TESTNET: TESTNET_RELEASE_CONFIG,
|
|
32
|
+
LOCAL: LOCAL_RELEASE_CONFIG,
|
|
33
|
+
DOCKER: DOCKER_RELEASE_CONFIG,
|
|
34
|
+
};
|
|
@@ -9,6 +9,7 @@ export declare function buildSimpleTransactionSync(args: {
|
|
|
9
9
|
withFeePayer: boolean;
|
|
10
10
|
replayProtectionNonce: bigint;
|
|
11
11
|
timeDeltaMs?: number;
|
|
12
|
+
maxGasAmount?: number;
|
|
12
13
|
}): SimpleTransaction;
|
|
13
14
|
export declare const generateExpireTimestamp: (aptosConfig: AptosConfig, timeDeltaMs?: number) => number;
|
|
14
15
|
//# sourceMappingURL=transaction-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-builder.d.ts","sourceRoot":"","sources":["../src/transaction-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,WAAW,EAMX,sBAAsB,EAEtB,YAAY,EAGZ,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,YAAY,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"transaction-builder.d.ts","sourceRoot":"","sources":["../src/transaction-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,WAAW,EAMX,sBAAsB,EAEtB,YAAY,EAGZ,iBAAiB,EAElB,MAAM,oBAAoB,CAAC;AAE5B,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,IAAI,EAAE,sBAAsB,CAAC;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,YAAY,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,qBAyBA;AAoBD,eAAO,MAAM,uBAAuB,GAAI,aAAa,WAAW,EAAE,oBAAe,WACY,CAAC"}
|
|
@@ -13,7 +13,7 @@ export function buildSimpleTransactionSync(args) {
|
|
|
13
13
|
// This is an unused value, so it's specifically to show that the sequence number is not used
|
|
14
14
|
BigInt("0xdeadbeef"), convertPayloadToInnerPayload(txnPayload, args.replayProtectionNonce),
|
|
15
15
|
// @Todo: Use gasPriceManager to get the max gas amount [as defaultMaxGasAmount might be very high number]
|
|
16
|
-
BigInt(args.aptosConfig.getDefaultMaxGasAmount()), BigInt(args.gasUnitPrice), BigInt(expireTimestamp), new ChainId(args.chainId));
|
|
16
|
+
BigInt(args.maxGasAmount ?? args.aptosConfig.getDefaultMaxGasAmount()), BigInt(args.gasUnitPrice), BigInt(expireTimestamp), new ChainId(args.chainId));
|
|
17
17
|
return new SimpleTransaction(rawTxn, args.withFeePayer ? AccountAddress.ZERO : undefined);
|
|
18
18
|
}
|
|
19
19
|
const parseMoveFnAbiToEntryFnABI = (functionAbi) => {
|