@1stdex/first-sdk 1.0.30 → 1.0.31

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBookPositionValue = exports.getOrderSetupStatus = exports.needsVaultDeposit = exports.checkTokenAllowances = exports.isOrderOperatorApproved = exports.getPortfolioBalance = exports.getTradingBalance = exports.getVault = exports.getReferralSummary = exports.getUserNativeVolume = exports.getTopUsersByNativeVolume = exports.getUserDailyVolumes = exports.getProtocolAnalytics = exports.getLatestPrice = exports.getDailyClosePriceMap = exports.getLatestPriceMap = exports.getStableCurrencies = exports.getCurrencies = exports.getContractAddresses = exports.getSubgraphBlock = exports.getSubgraphBlockNumber = exports.getSubgraphEndpoint = exports.getOpenOrders = exports.getOpenOrder = exports.getPriceNeighborhood = exports.parseMakeOrderIdsFromReceipt = exports.getQuoteToken = exports.getMarketSnapshot = exports.getMarketSnapshots = exports.getExpectedInput = exports.getExpectedOutput = exports.getLatestChartLog = exports.getChartLogs = exports.getMarket = void 0;
3
+ exports.getOrderPositionValue = exports.getBookPositionValue = exports.getOrderSetupStatus = exports.needsVaultDeposit = exports.checkTokenAllowances = exports.isOrderOperatorApproved = exports.getPortfolioBalance = exports.getTradingBalance = exports.getVault = exports.getReferralSummary = exports.getUserNativeVolume = exports.getTopUsersByNativeVolume = exports.getUserDailyVolumes = exports.getProtocolAnalytics = exports.getLatestPrice = exports.getDailyClosePriceMap = exports.getLatestPriceMap = exports.getStableCurrencies = exports.getCurrencies = exports.getContractAddresses = exports.getSubgraphBlock = exports.getSubgraphBlockNumber = exports.getSubgraphEndpoint = exports.getOpenOrders = exports.getOpenOrder = exports.getPriceNeighborhood = exports.parseMakeOrderIdsFromReceipt = exports.getQuoteToken = exports.getMarketSnapshot = exports.getMarketSnapshots = exports.getExpectedInput = exports.getExpectedOutput = exports.getLatestChartLog = exports.getChartLogs = exports.getMarket = void 0;
4
4
  var market_1 = require("./market");
5
5
  Object.defineProperty(exports, "getMarket", { enumerable: true, get: function () { return market_1.getMarket; } });
6
6
  Object.defineProperty(exports, "getChartLogs", { enumerable: true, get: function () { return market_1.getChartLogs; } });
