@decibeltrade/sdk 0.1.5 → 0.1.7
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/dist/abi/generate-abis.js +9 -44
- package/dist/abi/json/netna.json +160 -158
- package/dist/abi/json/testnet.json +15 -3
- package/dist/abi/types.js +1 -2
- package/dist/admin.js +10 -14
- package/dist/base.js +19 -26
- package/dist/constants.js +35 -42
- package/dist/fee-pay.d.ts.map +1 -1
- package/dist/fee-pay.js +4 -24
- package/dist/gas/gas-price-manager.js +3 -7
- package/dist/index.js +10 -26
- package/dist/order-event.types.js +1 -2
- package/dist/order-status.js +16 -23
- package/dist/read/account-overview/account-overview.reader.js +20 -91
- package/dist/read/account-overview/account-overview.types.d.ts +7 -7
- package/dist/read/account-overview/account-overview.types.js +23 -26
- package/dist/read/base-reader.js +5 -9
- package/dist/read/candlesticks/candlesticks.reader.js +24 -95
- package/dist/read/candlesticks/candlesticks.types.js +14 -17
- package/dist/read/delegations/delegations.reader.js +14 -84
- package/dist/read/delegations/delegations.types.js +6 -9
- package/dist/read/index.js +50 -68
- package/dist/read/leaderboard/leaderboard.reader.js +13 -94
- package/dist/read/leaderboard/leaderboard.types.js +10 -13
- package/dist/read/market-contexts/market-contexts.reader.js +16 -83
- package/dist/read/market-contexts/market-contexts.types.js +12 -15
- package/dist/read/market-depth/market-depth.reader.js +29 -101
- package/dist/read/market-depth/market-depth.types.js +8 -11
- package/dist/read/market-prices/market-prices.reader.js +30 -111
- package/dist/read/market-prices/market-prices.types.js +21 -24
- package/dist/read/market-trades/market-trades.reader.js +23 -94
- package/dist/read/market-trades/market-trades.types.js +18 -21
- package/dist/read/markets/markets.reader.js +55 -152
- package/dist/read/markets/markets.types.js +32 -35
- package/dist/read/pagination.types.js +5 -11
- package/dist/read/portfolio-chart/portfolio-chart.reader.js +12 -82
- package/dist/read/portfolio-chart/portfolio-chart.types.js +5 -8
- package/dist/read/types.js +58 -75
- package/dist/read/user-active-twaps/user-active-twaps.reader.js +16 -86
- package/dist/read/user-active-twaps/user-active-twaps.types.js +18 -21
- package/dist/read/user-bulk-orders/user-bulk-orders.reader.js +16 -86
- package/dist/read/user-bulk-orders/user-bulk-orders.types.js +16 -19
- package/dist/read/user-funding-history/user-funding-history.reader.js +16 -86
- package/dist/read/user-funding-history/user-funding-history.types.js +13 -16
- package/dist/read/user-notifications/user-notifications.reader.js +8 -32
- package/dist/read/user-notifications/user-notifications.types.js +19 -22
- package/dist/read/user-open-orders/user-open-orders.reader.js +16 -86
- package/dist/read/user-open-orders/user-open-orders.types.js +27 -30
- package/dist/read/user-order-history/user-order-history.reader.js +18 -88
- package/dist/read/user-order-history/user-order-history.types.js +29 -32
- package/dist/read/user-positions/user-positions.reader.js +24 -95
- package/dist/read/user-positions/user-positions.types.d.ts +15 -15
- package/dist/read/user-positions/user-positions.types.js +22 -25
- package/dist/read/user-subaccounts/user-subaccounts.reader.js +18 -89
- package/dist/read/user-subaccounts/user-subaccounts.types.js +8 -11
- package/dist/read/user-trade-history/user-trade-history.reader.js +16 -86
- package/dist/read/user-trade-history/user-trade-history.types.js +18 -21
- package/dist/read/vaults/vaults.reader.js +45 -150
- package/dist/read/vaults/vaults.types.js +52 -55
- package/dist/read/ws-subscription.js +10 -17
- package/dist/subaccount-types.js +4 -7
- package/dist/transaction-builder.js +15 -23
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils.js +28 -42
- package/dist/write.js +20 -24
- package/package.json +4 -3
- package/tsconfig.json +4 -1
|
@@ -1,99 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
28
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.UserFundingHistoryReader = void 0;
|
|
55
|
-
var base_reader_1 = require("../base-reader");
|
|
56
|
-
var user_funding_history_types_1 = require("./user-funding-history.types");
|
|
57
|
-
var UserFundingHistoryReader = /** @class */ (function (_super) {
|
|
58
|
-
__extends(UserFundingHistoryReader, _super);
|
|
59
|
-
function UserFundingHistoryReader() {
|
|
60
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
61
|
-
}
|
|
1
|
+
import { BaseReader } from "../base-reader";
|
|
2
|
+
import { UserFundingHistorySchema, UserFundingHistoryWsMessageSchema, } from "./user-funding-history.types";
|
|
3
|
+
export class UserFundingHistoryReader extends BaseReader {
|
|
62
4
|
/**
|
|
63
5
|
* Get the trade history for a given user
|
|
64
6
|
* @param subAddr The subaccount address of the user to get trade history for
|
|
65
7
|
* @param limit The number of trades to get (default: 10)
|
|
66
8
|
* @returns The trade history for the given user
|
|
67
9
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
case 0: return [4 /*yield*/, this.getRequest({
|
|
75
|
-
schema: user_funding_history_types_1.UserFundingHistorySchema,
|
|
76
|
-
url: "".concat(this.deps.config.tradingHttpUrl, "/api/v1/funding_rate_history"),
|
|
77
|
-
queryParams: { user: subAddr, limit: limit.toString() },
|
|
78
|
-
options: fetchOptions,
|
|
79
|
-
})];
|
|
80
|
-
case 1:
|
|
81
|
-
response = _d.sent();
|
|
82
|
-
return [2 /*return*/, response.data];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
10
|
+
async getByAddr({ subAddr, limit = 10, fetchOptions }) {
|
|
11
|
+
const response = await this.getRequest({
|
|
12
|
+
schema: UserFundingHistorySchema,
|
|
13
|
+
url: `${this.deps.config.tradingHttpUrl}/api/v1/funding_rate_history`,
|
|
14
|
+
queryParams: { user: subAddr, limit: limit.toString() },
|
|
15
|
+
options: fetchOptions,
|
|
85
16
|
});
|
|
86
|
-
|
|
17
|
+
return response.data;
|
|
18
|
+
}
|
|
87
19
|
/**
|
|
88
20
|
* Subscribe to trade history updates
|
|
89
21
|
* @param subAddr The subaccount address of the user to subscribe to
|
|
90
22
|
* @param onData Callback function for received trade history data
|
|
91
23
|
* @returns A function to unsubscribe from the trade history updates
|
|
92
24
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return this.deps.ws.subscribe(topic,
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
}(base_reader_1.BaseReader));
|
|
99
|
-
exports.UserFundingHistoryReader = UserFundingHistoryReader;
|
|
25
|
+
subscribeByAddr(subAddr, onData) {
|
|
26
|
+
const topic = `user_funding_rate_history:${subAddr}`;
|
|
27
|
+
return this.deps.ws.subscribe(topic, UserFundingHistoryWsMessageSchema, onData);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
is_rebate: v4_1.default.boolean(),
|
|
12
|
-
fee_amount: v4_1.default.number(),
|
|
13
|
-
transaction_unix_ms: v4_1.default.number(),
|
|
1
|
+
import z from "zod/v4";
|
|
2
|
+
export const UserFundingSchema = z.object({
|
|
3
|
+
market: z.string(),
|
|
4
|
+
action: z.string(),
|
|
5
|
+
size: z.number(),
|
|
6
|
+
is_funding_positive: z.boolean(),
|
|
7
|
+
realized_funding_amount: z.number(),
|
|
8
|
+
is_rebate: z.boolean(),
|
|
9
|
+
fee_amount: z.number(),
|
|
10
|
+
transaction_unix_ms: z.number(),
|
|
14
11
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
funding_history:
|
|
12
|
+
export const UserFundingHistorySchema = z.array(UserFundingSchema);
|
|
13
|
+
export const UserFundingHistoryWsMessageSchema = z.object({
|
|
14
|
+
funding_history: UserFundingHistorySchema,
|
|
18
15
|
});
|
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.UserNotificationsReader = void 0;
|
|
19
|
-
var base_reader_1 = require("../base-reader");
|
|
20
|
-
var user_notifications_types_1 = require("./user-notifications.types");
|
|
21
|
-
var UserNotificationsReader = /** @class */ (function (_super) {
|
|
22
|
-
__extends(UserNotificationsReader, _super);
|
|
23
|
-
function UserNotificationsReader() {
|
|
24
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
25
|
-
}
|
|
1
|
+
import { BaseReader } from "../base-reader";
|
|
2
|
+
import { UserNotificationSchema } from "./user-notifications.types";
|
|
3
|
+
export class UserNotificationsReader extends BaseReader {
|
|
26
4
|
/**
|
|
27
5
|
* Subscribe to user positions updates
|
|
28
6
|
* @param subAddr The subaccount address of the user to subscribe to
|
|
@@ -30,10 +8,8 @@ var UserNotificationsReader = /** @class */ (function (_super) {
|
|
|
30
8
|
* @param onData Callback function for received user positions data
|
|
31
9
|
* @returns A function to unsubscribe from the user positions updates
|
|
32
10
|
*/
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return this.deps.ws.subscribe(topic,
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
}(base_reader_1.BaseReader));
|
|
39
|
-
exports.UserNotificationsReader = UserNotificationsReader;
|
|
11
|
+
subscribeByAddr(subAddr, onData) {
|
|
12
|
+
const topic = `notifications:${subAddr}`;
|
|
13
|
+
return this.deps.ws.subscribe(topic, UserNotificationSchema, onData);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var v4_1 = require("zod/v4");
|
|
5
|
-
var user_active_twaps_types_1 = require("../user-active-twaps/user-active-twaps.types");
|
|
6
|
-
var user_order_history_types_1 = require("../user-order-history/user-order-history.types");
|
|
1
|
+
import z from "zod/v4";
|
|
2
|
+
import { UserActiveTwapSchema } from "../user-active-twaps/user-active-twaps.types";
|
|
3
|
+
import { UserOrderSchema } from "../user-order-history/user-order-history.types";
|
|
7
4
|
// from /rust/trading-api-dto/src/notification.rs
|
|
8
|
-
var NotificationType;
|
|
5
|
+
export var NotificationType;
|
|
9
6
|
(function (NotificationType) {
|
|
10
7
|
NotificationType["MarketOrderPlaced"] = "MarketOrderPlaced";
|
|
11
8
|
NotificationType["LimitOrderPlaced"] = "LimitOrderPlaced";
|
|
@@ -31,8 +28,8 @@ var NotificationType;
|
|
|
31
28
|
NotificationType["SlHit"] = "SlHit";
|
|
32
29
|
NotificationType["TpCancelled"] = "TpCancelled";
|
|
33
30
|
NotificationType["SlCancelled"] = "SlCancelled";
|
|
34
|
-
})(NotificationType || (
|
|
35
|
-
var ClientNotificationType;
|
|
31
|
+
})(NotificationType || (NotificationType = {}));
|
|
32
|
+
export var ClientNotificationType;
|
|
36
33
|
(function (ClientNotificationType) {
|
|
37
34
|
ClientNotificationType["TwapPlaced"] = "TwapPlaced";
|
|
38
35
|
ClientNotificationType["OrderCancellationPlaced"] = "OrderCancellationPlaced";
|
|
@@ -41,19 +38,19 @@ var ClientNotificationType;
|
|
|
41
38
|
ClientNotificationType["OrderCancellationErrored"] = "OrderCancellationErrored";
|
|
42
39
|
ClientNotificationType["PositionCancellationErrored"] = "PositionCancellationErrored";
|
|
43
40
|
ClientNotificationType["TwapCancellationErrored"] = "TwapCancellationErrored";
|
|
44
|
-
})(ClientNotificationType || (
|
|
45
|
-
|
|
46
|
-
trigger_price:
|
|
47
|
-
reason:
|
|
48
|
-
amount:
|
|
49
|
-
filled_size:
|
|
41
|
+
})(ClientNotificationType || (ClientNotificationType = {}));
|
|
42
|
+
export const NotificationMetadataSchema = z.object({
|
|
43
|
+
trigger_price: z.number().optional(),
|
|
44
|
+
reason: z.string().optional(),
|
|
45
|
+
amount: z.number().optional(),
|
|
46
|
+
filled_size: z.number().optional(),
|
|
50
47
|
});
|
|
51
|
-
|
|
52
|
-
notification:
|
|
53
|
-
account:
|
|
54
|
-
notification_metadata:
|
|
55
|
-
notification_type:
|
|
56
|
-
order:
|
|
57
|
-
twap:
|
|
48
|
+
export const UserNotificationSchema = z.object({
|
|
49
|
+
notification: z.object({
|
|
50
|
+
account: z.string(),
|
|
51
|
+
notification_metadata: NotificationMetadataSchema.optional(),
|
|
52
|
+
notification_type: z.enum(NotificationType),
|
|
53
|
+
order: UserOrderSchema.optional(),
|
|
54
|
+
twap: UserActiveTwapSchema.optional(),
|
|
58
55
|
}),
|
|
59
56
|
});
|
|
@@ -1,98 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
28
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.UserOpenOrdersReader = void 0;
|
|
55
|
-
var base_reader_1 = require("../base-reader");
|
|
56
|
-
var user_open_orders_types_1 = require("./user-open-orders.types");
|
|
57
|
-
var UserOpenOrdersReader = /** @class */ (function (_super) {
|
|
58
|
-
__extends(UserOpenOrdersReader, _super);
|
|
59
|
-
function UserOpenOrdersReader() {
|
|
60
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
61
|
-
}
|
|
1
|
+
import { BaseReader } from "../base-reader";
|
|
2
|
+
import { UserOpenOrdersSchema, UserOpenOrdersWsMessageSchema, } from "./user-open-orders.types";
|
|
3
|
+
export class UserOpenOrdersReader extends BaseReader {
|
|
62
4
|
/**
|
|
63
5
|
* Get the open orders for a given user
|
|
64
6
|
* @param subAddr The subaccount address of the user to get open orders for
|
|
65
7
|
* @returns The open orders for the given user
|
|
66
8
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
case 0: return [4 /*yield*/, this.getRequest({
|
|
74
|
-
schema: user_open_orders_types_1.UserOpenOrdersSchema,
|
|
75
|
-
url: "".concat(this.deps.config.tradingHttpUrl, "/api/v1/open_orders"),
|
|
76
|
-
queryParams: { user: subAddr },
|
|
77
|
-
options: fetchOptions,
|
|
78
|
-
})];
|
|
79
|
-
case 1:
|
|
80
|
-
response = _c.sent();
|
|
81
|
-
return [2 /*return*/, response.data];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
9
|
+
async getByAddr({ subAddr, fetchOptions }) {
|
|
10
|
+
const response = await this.getRequest({
|
|
11
|
+
schema: UserOpenOrdersSchema,
|
|
12
|
+
url: `${this.deps.config.tradingHttpUrl}/api/v1/open_orders`,
|
|
13
|
+
queryParams: { user: subAddr },
|
|
14
|
+
options: fetchOptions,
|
|
84
15
|
});
|
|
85
|
-
|
|
16
|
+
return response.data;
|
|
17
|
+
}
|
|
86
18
|
/**
|
|
87
19
|
* Subscribe to user orders updates
|
|
88
20
|
* @param subAddr The subaccount address of the user to subscribe to
|
|
89
21
|
* @param onData Callback function for received user orders data
|
|
90
22
|
* @returns A function to unsubscribe from the user orders updates
|
|
91
23
|
*/
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return this.deps.ws.subscribe(topic,
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
}(base_reader_1.BaseReader));
|
|
98
|
-
exports.UserOpenOrdersReader = UserOpenOrdersReader;
|
|
24
|
+
subscribeByAddr(subAddr, onData) {
|
|
25
|
+
const topic = `user_open_orders:${subAddr}`;
|
|
26
|
+
return this.deps.ws.subscribe(topic, UserOpenOrdersWsMessageSchema, onData);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,32 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
trigger_condition: v4_1.default.string().optional(),
|
|
26
|
-
order_direction: v4_1.default.string().optional(),
|
|
27
|
-
is_reduce_only: v4_1.default.boolean().optional(),
|
|
1
|
+
import z from "zod/v4";
|
|
2
|
+
export const UserOpenOrderSchema = z.object({
|
|
3
|
+
parent: z.string(),
|
|
4
|
+
market: z.string(),
|
|
5
|
+
order_id: z.string(),
|
|
6
|
+
client_order_id: z.string().nullable(),
|
|
7
|
+
orig_size: z.number().nullable(),
|
|
8
|
+
remaining_size: z.number().nullable(),
|
|
9
|
+
size_delta: z.number().nullable(),
|
|
10
|
+
price: z.number().nullable(),
|
|
11
|
+
is_buy: z.boolean(),
|
|
12
|
+
details: z.string(),
|
|
13
|
+
transaction_version: z.number(),
|
|
14
|
+
unix_ms: z.number(),
|
|
15
|
+
tp_order_id: z.string().nullable(),
|
|
16
|
+
tp_trigger_price: z.number().nullable(),
|
|
17
|
+
tp_limit_price: z.number().nullable(),
|
|
18
|
+
sl_order_id: z.string().nullable(),
|
|
19
|
+
sl_trigger_price: z.number().nullable(),
|
|
20
|
+
sl_limit_price: z.number().nullable(),
|
|
21
|
+
order_type: z.string().optional(),
|
|
22
|
+
trigger_condition: z.string().optional(),
|
|
23
|
+
order_direction: z.string().optional(),
|
|
24
|
+
is_reduce_only: z.boolean().optional(),
|
|
28
25
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
orders:
|
|
26
|
+
export const UserOpenOrdersSchema = z.array(UserOpenOrderSchema);
|
|
27
|
+
export const UserOpenOrdersWsMessageSchema = z.object({
|
|
28
|
+
orders: z.array(UserOpenOrderSchema),
|
|
32
29
|
});
|
|
@@ -1,95 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
28
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
-
exports.UserOrderHistoryReader = void 0;
|
|
55
|
-
var base_reader_1 = require("../base-reader");
|
|
56
|
-
var user_order_history_types_1 = require("./user-order-history.types");
|
|
57
|
-
var UserOrderHistoryReader = /** @class */ (function (_super) {
|
|
58
|
-
__extends(UserOrderHistoryReader, _super);
|
|
59
|
-
function UserOrderHistoryReader() {
|
|
60
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
61
|
-
}
|
|
62
|
-
UserOrderHistoryReader.prototype.getByAddr = function (_a) {
|
|
63
|
-
return __awaiter(this, arguments, void 0, function (_b) {
|
|
64
|
-
var response;
|
|
65
|
-
var subAddr = _b.subAddr, fetchOptions = _b.fetchOptions;
|
|
66
|
-
return __generator(this, function (_c) {
|
|
67
|
-
switch (_c.label) {
|
|
68
|
-
case 0: return [4 /*yield*/, this.getRequest({
|
|
69
|
-
schema: user_order_history_types_1.UserOrdersSchema,
|
|
70
|
-
url: "".concat(this.deps.config.tradingHttpUrl, "/api/v1/order_history"),
|
|
71
|
-
queryParams: {
|
|
72
|
-
user: subAddr,
|
|
73
|
-
},
|
|
74
|
-
options: fetchOptions,
|
|
75
|
-
})];
|
|
76
|
-
case 1:
|
|
77
|
-
response = _c.sent();
|
|
78
|
-
return [2 /*return*/, response.data];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
1
|
+
import { BaseReader } from "../base-reader";
|
|
2
|
+
import { UserOrdersSchema, UserOrdersWsMessageSchema, } from "./user-order-history.types";
|
|
3
|
+
export class UserOrderHistoryReader extends BaseReader {
|
|
4
|
+
async getByAddr({ subAddr, fetchOptions }) {
|
|
5
|
+
const response = await this.getRequest({
|
|
6
|
+
schema: UserOrdersSchema,
|
|
7
|
+
url: `${this.deps.config.tradingHttpUrl}/api/v1/order_history`,
|
|
8
|
+
queryParams: {
|
|
9
|
+
user: subAddr,
|
|
10
|
+
},
|
|
11
|
+
options: fetchOptions,
|
|
81
12
|
});
|
|
82
|
-
|
|
13
|
+
return response.data;
|
|
14
|
+
}
|
|
83
15
|
/**
|
|
84
16
|
* Subscribe to user order history updates
|
|
85
17
|
* @param subAddr The subaccount address of the user to subscribe to
|
|
86
18
|
* @param onData Callback function for received user order history data
|
|
87
19
|
* @returns A function to unsubscribe from the user order history updates
|
|
88
20
|
*/
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return this.deps.ws.subscribe(topic,
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
}(base_reader_1.BaseReader));
|
|
95
|
-
exports.UserOrderHistoryReader = UserOrderHistoryReader;
|
|
21
|
+
subscribeByAddr(subAddr, onData) {
|
|
22
|
+
const topic = `user_order_history:${subAddr}`;
|
|
23
|
+
return this.deps.ws.subscribe(topic, UserOrdersWsMessageSchema, onData);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
sl_limit_price: v4_1.default.number().nullable(),
|
|
28
|
-
transaction_version: v4_1.default.number(),
|
|
29
|
-
unix_ms: v4_1.default.number(),
|
|
1
|
+
import z from "zod/v4";
|
|
2
|
+
import { PaginatedResponseSchema } from "../pagination.types";
|
|
3
|
+
export const UserOrderSchema = z.object({
|
|
4
|
+
parent: z.string(),
|
|
5
|
+
market: z.string(),
|
|
6
|
+
client_order_id: z.string(),
|
|
7
|
+
order_id: z.string(),
|
|
8
|
+
status: z.string(),
|
|
9
|
+
order_type: z.string(),
|
|
10
|
+
trigger_condition: z.string(),
|
|
11
|
+
order_direction: z.string(),
|
|
12
|
+
orig_size: z.number(),
|
|
13
|
+
remaining_size: z.number(),
|
|
14
|
+
size_delta: z.number(),
|
|
15
|
+
price: z.number(),
|
|
16
|
+
is_buy: z.boolean(),
|
|
17
|
+
is_reduce_only: z.boolean(),
|
|
18
|
+
details: z.string(),
|
|
19
|
+
tp_order_id: z.string().nullable(),
|
|
20
|
+
tp_trigger_price: z.number().nullable(),
|
|
21
|
+
tp_limit_price: z.number().nullable(),
|
|
22
|
+
sl_order_id: z.string().nullable(),
|
|
23
|
+
sl_trigger_price: z.number().nullable(),
|
|
24
|
+
sl_limit_price: z.number().nullable(),
|
|
25
|
+
transaction_version: z.number(),
|
|
26
|
+
unix_ms: z.number(),
|
|
30
27
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
orders:
|
|
28
|
+
export const UserOrdersSchema = PaginatedResponseSchema(UserOrderSchema);
|
|
29
|
+
export const UserOrdersWsMessageSchema = z.object({
|
|
30
|
+
orders: z.array(UserOrderSchema),
|
|
34
31
|
});
|