@yuants/vendor-binance 0.8.7 → 0.10.0
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/api/client.js +14 -5
- package/dist/api/client.js.map +1 -1
- package/dist/api/public-api.js +6 -0
- package/dist/api/public-api.js.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/legacy_index.js +163 -400
- package/dist/legacy_index.js.map +1 -1
- package/dist/public-data/interest_rate.js +5 -3
- package/dist/public-data/interest_rate.js.map +1 -1
- package/dist/public-data/ohlc.js +1 -1
- package/dist/public-data/ohlc.js.map +1 -1
- package/dist/public-data/product.js +83 -4
- package/dist/public-data/product.js.map +1 -1
- package/dist/public-data/quote.js +7 -7
- package/dist/public-data/quote.js.map +1 -1
- package/dist/services/accounts/profile.js +4 -15
- package/dist/services/accounts/profile.js.map +1 -1
- package/dist/services/accounts/spot.js +1 -1
- package/dist/services/accounts/spot.js.map +1 -1
- package/dist/services/accounts/unified.js +2 -12
- package/dist/services/accounts/unified.js.map +1 -1
- package/dist/services/exchange.js +56 -0
- package/dist/services/exchange.js.map +1 -0
- package/dist/services/orders/cancelOrder.js +5 -3
- package/dist/services/orders/cancelOrder.js.map +1 -1
- package/dist/services/orders/listOrders.js +44 -35
- package/dist/services/orders/listOrders.js.map +1 -1
- package/dist/services/orders/modifyOrder.js +6 -3
- package/dist/services/orders/modifyOrder.js.map +1 -1
- package/dist/services/orders/order-utils.js +29 -7
- package/dist/services/orders/order-utils.js.map +1 -1
- package/dist/services/orders/submitOrder.js +5 -3
- package/dist/services/orders/submitOrder.js.map +1 -1
- package/lib/api/client.d.ts.map +1 -1
- package/lib/api/client.js +13 -7
- package/lib/api/client.js.map +1 -1
- package/lib/api/public-api.d.ts +41 -0
- package/lib/api/public-api.d.ts.map +1 -1
- package/lib/api/public-api.js +8 -1
- package/lib/api/public-api.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/legacy_index.d.ts +0 -1
- package/lib/legacy_index.js +162 -401
- package/lib/legacy_index.js.map +1 -1
- package/lib/public-data/interest_rate.js +5 -3
- package/lib/public-data/interest_rate.js.map +1 -1
- package/lib/public-data/ohlc.js +1 -1
- package/lib/public-data/ohlc.js.map +1 -1
- package/lib/public-data/product.d.ts +2 -1
- package/lib/public-data/product.d.ts.map +1 -1
- package/lib/public-data/product.js +84 -3
- package/lib/public-data/product.js.map +1 -1
- package/lib/public-data/quote.js +7 -7
- package/lib/public-data/quote.js.map +1 -1
- package/lib/services/accounts/profile.d.ts +1 -5
- package/lib/services/accounts/profile.d.ts.map +1 -1
- package/lib/services/accounts/profile.js +6 -17
- package/lib/services/accounts/profile.js.map +1 -1
- package/lib/services/accounts/spot.d.ts +2 -2
- package/lib/services/accounts/spot.d.ts.map +1 -1
- package/lib/services/accounts/spot.js +1 -1
- package/lib/services/accounts/spot.js.map +1 -1
- package/lib/services/accounts/unified.d.ts +2 -2
- package/lib/services/accounts/unified.d.ts.map +1 -1
- package/lib/services/accounts/unified.js +2 -12
- package/lib/services/accounts/unified.js.map +1 -1
- package/lib/services/exchange.d.ts +2 -0
- package/lib/services/exchange.d.ts.map +1 -0
- package/lib/services/exchange.js +58 -0
- package/lib/services/exchange.js.map +1 -0
- package/lib/services/orders/cancelOrder.d.ts.map +1 -1
- package/lib/services/orders/cancelOrder.js +5 -3
- package/lib/services/orders/cancelOrder.js.map +1 -1
- package/lib/services/orders/listOrders.d.ts +4 -2
- package/lib/services/orders/listOrders.d.ts.map +1 -1
- package/lib/services/orders/listOrders.js +47 -36
- package/lib/services/orders/listOrders.js.map +1 -1
- package/lib/services/orders/modifyOrder.d.ts.map +1 -1
- package/lib/services/orders/modifyOrder.js +6 -3
- package/lib/services/orders/modifyOrder.js.map +1 -1
- package/lib/services/orders/order-utils.d.ts.map +1 -1
- package/lib/services/orders/order-utils.js +29 -7
- package/lib/services/orders/order-utils.js.map +1 -1
- package/lib/services/orders/submitOrder.d.ts.map +1 -1
- package/lib/services/orders/submitOrder.js +5 -3
- package/lib/services/orders/submitOrder.js.map +1 -1
- package/package.json +2 -1
- package/temp/package-deps.json +23 -24
- package/dist/cli.js +0 -3
- package/dist/cli.js.map +0 -1
- package/dist/services/account-actions-with-credential.js +0 -34
- package/dist/services/account-actions-with-credential.js.map +0 -1
- package/dist/services/order-actions-with-credential.js +0 -21
- package/dist/services/order-actions-with-credential.js.map +0 -1
- package/lib/cli.d.ts +0 -3
- package/lib/cli.d.ts.map +0 -1
- package/lib/cli.js +0 -5
- package/lib/cli.js.map +0 -1
- package/lib/services/account-actions-with-credential.d.ts +0 -2
- package/lib/services/account-actions-with-credential.d.ts.map +0 -1
- package/lib/services/account-actions-with-credential.js +0 -36
- package/lib/services/account-actions-with-credential.js.map +0 -1
- package/lib/services/order-actions-with-credential.d.ts +0 -2
- package/lib/services/order-actions-with-credential.d.ts.map +0 -1
- package/lib/services/order-actions-with-credential.js +0 -23
- package/lib/services/order-actions-with-credential.js.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { provideExchangeServices } from '@yuants/exchange';
|
|
2
|
+
import { Terminal } from '@yuants/protocol';
|
|
3
|
+
import { decodePath } from '@yuants/utils';
|
|
4
|
+
import { listProducts } from '../public-data/product';
|
|
5
|
+
import { getCredentialId } from './accounts/profile';
|
|
6
|
+
import { getSpotAccountInfoSnapshot } from './accounts/spot';
|
|
7
|
+
import { getUnifiedAccountInfo } from './accounts/unified';
|
|
8
|
+
import { cancelOrder } from './orders/cancelOrder';
|
|
9
|
+
import { getOrdersByProductId, listSpotOrders, listUnifiedUmOrders } from './orders/listOrders';
|
|
10
|
+
import { modifyOrder } from './orders/modifyOrder';
|
|
11
|
+
import { submitOrder } from './orders/submitOrder';
|
|
12
|
+
const terminal = Terminal.fromNodeEnv();
|
|
13
|
+
provideExchangeServices(terminal, {
|
|
14
|
+
name: 'BINANCE',
|
|
15
|
+
credentialSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
required: ['access_key', 'secret_key'],
|
|
18
|
+
properties: {
|
|
19
|
+
access_key: { type: 'string' },
|
|
20
|
+
secret_key: { type: 'string' },
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
getCredentialId,
|
|
24
|
+
listProducts,
|
|
25
|
+
getPositions: async function (credential) {
|
|
26
|
+
const [uFuturePositions, spotPositions] = await Promise.all([
|
|
27
|
+
getUnifiedAccountInfo(credential),
|
|
28
|
+
getSpotAccountInfoSnapshot(credential),
|
|
29
|
+
]);
|
|
30
|
+
return [...uFuturePositions, ...spotPositions];
|
|
31
|
+
},
|
|
32
|
+
getOrders: async function (credential) {
|
|
33
|
+
const [umOrders, spotOrders] = await Promise.all([
|
|
34
|
+
listUnifiedUmOrders(credential),
|
|
35
|
+
listSpotOrders(credential),
|
|
36
|
+
]);
|
|
37
|
+
return [...umOrders, ...spotOrders];
|
|
38
|
+
},
|
|
39
|
+
getPositionsByProductId: async function (credential, product_id) {
|
|
40
|
+
const [_, instType] = decodePath(product_id); // BINANCE/USDT-FUTURE/ADAUSDT
|
|
41
|
+
if (instType === 'SPOT') {
|
|
42
|
+
const positions = await getSpotAccountInfoSnapshot(credential);
|
|
43
|
+
return positions.filter((position) => position.product_id === product_id);
|
|
44
|
+
}
|
|
45
|
+
if (instType === 'USDT-FUTURE') {
|
|
46
|
+
const positions = await getUnifiedAccountInfo(credential);
|
|
47
|
+
return positions.filter((position) => position.product_id === product_id);
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`Unsupported instType: ${instType}`);
|
|
50
|
+
},
|
|
51
|
+
getOrdersByProductId,
|
|
52
|
+
submitOrder,
|
|
53
|
+
modifyOrder,
|
|
54
|
+
cancelOrder,
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=exchange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exchange.js","sourceRoot":"","sources":["../../src/services/exchange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,CAAC;IACjD,CAAC;IACD,SAAS,EAAE,KAAK,WAAW,UAAuB;QAChD,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC/C,mBAAmB,CAAC,UAAU,CAAC;YAC/B,cAAc,CAAC,UAAU,CAAC;SAC3B,CAAC,CAAC;QACH,OAAO,CAAC,GAAG,QAAQ,EAAE,GAAG,UAAU,CAAC,CAAC;IACtC,CAAC;IACD,uBAAuB,EAAE,KAAK,WAC5B,UAAuB,EACvB,UAAkB;QAElB,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,8BAA8B;QAC5E,IAAI,QAAQ,KAAK,MAAM,EAAE;YACvB,MAAM,SAAS,GAAG,MAAM,0BAA0B,CAAC,UAAU,CAAC,CAAC;YAC/D,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;SAC3E;QACD,IAAI,QAAQ,KAAK,aAAa,EAAE;YAC9B,MAAM,SAAS,GAAG,MAAM,qBAAqB,CAAC,UAAU,CAAC,CAAC;YAC1D,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;SAC3E;QACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,oBAAoB;IACpB,WAAW;IACX,WAAW;IACX,WAAW;CACZ,CAAC,CAAC","sourcesContent":["import { IPosition } from '@yuants/data-account';\nimport { IOrder } from '@yuants/data-order';\nimport { provideExchangeServices } from '@yuants/exchange';\nimport { Terminal } from '@yuants/protocol';\nimport { decodePath } from '@yuants/utils';\nimport { ICredential } from '../api/client';\nimport { listProducts } from '../public-data/product';\nimport { getCredentialId } from './accounts/profile';\nimport { getSpotAccountInfoSnapshot } from './accounts/spot';\nimport { getUnifiedAccountInfo } from './accounts/unified';\nimport { cancelOrder } from './orders/cancelOrder';\nimport { getOrdersByProductId, listSpotOrders, listUnifiedUmOrders } from './orders/listOrders';\nimport { modifyOrder } from './orders/modifyOrder';\nimport { submitOrder } from './orders/submitOrder';\n\nconst terminal = Terminal.fromNodeEnv();\n\nprovideExchangeServices<ICredential>(terminal, {\n name: 'BINANCE',\n credentialSchema: {\n type: 'object',\n required: ['access_key', 'secret_key'],\n properties: {\n access_key: { type: 'string' },\n secret_key: { type: 'string' },\n },\n },\n getCredentialId,\n listProducts,\n getPositions: async function (credential: ICredential): Promise<IPosition[]> {\n const [uFuturePositions, spotPositions] = await Promise.all([\n getUnifiedAccountInfo(credential),\n getSpotAccountInfoSnapshot(credential),\n ]);\n return [...uFuturePositions, ...spotPositions];\n },\n getOrders: async function (credential: ICredential): Promise<IOrder[]> {\n const [umOrders, spotOrders] = await Promise.all([\n listUnifiedUmOrders(credential),\n listSpotOrders(credential),\n ]);\n return [...umOrders, ...spotOrders];\n },\n getPositionsByProductId: async function (\n credential: ICredential,\n product_id: string,\n ): Promise<IPosition[]> {\n const [_, instType] = decodePath(product_id); // BINANCE/USDT-FUTURE/ADAUSDT\n if (instType === 'SPOT') {\n const positions = await getSpotAccountInfoSnapshot(credential);\n return positions.filter((position) => position.product_id === product_id);\n }\n if (instType === 'USDT-FUTURE') {\n const positions = await getUnifiedAccountInfo(credential);\n return positions.filter((position) => position.product_id === product_id);\n }\n throw new Error(`Unsupported instType: ${instType}`);\n },\n getOrdersByProductId,\n submitOrder,\n modifyOrder,\n cancelOrder,\n});\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isApiError } from '../../api/client';
|
|
2
2
|
import { deleteSpotOrder, deleteUmOrder } from '../../api/private-api';
|
|
3
3
|
import { decodeFutureSymbol, decodeSpotSymbol } from './order-utils';
|
|
4
|
+
import { decodePath, newError } from '@yuants/utils';
|
|
4
5
|
const cancelUnifiedOrder = async (credential, order) => {
|
|
5
6
|
if (!order.order_id) {
|
|
6
7
|
throw new Error('Binance cancelOrder requires order_id');
|
|
@@ -28,12 +29,13 @@ const cancelSpotOrder = async (credential, order) => {
|
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
31
|
export const cancelOrder = async (credential, order) => {
|
|
31
|
-
|
|
32
|
+
const [, TYPE] = decodePath(order.product_id);
|
|
33
|
+
if (TYPE === 'USDT-FUTURE') {
|
|
32
34
|
return cancelUnifiedOrder(credential, order);
|
|
33
35
|
}
|
|
34
|
-
if (
|
|
36
|
+
if (TYPE === 'SPOT') {
|
|
35
37
|
return cancelSpotOrder(credential, order);
|
|
36
38
|
}
|
|
37
|
-
throw
|
|
39
|
+
throw newError('BINANCE_CANCEL_ORDER_UNSUPPORTED_PRODUCT_TYPE', { order });
|
|
38
40
|
};
|
|
39
41
|
//# sourceMappingURL=cancelOrder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cancelOrder.js","sourceRoot":"","sources":["../../../src/services/orders/cancelOrder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAe,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"cancelOrder.js","sourceRoot":"","sources":["../../../src/services/orders/cancelOrder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAe,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,kBAAkB,GAA6C,KAAK,EAAE,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AC,UAAU,EAAE,KAAK,CAAC,CAAC;KAC9C;IACD,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,OAAO,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;KAC3C;IACD,MAAM,QAAQ,CAAC,+CAA+C,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC","sourcesContent":["import { IActionHandlerOfCancelOrder } from '@yuants/data-order';\nimport { isApiError } from '../../api/client';\nimport { deleteSpotOrder, deleteUmOrder, ICredential } from '../../api/private-api';\nimport { decodeFutureSymbol, decodeSpotSymbol } from './order-utils';\nimport { decodePath, newError } from '@yuants/utils';\n\nconst cancelUnifiedOrder: IActionHandlerOfCancelOrder<ICredential> = async (credential, order) => {\n if (!order.order_id) {\n throw new Error('Binance cancelOrder requires order_id');\n }\n const symbol = decodeFutureSymbol(order.product_id);\n const res = await deleteUmOrder(credential, {\n symbol,\n orderId: order.order_id,\n });\n if (isApiError(res)) {\n throw new Error(`Binance cancel unified order failed: ${res.code} ${res.msg}`);\n }\n};\n\nconst cancelSpotOrder: IActionHandlerOfCancelOrder<ICredential> = async (credential, order) => {\n if (!order.order_id) {\n throw new Error('Binance cancelOrder requires order_id');\n }\n const symbol = decodeSpotSymbol(order.product_id);\n const res = await deleteSpotOrder(credential, {\n symbol,\n orderId: order.order_id,\n });\n if (isApiError(res)) {\n throw new Error(`Binance cancel spot order failed: ${res.code} ${res.msg}`);\n }\n};\n\nexport const cancelOrder: IActionHandlerOfCancelOrder<ICredential> = async (credential, order) => {\n const [, TYPE] = decodePath(order.product_id);\n if (TYPE === 'USDT-FUTURE') {\n return cancelUnifiedOrder(credential, order);\n }\n if (TYPE === 'SPOT') {\n return cancelSpotOrder(credential, order);\n }\n throw newError('BINANCE_CANCEL_ORDER_UNSUPPORTED_PRODUCT_TYPE', { order });\n};\n"]}
|
|
@@ -1,49 +1,58 @@
|
|
|
1
|
-
import { encodePath, formatTime } from '@yuants/utils';
|
|
1
|
+
import { decodePath, encodePath, formatTime } from '@yuants/utils';
|
|
2
2
|
import { isApiError } from '../../api/client';
|
|
3
3
|
import { getSpotOpenOrders, getUnifiedUmOpenOrders } from '../../api/private-api';
|
|
4
4
|
import { mapBinanceOrderStatus, mapBinanceOrderTypeToYuants, mapBinanceSideToYuantsDirection, mapSpotSideToOrderDirection, } from './order-utils';
|
|
5
|
-
export const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
throw new Error(res.msg);
|
|
10
|
-
}
|
|
11
|
-
return res.map((order) => {
|
|
12
|
-
var _a;
|
|
13
|
-
return ({
|
|
14
|
-
order_id: `${order.orderId}`,
|
|
15
|
-
account_id,
|
|
16
|
-
product_id: encodePath('usdt-future', order.symbol),
|
|
17
|
-
order_type: mapBinanceOrderTypeToYuants(order.type),
|
|
18
|
-
order_direction: (_a = mapBinanceSideToYuantsDirection(order.side, order.positionSide)) !== null && _a !== void 0 ? _a : (order.side === 'BUY' ? 'OPEN_LONG' : 'OPEN_SHORT'),
|
|
19
|
-
volume: +order.origQty,
|
|
20
|
-
traded_volume: +order.executedQty,
|
|
21
|
-
price: order.price === undefined ? undefined : +order.price,
|
|
22
|
-
submit_at: order.time,
|
|
23
|
-
updated_at: formatTime(order.updateTime),
|
|
24
|
-
order_status: mapBinanceOrderStatus(order.status),
|
|
25
|
-
});
|
|
26
|
-
});
|
|
5
|
+
export const listUnifiedUmOrders = async (credential) => {
|
|
6
|
+
const res = await getUnifiedUmOpenOrders(credential);
|
|
7
|
+
if (isApiError(res)) {
|
|
8
|
+
throw new Error(res.msg);
|
|
27
9
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
throw new Error(res.msg);
|
|
32
|
-
}
|
|
33
|
-
return res.map((order) => ({
|
|
10
|
+
return res.map((order) => {
|
|
11
|
+
var _a;
|
|
12
|
+
return ({
|
|
34
13
|
order_id: `${order.orderId}`,
|
|
35
|
-
account_id,
|
|
36
|
-
product_id: encodePath('
|
|
14
|
+
account_id: '',
|
|
15
|
+
product_id: encodePath('BINANCE', 'USDT-FUTURE', order.symbol),
|
|
37
16
|
order_type: mapBinanceOrderTypeToYuants(order.type),
|
|
38
|
-
order_direction:
|
|
17
|
+
order_direction: (_a = mapBinanceSideToYuantsDirection(order.side, order.positionSide)) !== null && _a !== void 0 ? _a : (order.side === 'BUY' ? 'OPEN_LONG' : 'OPEN_SHORT'),
|
|
39
18
|
volume: +order.origQty,
|
|
40
19
|
traded_volume: +order.executedQty,
|
|
41
|
-
price: order.price ? +order.price
|
|
20
|
+
price: order.price === undefined ? undefined : +order.price,
|
|
42
21
|
submit_at: order.time,
|
|
43
22
|
updated_at: formatTime(order.updateTime),
|
|
44
23
|
order_status: mapBinanceOrderStatus(order.status),
|
|
45
|
-
})
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export const listSpotOrders = async (credential) => {
|
|
28
|
+
const res = await getSpotOpenOrders(credential);
|
|
29
|
+
if (isApiError(res)) {
|
|
30
|
+
throw new Error(res.msg);
|
|
31
|
+
}
|
|
32
|
+
return res.map((order) => ({
|
|
33
|
+
order_id: `${order.orderId}`,
|
|
34
|
+
account_id: '',
|
|
35
|
+
product_id: encodePath('BINANCE', 'SPOT', order.symbol),
|
|
36
|
+
order_type: mapBinanceOrderTypeToYuants(order.type),
|
|
37
|
+
order_direction: mapSpotSideToOrderDirection(order.side),
|
|
38
|
+
volume: +order.origQty,
|
|
39
|
+
traded_volume: +order.executedQty,
|
|
40
|
+
price: order.price === undefined ? undefined : +order.price,
|
|
41
|
+
submit_at: order.time,
|
|
42
|
+
updated_at: formatTime(order.updateTime),
|
|
43
|
+
order_status: mapBinanceOrderStatus(order.status),
|
|
44
|
+
}));
|
|
45
|
+
};
|
|
46
|
+
export const getOrdersByProductId = async function (credential, product_id) {
|
|
47
|
+
const [_, instType] = decodePath(product_id); // BINANCE/USDT-FUTURE/ADAUSDT
|
|
48
|
+
if (instType === 'SPOT') {
|
|
49
|
+
const orders = await listSpotOrders(credential);
|
|
50
|
+
return orders.filter((order) => order.product_id === product_id);
|
|
51
|
+
}
|
|
52
|
+
if (instType === 'USDT-FUTURE') {
|
|
53
|
+
const orders = await listUnifiedUmOrders(credential);
|
|
54
|
+
return orders.filter((order) => order.product_id === product_id);
|
|
46
55
|
}
|
|
47
|
-
throw new Error(`Unsupported
|
|
56
|
+
throw new Error(`Unsupported instType: ${instType}`);
|
|
48
57
|
};
|
|
49
58
|
//# sourceMappingURL=listOrders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOrders.js","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"listOrders.js","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAe,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EACL,qBAAqB,EACrB,2BAA2B,EAC3B,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AAEvB,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,UAAuB,EAAqB,EAAE;IACtF,MAAM,GAAG,GAAG,MAAM,sBAAsB,CAAC,UAAU,CAAC,CAAC;IACrD,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;KAC1B;IACD,OAAO,GAAG,CAAC,GAAG,CACZ,CAAC,KAAK,EAAU,EAAE;;QAAC,OAAA,CAAC;YAClB,QAAQ,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE;YAC5B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,KAAK,CAAC,IAAI,CAAC;QACnD,eAAe,EAAE,2BAA2B,CAAC,KAAK,CAAC,IAAI,CAAC;QACxD,MAAM,EAAE,CAAC,KAAK,CAAC,OAAO;QACtB,aAAa,EAAE,CAAC,KAAK,CAAC,WAAW;QACjC,KAAK,EAAE,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK;QAC3D,SAAS,EAAE,KAAK,CAAC,IAAI;QACrB,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC;QACxC,YAAY,EAAE,qBAAqB,CAAC,KAAK,CAAC,MAAM,CAAC;KAClD,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,WACvC,UAAuB,EACvB,UAAkB;IAElB,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,8BAA8B;IAC5E,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,UAAU,CAAC,CAAC;QAChD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;KAClE;IACD,IAAI,QAAQ,KAAK,aAAa,EAAE;QAC9B,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,UAAU,CAAC,CAAC;QACrD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;KAClE;IACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC","sourcesContent":["import { IActionHandlerOfListOrders, IOrder } from '@yuants/data-order';\nimport { decodePath, encodePath, formatTime } from '@yuants/utils';\nimport { isApiError } from '../../api/client';\nimport { getSpotOpenOrders, getUnifiedUmOpenOrders, ICredential } from '../../api/private-api';\nimport {\n mapBinanceOrderStatus,\n mapBinanceOrderTypeToYuants,\n mapBinanceSideToYuantsDirection,\n mapSpotSideToOrderDirection,\n} from './order-utils';\n\nexport const listUnifiedUmOrders = async (credential: ICredential): Promise<IOrder[]> => {\n const res = await getUnifiedUmOpenOrders(credential);\n if (isApiError(res)) {\n throw new Error(res.msg);\n }\n return res.map(\n (order): IOrder => ({\n order_id: `${order.orderId}`,\n account_id: '',\n product_id: encodePath('BINANCE', 'USDT-FUTURE', order.symbol),\n order_type: mapBinanceOrderTypeToYuants(order.type),\n order_direction:\n mapBinanceSideToYuantsDirection(order.side, order.positionSide) ??\n (order.side === 'BUY' ? 'OPEN_LONG' : 'OPEN_SHORT'),\n volume: +order.origQty,\n traded_volume: +order.executedQty,\n price: order.price === undefined ? undefined : +order.price,\n submit_at: order.time,\n updated_at: formatTime(order.updateTime),\n order_status: mapBinanceOrderStatus(order.status),\n }),\n );\n};\n\nexport const listSpotOrders = async (credential: ICredential): Promise<IOrder[]> => {\n const res = await getSpotOpenOrders(credential);\n if (isApiError(res)) {\n throw new Error(res.msg);\n }\n return res.map(\n (order): IOrder => ({\n order_id: `${order.orderId}`,\n account_id: '',\n product_id: encodePath('BINANCE', 'SPOT', order.symbol),\n order_type: mapBinanceOrderTypeToYuants(order.type),\n order_direction: mapSpotSideToOrderDirection(order.side),\n volume: +order.origQty,\n traded_volume: +order.executedQty,\n price: order.price === undefined ? undefined : +order.price,\n submit_at: order.time,\n updated_at: formatTime(order.updateTime),\n order_status: mapBinanceOrderStatus(order.status),\n }),\n );\n};\n\nexport const getOrdersByProductId = async function (\n credential: ICredential,\n product_id: string,\n): Promise<IOrder[]> {\n const [_, instType] = decodePath(product_id); // BINANCE/USDT-FUTURE/ADAUSDT\n if (instType === 'SPOT') {\n const orders = await listSpotOrders(credential);\n return orders.filter((order) => order.product_id === product_id);\n }\n if (instType === 'USDT-FUTURE') {\n const orders = await listUnifiedUmOrders(credential);\n return orders.filter((order) => order.product_id === product_id);\n }\n throw new Error(`Unsupported instType: ${instType}`);\n};\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isApiError } from '../../api/client';
|
|
2
2
|
import { postSpotOrderCancelReplace, putUmOrder } from '../../api/private-api';
|
|
3
3
|
import { decodeFutureSymbol, decodeSpotSymbol, deriveClientOrderId, mapOrderDirectionToSide, mapOrderTypeToOrdType, } from './order-utils';
|
|
4
|
+
import { newError } from '@yuants/utils/lib/error';
|
|
5
|
+
import { decodePath } from '@yuants/utils/lib/path';
|
|
4
6
|
const modifyUnifiedOrder = async (credential, order) => {
|
|
5
7
|
const symbol = decodeFutureSymbol(order.product_id);
|
|
6
8
|
const side = mapOrderDirectionToSide(order.order_direction);
|
|
@@ -47,12 +49,13 @@ const modifySpotOrder = async (credential, order) => {
|
|
|
47
49
|
}
|
|
48
50
|
};
|
|
49
51
|
export const modifyOrder = async (credential, order) => {
|
|
50
|
-
|
|
52
|
+
const [, TYPE] = decodePath(order.product_id);
|
|
53
|
+
if (TYPE === 'USDT-FUTURE') {
|
|
51
54
|
return modifyUnifiedOrder(credential, order);
|
|
52
55
|
}
|
|
53
|
-
if (
|
|
56
|
+
if (TYPE === 'SPOT') {
|
|
54
57
|
return modifySpotOrder(credential, order);
|
|
55
58
|
}
|
|
56
|
-
throw
|
|
59
|
+
throw newError('BINANCE_MODIFY_ORDER_UNSUPPORTED_PRODUCT_TYPE', { order });
|
|
57
60
|
};
|
|
58
61
|
//# sourceMappingURL=modifyOrder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modifyOrder.js","sourceRoot":"","sources":["../../../src/services/orders/modifyOrder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAe,0BAA0B,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC5F,OA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ACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;KAC7E;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAA6C,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;IAC/F,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAE9C,IAAI,IAAI,KAAK,aAAa,EAAE;QAC1B,OAAO,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;KAC9C;IACD,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,OAAO,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;KAC3C;IAED,MAAM,QAAQ,CAAC,+CAA+C,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC","sourcesContent":["import { IActionHandlerOfModifyOrder } from '@yuants/data-order';\nimport { isApiError } from '../../api/client';\nimport { ICredential, postSpotOrderCancelReplace, putUmOrder } from '../../api/private-api';\nimport {\n decodeFutureSymbol,\n decodeSpotSymbol,\n deriveClientOrderId,\n mapOrderDirectionToSide,\n mapOrderTypeToOrdType,\n} from './order-utils';\nimport { newError } from '@yuants/utils/lib/error';\nimport { decodePath } from '@yuants/utils/lib/path';\n\nconst modifyUnifiedOrder: IActionHandlerOfModifyOrder<ICredential> = async (credential, order) => {\n const symbol = decodeFutureSymbol(order.product_id);\n const side = mapOrderDirectionToSide(order.order_direction);\n\n const res = await putUmOrder(credential, {\n symbol,\n side,\n orderId: order.order_id ? parseInt(order.order_id) : undefined,\n // origClientOrderId: order.client_order_id, // TODO: support client_order_id\n quantity: order.volume,\n price: order.price,\n });\n if (isApiError(res)) {\n throw new Error(`Binance modify unified order failed: ${res.code} ${res.msg}`);\n }\n};\n\nconst modifySpotOrder: IActionHandlerOfModifyOrder<ICredential> = async (credential, order) => {\n const symbol = decodeSpotSymbol(order.product_id);\n const side = mapOrderDirectionToSide(order.order_direction);\n const type = mapOrderTypeToOrdType(order.order_type);\n const timeInForce = order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;\n\n const params: Parameters<typeof postSpotOrderCancelReplace>[1] = {\n symbol,\n side,\n type,\n cancelReplaceMode: 'STOP_ON_FAILURE',\n cancelOrderId: order.order_id ? parseInt(order.order_id) : undefined,\n // cancelOrigClientOrderId: order.client_order_id, // TODO: support client_order_id\n newClientOrderId: deriveClientOrderId(order),\n quantity: order.volume,\n };\n\n if (type === 'LIMIT') {\n if (order.price === undefined) {\n throw new Error('Binance spot LIMIT order requires price');\n }\n params.price = order.price;\n params.timeInForce = timeInForce;\n }\n if (order.price !== undefined && type === 'MARKET') {\n params.price = order.price;\n }\n\n const res = await postSpotOrderCancelReplace(credential, params);\n if (isApiError(res)) {\n throw new Error(`Binance modify spot order failed: ${res.code} ${res.msg}`);\n }\n};\n\nexport const modifyOrder: IActionHandlerOfModifyOrder<ICredential> = async (credential, order) => {\n const [, TYPE] = decodePath(order.product_id);\n\n if (TYPE === 'USDT-FUTURE') {\n return modifyUnifiedOrder(credential, order);\n }\n if (TYPE === 'SPOT') {\n return modifySpotOrder(credential, order);\n }\n\n throw newError('BINANCE_MODIFY_ORDER_UNSUPPORTED_PRODUCT_TYPE', { order });\n};\n"]}
|
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
import { decodePath } from '@yuants/utils';
|
|
2
2
|
import { createHash } from 'crypto';
|
|
3
3
|
export const decodeFutureSymbol = (product_id) => {
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const parts = decodePath(product_id);
|
|
5
|
+
// Support both old format (usdt-future/symbol) and new format (BINANCE/USDT-FUTURE/symbol)
|
|
6
|
+
if (parts.length === 2) {
|
|
7
|
+
const [instType, symbol] = parts;
|
|
8
|
+
if (instType !== 'usdt-future' || !symbol) {
|
|
9
|
+
throw new Error(`Unsupported product_id for Binance futures: ${product_id}`);
|
|
10
|
+
}
|
|
11
|
+
return symbol;
|
|
12
|
+
}
|
|
13
|
+
else if (parts.length === 3) {
|
|
14
|
+
const [datasource, instType, symbol] = parts;
|
|
15
|
+
if (datasource !== 'BINANCE' || instType !== 'USDT-FUTURE' || !symbol) {
|
|
16
|
+
throw new Error(`Unsupported product_id for Binance futures: ${product_id}`);
|
|
17
|
+
}
|
|
18
|
+
return symbol;
|
|
7
19
|
}
|
|
8
|
-
|
|
20
|
+
throw new Error(`Unsupported product_id for Binance futures: ${product_id}`);
|
|
9
21
|
};
|
|
10
22
|
export const decodeSpotSymbol = (product_id) => {
|
|
11
23
|
try {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
const parts = decodePath(product_id);
|
|
25
|
+
// Support both old format (spot/symbol) and new format (BINANCE/SPOT/symbol)
|
|
26
|
+
if (parts.length === 2) {
|
|
27
|
+
const [instType, symbol] = parts;
|
|
28
|
+
if ((instType === null || instType === void 0 ? void 0 : instType.toLowerCase()) === 'spot' && symbol) {
|
|
29
|
+
return symbol;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else if (parts.length === 3) {
|
|
33
|
+
const [datasource, instType, symbol] = parts;
|
|
34
|
+
if (datasource === 'BINANCE' && instType === 'SPOT' && symbol) {
|
|
35
|
+
return symbol;
|
|
36
|
+
}
|
|
15
37
|
}
|
|
16
38
|
}
|
|
17
39
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-utils.js","sourceRoot":"","sources":["../../../src/services/orders/order-utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,UAAkB,EAAE,EAAE;IACvD,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,UAAU,CA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AK,CAAC,QAAQ,EAAE,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC;QAC7B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC,CAAC;IACH,OAAO,SAAS,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AACpF,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAA2C;IACpE,GAAG,EAAE,UAAU;IACf,gBAAgB,EAAE,QAAQ;IAC1B,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,UAAU;IACvB,cAAc,EAAE,WAAW;IAC3B,QAAQ,EAAE,WAAW;IACrB,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,WAAW;IACrB,OAAO,EAAE,WAAW;CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,MAAe,EAA0B,EAAE;;IAC/E,IAAI,CAAC,MAAM;QAAE,OAAO,UAAU,CAAC;IAC/B,OAAO,MAAA,qBAAqB,CAAC,MAAM,CAAC,mCAAI,UAAU,CAAC;AACrD,CAAC,CAAC","sourcesContent":["import { IOrder } from '@yuants/data-order';\nimport { decodePath } from '@yuants/utils';\nimport { createHash } from 'crypto';\n\nexport const decodeFutureSymbol = (product_id: string) => {\n const parts = decodePath(product_id);\n // Support both old format (usdt-future/symbol) and new format (BINANCE/USDT-FUTURE/symbol)\n if (parts.length === 2) {\n const [instType, symbol] = parts;\n if (instType !== 'usdt-future' || !symbol) {\n throw new Error(`Unsupported product_id for Binance futures: ${product_id}`);\n }\n return symbol;\n } else if (parts.length === 3) {\n const [datasource, instType, symbol] = parts;\n if (datasource !== 'BINANCE' || instType !== 'USDT-FUTURE' || !symbol) {\n throw new Error(`Unsupported product_id for Binance futures: ${product_id}`);\n }\n return symbol;\n }\n throw new Error(`Unsupported product_id for Binance futures: ${product_id}`);\n};\n\nexport const decodeSpotSymbol = (product_id: string) => {\n try {\n const parts = decodePath(product_id);\n // Support both old format (spot/symbol) and new format (BINANCE/SPOT/symbol)\n if (parts.length === 2) {\n const [instType, symbol] = parts;\n if (instType?.toLowerCase() === 'spot' && symbol) {\n return symbol;\n }\n } else if (parts.length === 3) {\n const [datasource, instType, symbol] = parts;\n if (datasource === 'BINANCE' && instType === 'SPOT' && symbol) {\n return symbol;\n }\n }\n } catch (err) {\n // ignore decode errors and fall back to raw product id\n }\n if (!product_id.includes('/')) {\n return product_id;\n }\n throw new Error(`Unsupported product_id for Binance spot: ${product_id}`);\n};\n\nexport const mapOrderDirectionToSide = (direction?: IOrder['order_direction']) => {\n switch (direction) {\n case 'OPEN_LONG':\n case 'CLOSE_SHORT':\n return 'BUY';\n case 'OPEN_SHORT':\n case 'CLOSE_LONG':\n return 'SELL';\n default:\n throw new Error(`Unsupported order_direction: ${direction}`);\n }\n};\n\nexport const mapOrderDirectionToPositionSide = (direction?: IOrder['order_direction']) => {\n switch (direction) {\n case 'OPEN_LONG':\n case 'CLOSE_LONG':\n return 'LONG';\n case 'OPEN_SHORT':\n case 'CLOSE_SHORT':\n return 'SHORT';\n default:\n throw new Error(`Unsupported order_direction for positionSide: ${direction}`);\n }\n};\n\nexport const mapOrderTypeToOrdType = (order_type?: IOrder['order_type']) => {\n switch (order_type) {\n case 'LIMIT':\n case 'MAKER':\n return 'LIMIT';\n case 'MARKET':\n return 'MARKET';\n default:\n throw new Error(`Unsupported order_type: ${order_type}`);\n }\n};\n\nexport const mapBinanceOrderTypeToYuants = (binanceType?: string): IOrder['order_type'] => {\n switch (binanceType) {\n case 'LIMIT':\n return 'LIMIT';\n case 'MARKET':\n return 'MARKET';\n default:\n return 'LIMIT';\n }\n};\n\nexport const mapBinanceSideToYuantsDirection = (\n side?: string,\n positionSide?: string,\n): IOrder['order_direction'] | undefined => {\n if (!side || !positionSide) {\n return undefined;\n }\n if (positionSide === 'LONG') {\n return side === 'BUY' ? 'OPEN_LONG' : 'CLOSE_LONG';\n }\n if (positionSide === 'SHORT') {\n return side === 'SELL' ? 'OPEN_SHORT' : 'CLOSE_SHORT';\n }\n return undefined;\n};\n\nexport const mapSpotSideToOrderDirection = (side?: string): IOrder['order_direction'] => {\n if (side === 'SELL') {\n return 'CLOSE_LONG';\n }\n return 'OPEN_LONG';\n};\n\nexport const deriveClientOrderId = (order: IOrder) => {\n if (order.order_id) return `${order.order_id}`;\n const payload = JSON.stringify({\n account_id: order.account_id,\n product_id: order.product_id,\n order_direction: order.order_direction,\n order_type: order.order_type,\n price: order.price,\n volume: order.volume,\n });\n return `YUANTS${createHash('sha256').update(payload).digest('hex').slice(0, 24)}`;\n};\n\nconst BinanceOrderStatusMap: Record<string, IOrder['order_status']> = {\n NEW: 'ACCEPTED',\n PARTIALLY_FILLED: 'TRADED',\n FILLED: 'TRADED',\n PENDING_NEW: 'ACCEPTED',\n PENDING_CANCEL: 'CANCELLED',\n CANCELED: 'CANCELLED',\n CANCELLED: 'CANCELLED',\n REJECTED: 'CANCELLED',\n EXPIRED: 'CANCELLED',\n};\n\nexport const mapBinanceOrderStatus = (status?: string): IOrder['order_status'] => {\n if (!status) return 'ACCEPTED';\n return BinanceOrderStatusMap[status] ?? 'ACCEPTED';\n};\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decodePath, newError } from '@yuants/utils';
|
|
1
2
|
import { isApiError } from '../../api/client';
|
|
2
3
|
import { postSpotOrder, postUmOrder } from '../../api/private-api';
|
|
3
4
|
import { decodeFutureSymbol, decodeSpotSymbol, deriveClientOrderId, mapOrderDirectionToPositionSide, mapOrderDirectionToSide, mapOrderTypeToOrdType, } from './order-utils';
|
|
@@ -59,12 +60,13 @@ const submitSpotOrder = async (credential, order) => {
|
|
|
59
60
|
return { order_id: `${res.orderId}` };
|
|
60
61
|
};
|
|
61
62
|
export const submitOrder = async (credential, order) => {
|
|
62
|
-
|
|
63
|
+
const [, TYPE] = decodePath(order.product_id);
|
|
64
|
+
if (TYPE === 'USDT-FUTURE') {
|
|
63
65
|
return submitUnifiedOrder(credential, order);
|
|
64
66
|
}
|
|
65
|
-
if (
|
|
67
|
+
if (TYPE === 'SPOT') {
|
|
66
68
|
return submitSpotOrder(credential, order);
|
|
67
69
|
}
|
|
68
|
-
throw
|
|
70
|
+
throw newError('BINANCE_SUBMIT_ORDER_UNSUPPORTED_PRODUCT_TYPE', { order });
|
|
69
71
|
};
|
|
70
72
|
//# sourceMappingURL=submitOrder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submitOrder.js","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAe,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AAEvB,MAAM,kBAAkB,GAA6C,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;IAC/F,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACpD,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;KACxE;IACD,MAAM,IAAI,GAAG,uBAAuB,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAC5D,MAAM,YAAY,GAAG,+BAA+B,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IA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CAAC,KAAK,CAAC;QAC3B,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;KAClC;IACD,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,EAAE;QAClD,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;KAC5B;IACD,MAAM,GAAG,GAAG,MAAM,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACpD,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;KAC7E;IACD,OAAO,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAA6C,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;IAC/F,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAE9C,IAAI,IAAI,KAAK,aAAa,EAAE;QAC1B,OAAO,kBAAkB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;KAC9C;IACD,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,OAAO,eAAe,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;KAC3C;IAED,MAAM,QAAQ,CAAC,+CAA+C,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC","sourcesContent":["import { IActionHandlerOfSubmitOrder } from '@yuants/data-order';\nimport { decodePath, newError } from '@yuants/utils';\nimport { isApiError } from '../../api/client';\nimport { ICredential, postSpotOrder, postUmOrder } from '../../api/private-api';\nimport {\n decodeFutureSymbol,\n decodeSpotSymbol,\n deriveClientOrderId,\n mapOrderDirectionToPositionSide,\n mapOrderDirectionToSide,\n mapOrderTypeToOrdType,\n} from './order-utils';\n\nconst submitUnifiedOrder: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n const symbol = decodeFutureSymbol(order.product_id);\n if (!order.volume) {\n throw new Error('Binance submitOrder requires order.volume to be set');\n }\n const side = mapOrderDirectionToSide(order.order_direction);\n const positionSide = mapOrderDirectionToPositionSide(order.order_direction);\n const type = mapOrderTypeToOrdType(order.order_type);\n const timeInForce = order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;\n const reduceOnly =\n order.order_direction === 'CLOSE_LONG' || order.order_direction === 'CLOSE_SHORT' ? 'true' : undefined;\n\n const res = await postUmOrder(credential, {\n symbol,\n side,\n positionSide,\n type,\n quantity: order.volume,\n price: order.price,\n timeInForce,\n reduceOnly,\n newClientOrderId: deriveClientOrderId(order),\n });\n if (isApiError(res)) {\n throw new Error(`Binance submit unified order failed: ${res.code} ${res.msg}`);\n }\n return { order_id: `${res.orderId}` };\n};\n\nconst submitSpotOrder: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n const symbol = decodeSpotSymbol(order.product_id);\n if (!order.volume) {\n throw new Error('Binance submitOrder requires order.volume to be set');\n }\n const side = mapOrderDirectionToSide(order.order_direction);\n const type = mapOrderTypeToOrdType(order.order_type);\n const timeInForce = order.order_type === 'MAKER' ? 'GTX' : order.order_type === 'LIMIT' ? 'GTC' : undefined;\n const params: Parameters<typeof postSpotOrder>[1] = {\n symbol,\n side,\n type,\n quantity: order.volume,\n newClientOrderId: deriveClientOrderId(order),\n };\n if (type === 'LIMIT') {\n if (order.price === undefined) {\n throw new Error('Binance spot LIMIT order requires price');\n }\n params.price = order.price;\n params.timeInForce = timeInForce;\n }\n if (order.price !== undefined && type === 'MARKET') {\n params.price = order.price;\n }\n const res = await postSpotOrder(credential, params);\n if (isApiError(res)) {\n throw new Error(`Binance submit spot order failed: ${res.code} ${res.msg}`);\n }\n return { order_id: `${res.orderId}` };\n};\n\nexport const submitOrder: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n const [, TYPE] = decodePath(order.product_id);\n\n if (TYPE === 'USDT-FUTURE') {\n return submitUnifiedOrder(credential, order);\n }\n if (TYPE === 'SPOT') {\n return submitSpotOrder(credential, order);\n }\n\n throw newError('BINANCE_SUBMIT_ORDER_UNSUPPORTED_PRODUCT_TYPE', { order });\n};\n"]}
|
package/lib/api/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAKA,aAAK,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEpD,aAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,CAAC;AAE3E,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;CACb;AAID,eAAO,MAAM,UAAU,iDAC0E,CAAC;AA2FlG,eAAO,MAAM,aAAa,cAAe,UAAU,YAAY,MAAM,WAAW,aAAa,eACvD,CAAC;AAEvC,eAAO,MAAM,cAAc,kBACb,WAAW,UACf,UAAU,YACR,MAAM,WACP,aAAa,eAC6B,CAAC;AAEtD,eAAO,MAAM,oBAAoB,QAAO,WAOvC,CAAC"}
|
package/lib/api/client.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.getDefaultCredential = exports.requestPrivate = exports.requestPublic = exports.isApiError = void 0;
|
|
7
4
|
const protocol_1 = require("@yuants/protocol");
|
|
8
5
|
const utils_1 = require("@yuants/utils");
|
|
9
|
-
// @ts-ignore
|
|
10
|
-
const crypto_js_1 = __importDefault(require("crypto-js"));
|
|
11
6
|
const MetricBinanceApiUsedWeight = protocol_1.GlobalPrometheusRegistry.gauge('binance_api_used_weight', '');
|
|
7
|
+
let retryAfterUntil = null;
|
|
12
8
|
const isApiError = (value) => typeof (value === null || value === void 0 ? void 0 : value.code) === 'number' && typeof (value === null || value === void 0 ? void 0 : value.msg) === 'string';
|
|
13
9
|
exports.isApiError = isApiError;
|
|
14
10
|
const appendParams = (url, params) => {
|
|
@@ -42,7 +38,7 @@ const callApi = async (method, endpoint, params, credential) => {
|
|
|
42
38
|
let headers;
|
|
43
39
|
if (credential) {
|
|
44
40
|
const signData = url.search.slice(1);
|
|
45
|
-
const signature =
|
|
41
|
+
const signature = Buffer.from(await (0, utils_1.HmacSHA256)(new TextEncoder().encode(signData), new TextEncoder().encode(credential.secret_key))).toString('hex');
|
|
46
42
|
url.searchParams.set('signature', signature);
|
|
47
43
|
headers = {
|
|
48
44
|
'Content-Type': 'application/json;charset=utf-8',
|
|
@@ -53,12 +49,22 @@ const callApi = async (method, endpoint, params, credential) => {
|
|
|
53
49
|
else {
|
|
54
50
|
console.info((0, utils_1.formatTime)(Date.now()), method, url.href);
|
|
55
51
|
}
|
|
52
|
+
if (retryAfterUntil) {
|
|
53
|
+
if (Date.now() <= retryAfterUntil) {
|
|
54
|
+
throw (0, utils_1.newError)('ACTIVE_RATE_LIMIT', { retryAfterUntil, now: Date.now(), url: url.href });
|
|
55
|
+
}
|
|
56
|
+
retryAfterUntil = null;
|
|
57
|
+
}
|
|
56
58
|
const res = await fetch(url.href, {
|
|
57
59
|
method,
|
|
58
60
|
headers,
|
|
59
61
|
});
|
|
60
62
|
const usedWeight1M = res.headers.get('x-mbx-used-weight-1m');
|
|
61
|
-
|
|
63
|
+
const retryAfter = res.headers.get('Retry-After');
|
|
64
|
+
if (retryAfter) {
|
|
65
|
+
retryAfterUntil = Date.now() + parseInt(retryAfter, 10) * 1000;
|
|
66
|
+
}
|
|
67
|
+
console.info((0, utils_1.formatTime)(Date.now()), 'response', method, url.href, `status=${res.status}`, retryAfter ? `retryAfter=${retryAfter}` : '', `usedWeight1M=${usedWeight1M !== null && usedWeight1M !== void 0 ? usedWeight1M : 'N/A'}`);
|
|
62
68
|
if (usedWeight1M) {
|
|
63
69
|
MetricBinanceApiUsedWeight.set(+usedWeight1M);
|
|
64
70
|
}
|
package/lib/api/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":";;;AAAA,+CAA4D;AAC5D,yCAAiE;AAEjE,MAAM,0BAA0B,GAAG,mCAAwB,CAAC,KAAK,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;AAgBjG,IAAI,eAAe,GAAkB,IAAI,CAAC;AAEnC,MAAM,UAAU,GAAG,CAAI,KAAoB,EAAsB,EAAE,CACxE,OAAO,CAAC,KAAmB,aAAnB,KAAK,uBAAL,KAAK,CAAgB,IAAI,CAAA,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAmB,aAAnB,KAAK,uBAAL,KAAK,CAAgB,GAAG,CAAA,KAAK,QAAQ,CAAC;AADrF,QAAA,UAAU,cAC2E;AAElG,MAAM,YAAY,GAAG,CAAC,GAAQ,EAAE,MAAsB,EAAE,EAAE;IACxD,IAAI,CAAC,MAAM;QAAE,OAAO;IACpB,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,KAAK,SAAS,CAAC,CAA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O,CAAC,GAAG,CAAC,UAAU,CAAC;IAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAC1C,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAC;KACtF;IACD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AACpC,CAAC,CAAC;AAPW,QAAA,oBAAoB,wBAO/B","sourcesContent":["import { GlobalPrometheusRegistry } from '@yuants/protocol';\nimport { formatTime, HmacSHA256, newError } from '@yuants/utils';\n\nconst MetricBinanceApiUsedWeight = GlobalPrometheusRegistry.gauge('binance_api_used_weight', '');\n\ntype HttpMethod = 'GET' | 'POST' | 'DELETE' | 'PUT';\n\ntype RequestParams = Record<string, string | number | boolean | undefined>;\n\nexport interface ICredential {\n access_key: string;\n secret_key: string;\n}\n\nexport interface IApiError {\n code: number;\n msg: string;\n}\n\nlet retryAfterUntil: number | null = null;\n\nexport const isApiError = <T>(value: T | IApiError): value is IApiError =>\n typeof (value as IApiError)?.code === 'number' && typeof (value as IApiError)?.msg === 'string';\n\nconst appendParams = (url: URL, params?: RequestParams) => {\n if (!params) return;\n const entries = Object.entries(params).filter(([, value]) => value !== undefined);\n const timestampEntry = entries.find(([key]) => key === 'timestamp');\n const restEntries = entries.filter(([key]) => key !== 'timestamp');\n restEntries\n .sort(([keyA], [keyB]) => keyA.localeCompare(keyB))\n .forEach(([key, value]) => {\n url.searchParams.set(key, String(value));\n });\n if (timestampEntry) {\n url.searchParams.set(timestampEntry[0], String(timestampEntry[1]));\n }\n};\n\nconst callApi = async <T>(\n method: HttpMethod,\n endpoint: string,\n params?: RequestParams,\n credential?: ICredential,\n): Promise<T> => {\n const url = new URL(endpoint);\n const normalizedParams: RequestParams = { ...params };\n if (credential) {\n if (normalizedParams.recvWindow === undefined) {\n // FYI https://developers.binance.com/docs/derivatives/usds-margined-futures/general-info#timing-security\n normalizedParams.recvWindow = 5000;\n }\n if (normalizedParams.timestamp === undefined) {\n normalizedParams.timestamp = Date.now();\n }\n }\n appendParams(url, normalizedParams);\n\n let headers: Record<string, string> | undefined;\n if (credential) {\n const signData = url.search.slice(1);\n\n const signature = Buffer.from(\n await HmacSHA256(new TextEncoder().encode(signData), new TextEncoder().encode(credential.secret_key)),\n ).toString('hex');\n url.searchParams.set('signature', signature);\n headers = {\n 'Content-Type': 'application/json;charset=utf-8',\n 'X-MBX-APIKEY': credential.access_key,\n };\n console.info(\n formatTime(Date.now()),\n method,\n url.href,\n JSON.stringify(headers),\n url.searchParams.toString(),\n signData,\n );\n } else {\n console.info(formatTime(Date.now()), method, url.href);\n }\n\n if (retryAfterUntil) {\n if (Date.now() <= retryAfterUntil) {\n throw newError('ACTIVE_RATE_LIMIT', { retryAfterUntil, now: Date.now(), url: url.href });\n }\n retryAfterUntil = null;\n }\n\n const res = await fetch(url.href, {\n method,\n headers,\n });\n const usedWeight1M = res.headers.get('x-mbx-used-weight-1m');\n const retryAfter = res.headers.get('Retry-After');\n if (retryAfter) {\n retryAfterUntil = Date.now() + parseInt(retryAfter, 10) * 1000;\n }\n console.info(\n formatTime(Date.now()),\n 'response',\n method,\n url.href,\n `status=${res.status}`,\n retryAfter ? `retryAfter=${retryAfter}` : '',\n `usedWeight1M=${usedWeight1M ?? 'N/A'}`,\n );\n if (usedWeight1M) {\n MetricBinanceApiUsedWeight.set(+usedWeight1M);\n }\n return res.json() as Promise<T>;\n};\n\nexport const requestPublic = <T>(method: HttpMethod, endpoint: string, params?: RequestParams) =>\n callApi<T>(method, endpoint, params);\n\nexport const requestPrivate = <T>(\n credential: ICredential,\n method: HttpMethod,\n endpoint: string,\n params?: RequestParams,\n) => callApi<T>(method, endpoint, params, credential);\n\nexport const getDefaultCredential = (): ICredential => {\n const access_key = process.env.ACCESS_KEY;\n const secret_key = process.env.SECRET_KEY;\n if (!access_key || !secret_key) {\n throw new Error('Missing Binance credential: ACCESS_KEY and SECRET_KEY must be set');\n }\n return { access_key, secret_key };\n};\n"]}
|
package/lib/api/public-api.d.ts
CHANGED
|
@@ -152,4 +152,45 @@ export interface ISpotBookTickerEntry {
|
|
|
152
152
|
export declare const getSpotBookTicker: (params?: {
|
|
153
153
|
symbol?: string;
|
|
154
154
|
}) => Promise<ISpotBookTickerEntry[]>;
|
|
155
|
+
export interface ISpotExchangeFilter extends Record<string, string | number | boolean | undefined> {
|
|
156
|
+
filterType: string;
|
|
157
|
+
}
|
|
158
|
+
export interface ISpotExchangeSymbol {
|
|
159
|
+
symbol: string;
|
|
160
|
+
status: string;
|
|
161
|
+
baseAsset: string;
|
|
162
|
+
baseAssetPrecision: number;
|
|
163
|
+
quoteAsset: string;
|
|
164
|
+
quotePrecision: number;
|
|
165
|
+
baseCommissionPrecision: number;
|
|
166
|
+
quoteCommissionPrecision: number;
|
|
167
|
+
orderTypes: string[];
|
|
168
|
+
icebergAllowed: boolean;
|
|
169
|
+
ocoAllowed: boolean;
|
|
170
|
+
quoteOrderQtyMarketAllowed: boolean;
|
|
171
|
+
allowTrailingStop: boolean;
|
|
172
|
+
cancelReplaceAllowed: boolean;
|
|
173
|
+
isSpotTradingAllowed: boolean;
|
|
174
|
+
isMarginTradingAllowed: boolean;
|
|
175
|
+
filters: ISpotExchangeFilter[];
|
|
176
|
+
permissions: string[];
|
|
177
|
+
}
|
|
178
|
+
export interface ISpotExchangeInfo {
|
|
179
|
+
timezone: string;
|
|
180
|
+
serverTime: number;
|
|
181
|
+
rateLimits: {
|
|
182
|
+
rateLimitType: string;
|
|
183
|
+
interval: string;
|
|
184
|
+
intervalNum: number;
|
|
185
|
+
limit: number;
|
|
186
|
+
}[];
|
|
187
|
+
exchangeFilters: unknown[];
|
|
188
|
+
symbols: ISpotExchangeSymbol[];
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* 获取现货交易规则和交易对
|
|
192
|
+
*
|
|
193
|
+
* https://developers.binance.com/docs/zh-CN/binance-spot-api-docs/rest-api/general-endpoints#%E4%BA%A4%E6%98%93%E8%A7%84%E8%8C%83%E4%BF%A1%E6%81%AF
|
|
194
|
+
*/
|
|
195
|
+
export declare const getSpotExchangeInfo: () => Promise<ISpotExchangeInfo>;
|
|
155
196
|
//# sourceMappingURL=public-api.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAsB,SAAQ,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAClG,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,qBAAqB,EAAE,CAAC;IACjC,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,MAAM,EAAE,C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