@@ -46,4 +46,6 @@ Object.defineProperty(exports, "needsVaultDeposit", { enumerable: true, get: fun
46
46
  Object.defineProperty(exports, "getOrderSetupStatus", { enumerable: true, get: function () { return setup_1.getOrderSetupStatus; } });
47
47
  var book_1 = require("./book");
48
48
  Object.defineProperty(exports, "getBookPositionValue", { enumerable: true, get: function () { return book_1.getBookPositionValue; } });
49
+ var order_1 = require("./order");
50
+ Object.defineProperty(exports, "getOrderPositionValue", { enumerable: true, get: function () { return order_1.getOrderPositionValue; } });
49
51
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/index.ts"],"names":[],"mappings":";;;AAAA,mCAUkB;AAThB,mGAAA,SAAS,OAAA;AACT,sGAAA,YAAY,OAAA;AACZ,2GAAA,iBAAiB,OAAA;AACjB,2GAAA,iBAAiB,OAAA;AACjB,0GAAA,gBAAgB,OAAA;AAChB,4GAAA,kBAAkB,OAAA;AAClB,2GAAA,iBAAiB,OAAA;AACjB,uGAAA,aAAa,OAAA;AACb,sHAAA,4BAA4B,OAAA;AAG9B,+BAA8C;AAArC,4GAAA,oBAAoB,OAAA;AAC7B,2CAA2D;AAAlD,0GAAA,YAAY,OAAA;AAAE,2GAAA,aAAa,OAAA;AACpC,uCAIoB;AAHlB,+GAAA,mBAAmB,OAAA;AACnB,kHAAA,sBAAsB,OAAA;AACtB,4GAAA,gBAAgB,OAAA;AAElB,qCAAiD;AAAxC,+GAAA,oBAAoB,OAAA;AAC7B,uCAMoB;AALlB,yGAAA,aAAa,OAAA;AACb,+GAAA,mBAAmB,OAAA;AACnB,6GAAA,iBAAiB,OAAA;AACjB,iHAAA,qBAAqB,OAAA;AACrB,0GAAA,cA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AmB,OAAA;AACnB,sHAAA,yBAAyB,OAAA;AACzB,gHAAA,mBAAmB,OAAA;AACnB,+GAAA,kBAAkB,OAAA;AAEpB,iCAAmC;AAA1B,iGAAA,QAAQ,OAAA;AACjB,qCAAmE;AAA1D,4GAAA,iBAAiB,OAAA;AAAE,8GAAA,mBAAmB,OAAA;AAC/C,iCAKiB;AAJf,gHAAA,uBAAuB,OAAA;AACvB,6GAAA,oBAAoB,OAAA;AACpB,0GAAA,iBAAiB,OAAA;AACjB,4GAAA,mBAAmB,OAAA;AAErB,+BAA8C;AAArC,4GAAA,oBAAoB,OAAA;AAC7B,iCAAgD;AAAvC,8GAAA,qBAAqB,OAAA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOrderPositionValue = void 0;
4
+ const apis_1 = require("../entities/book/apis");
5
+ const order_id_1 = require("../entities/open-order/utils/order-id");
6
+ const getOrderPositionValue = async ({ chainId, orderId, units, }) => {
7
+ const { bookId, tick } = (0, order_id_1.fromOrderId)(BigInt(orderId));
8
+ return (0, apis_1.fetchBookPositionValue)({
9
+ chainId,
10
+ bookId: bookId.toString(),
11
+ tick,
12
+ units,
13
+ });
14
+ };
15
+ exports.getOrderPositionValue = getOrderPositionValue;
16
+ //# sourceMappingURL=order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order.js","sourceRoot":"","sources":["../../../src/views/order.ts"],"names":[],"mappings":";;;AACA,gDAA+D;AAC/D,oEAAoE;AAuB7D,MAAM,qBAAqB,GAAG,KAAK,EAAE,EAC1C,OAAO,EACP,OAAO,EACP,KAAK,GAKN,EAA4D,EAAE;IAC7D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAA,sBAAW,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACtD,OAAO,IAAA,6BAAsB,EAAC;QAC5B,OAAO;QACP,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;QACzB,IAAI;QACJ,KAAK;KACN,CAAC,CAAC;AACL,CAAC,CAAC;AAhBW,QAAA,qBAAqB,yBAgBhC"}
@@ -9,4 +9,5 @@ export { getVault } from './vault';
9
9
  export { getTradingBalance, getPortfolioBalance } from './balance';
10
10
  export { isOrderOperatorApproved, checkTokenAllowances, needsVaultDeposit, getOrderSetupStatus, } from './setup';
11
11
  export { getBookPositionValue } from './book';
12
+ export { getOrderPositionValue } from './order';
12
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,4BAA4B,GAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,4BAA4B,GAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACnE,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { fetchBookPositionValue } from '../entities/book/apis';
2
+ import { fromOrderId } from '../entities/open-order/utils/order-id';
3
+ /**
4
+ * Gets the USD value for an order position with given units.
5
+ *
6
+ * @param {CHAIN_IDS} chainId - chain id from {@link CHAIN_IDS}
7
+ * @param {string} orderId - The order ID as a string
8
+ * @param {bigint} units - The number of units
9
+ *
10
+ * @returns {Promise<{ bookType: 'bids' | 'asks'; usdValue: string }>} An object containing:
11
+ * - bookType: 'bids' for bid books, 'asks' for ask books
12
+ * - usdValue: The USD value of the position as a string
13
+ *
14
+ * @example
15
+ * import { getOrderPositionValue } from '@clober/v2-sdk'
16
+ *
17
+ * const result = await getOrderPositionValue({
18
+ * chainId: 421614,
19
+ * orderId: '46223845323662364279893361453861711542636620039907198451770258805035840307200',
20
+ * units: 5n,
21
+ * })
22
+ * // returns { bookType: 'bids', usdValue: '1234.56' }
23
+ */
24
+ export const getOrderPositionValue = async ({ chainId, orderId, units, }) => {
25
+ const { bookId, tick } = fromOrderId(BigInt(orderId));
26
+ return fetchBookPositionValue({
27
+ chainId,
28
+ bookId: bookId.toString(),
29
+ tick,
30
+ units,
31
+ });
32
+ };
33
+ //# sourceMappingURL=order.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order.js","sourceRoot":"","sources":["../../../src/views/order.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAE,EAC1C,OAAO,EACP,OAAO,EACP,KAAK,GAKN,EAA4D,EAAE;IAC7D,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IACtD,OAAO,sBAAsB,CAAC;QAC5B,OAAO;QACP,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;QACzB,IAAI;QACJ,KAAK;KACN,CAAC,CAAC;AACL,CAAC,CAAC"}