@1stdex/first-sdk 1.0.92-beta.4 → 1.0.92-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/views/book.js +7 -6
- package/dist/cjs/views/book.js.map +1 -1
- package/dist/cjs/views/index.js +2 -1
- package/dist/cjs/views/index.js.map +1 -1
- package/dist/cjs/views/open-order.js +6 -1
- package/dist/cjs/views/open-order.js.map +1 -1
- package/dist/esm/views/book.js +14 -13
- package/dist/esm/views/book.js.map +1 -1
- package/dist/esm/views/index.js +1 -1
- package/dist/esm/views/index.js.map +1 -1
- package/dist/esm/views/open-order.js +17 -0
- package/dist/esm/views/open-order.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/views/book.d.ts +8 -11
- package/dist/types/views/book.d.ts.map +1 -1
- package/dist/types/views/index.d.ts +1 -1
- package/dist/types/views/index.d.ts.map +1 -1
- package/dist/types/views/open-order.d.ts +20 -0
- package/dist/types/views/open-order.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/views/book.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getTradeInfo = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
4
5
|
const subgraph_1 = require("../constants/chain-configs/subgraph");
|
|
5
6
|
const utils_1 = require("../utils");
|
|
6
7
|
const getTradeInfo = async ({ chainId, bookId, tick, quoteUnits, }) => {
|
|
@@ -11,8 +12,8 @@ const getTradeInfo = async ({ chainId, bookId, tick, quoteUnits, }) => {
|
|
|
11
12
|
throw new Error(`Book not found: ${bookId}`);
|
|
12
13
|
}
|
|
13
14
|
const unitSize = BigInt(book.unitSize);
|
|
14
|
-
const
|
|
15
|
-
const
|
|
15
|
+
const quoteAmountRaw = quoteUnits * unitSize;
|
|
16
|
+
const baseAmountRaw = (0, utils_1.quoteToBase)(tick, quoteAmountRaw, false);
|
|
16
17
|
const quoteCurrency = {
|
|
17
18
|
address: book.quote.id,
|
|
18
19
|
name: book.quote.name,
|
|
@@ -25,11 +26,11 @@ const getTradeInfo = async ({ chainId, bookId, tick, quoteUnits, }) => {
|
|
|
25
26
|
symbol: book.base.symbol,
|
|
26
27
|
decimals: Number(book.base.decimals),
|
|
27
28
|
};
|
|
29
|
+
const quoteAmount = (0, viem_1.formatUnits)(quoteAmountRaw, quoteCurrency.decimals);
|
|
30
|
+
const baseAmount = (0, viem_1.formatUnits)(baseAmountRaw, baseCurrency.decimals);
|
|
28
31
|
return {
|
|
29
|
-
quoteCurrency,
|
|
30
|
-
|
|
31
|
-
baseCurrency,
|
|
32
|
-
baseAmount,
|
|
32
|
+
quote: { currency: quoteCurrency, value: quoteAmount },
|
|
33
|
+
base: { currency: baseCurrency, value: baseAmount },
|
|
33
34
|
};
|
|
34
35
|
};
|
|
35
36
|
exports.getTradeInfo = getTradeInfo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"book.js","sourceRoot":"","sources":["../../../src/views/book.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"book.js","sourceRoot":"","sources":["../../../src/views/book.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAGnC,kEAA+D;AAE/D,oCAAuC;AA0BhC,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,OAAO,EACP,MAAM,EACN,IAAI,EACJ,UAAU,GAMX,EAGE,EAAE;IAEH,MAAM,EACJ,IAAI,EAAE,EAAE,IAAI,EAAE,GACf,GAAG,MAAM,mBAAQ,CAAC,GAAG,CAoBpB,OAAO,EACP,cAAc,EACd,2IAA2I,EAC3I;QACE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;KAC1B,CACF,CAAC;IAEF,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IA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ainLZWithdrawalStatus = exports.getUserVolumeUSD = exports.getTradeHistory = exports.getOrderPositionValue = exports.getOrder = exports.getTradeInfo = exports.getOrderSetupStatus = exports.needsVaultDeposit = exports.checkTokenAllowances = exports.getRealTokenBalance = exports.getAllBalances = 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.getClaimableOrders = exports.getCancelableOrders = exports.getOpenOrders = exports.getOpenOrder = exports.getPriceNeighborhood = exports.getMakeOrderResult = exports.getLimitOrderResult = exports.parseMakeOrderIdsFromReceipt = exports.getQuoteToken = exports.getMarketSnapshot = exports.getMarketSnapshots = exports.getExpectedInput = exports.getExpectedOutput = exports.getLatestChartLog = exports.getChartLogs = exports.getMarket = void 0;
|
|
3
|
+
exports.getCrossChainLZWithdrawalStatus = exports.getUserVolumeUSD = exports.getTradeHistory = exports.getOrderPositionValue = exports.getOrder = exports.getTradeInfo = exports.getOrderSetupStatus = exports.needsVaultDeposit = exports.checkTokenAllowances = exports.getRealTokenBalance = exports.getAllBalances = 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.decodeOrderId = exports.getClaimableOrders = exports.getCancelableOrders = exports.getOpenOrders = exports.getOpenOrder = exports.getPriceNeighborhood = exports.getMakeOrderResult = exports.getLimitOrderResult = 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; } });
|
|
@@ -20,6 +20,7 @@ Object.defineProperty(exports, "getOpenOrder", { enumerable: true, get: function
|
|
|
20
20
|
Object.defineProperty(exports, "getOpenOrders", { enumerable: true, get: function () { return open_order_1.getOpenOrders; } });
|
|
21
21
|
Object.defineProperty(exports, "getCancelableOrders", { enumerable: true, get: function () { return open_order_1.getCancelableOrders; } });
|
|
22
22
|
Object.defineProperty(exports, "getClaimableOrders", { enumerable: true, get: function () { return open_order_1.getClaimableOrders; } });
|
|
23
|
+
Object.defineProperty(exports, "decodeOrderId", { enumerable: true, get: function () { return open_order_1.decodeOrderId; } });
|
|
23
24
|
var subgraph_1 = require("./subgraph");
|
|
24
25
|
Object.defineProperty(exports, "getSubgraphEndpoint", { enumerable: true, get: function () { return subgraph_1.getSubgraphEndpoint; } });
|
|
25
26
|
Object.defineProperty(exports, "getSubgraphBlockNumber", { enumerable: true, get: function () { return subgraph_1.getSubgraphBlockNumber; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/views/index.ts"],"names":[],"mappings":";;;AAAA,mCAYkB;AAXhB,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;AAC5B,6GAAA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nB,yGAAA,cAAc,OAAA;AACd,8GAAA,mBAAmB,OAAA;AAErB,iCAIiB;AAHf,6GAAA,oBAAoB,OAAA;AACpB,0GAAA,iBAAiB,OAAA;AACjB,4GAAA,mBAAmB,OAAA;AAErB,+BAAsC;AAA7B,oGAAA,YAAY,OAAA;AACrB,iCAA0D;AAAjD,iGAAA,QAAQ,OAAA;AAAE,8GAAA,qBAAqB,OAAA;AACxC,iDAAkD;AAAzC,gHAAA,eAAe,OAAA;AACxB,6CAAiD;AAAxC,+GAAA,gBAAgB,OAAA;AACzB,2CAA+D;AAAtD,6HAAA,+BAA+B,OAAA"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getClaimableOrders = exports.getCancelableOrders = exports.getOpenOrders = exports.getOpenOrder = void 0;
|
|
3
|
+
exports.decodeOrderId = exports.getClaimableOrders = exports.getCancelableOrders = exports.getOpenOrders = exports.getOpenOrder = void 0;
|
|
4
4
|
const apis_1 = require("../entities/open-order/apis");
|
|
5
|
+
const order_id_1 = require("../entities/open-order/utils/order-id");
|
|
5
6
|
const getOpenOrder = async ({ chainId, id, }) => {
|
|
6
7
|
return (0, apis_1.fetchOpenOrderByOrderIdFromSubgraph)(chainId, id);
|
|
7
8
|
};
|
|
@@ -18,4 +19,8 @@ const getClaimableOrders = async ({ chainId, userAddress, tokenAddresses, }) =>
|
|
|
18
19
|
return (0, apis_1.fetchClaimableOrdersFromSubgraph)(chainId, userAddress, tokenAddresses);
|
|
19
20
|
};
|
|
20
21
|
exports.getClaimableOrders = getClaimableOrders;
|
|
22
|
+
const decodeOrderId = ({ orderId, }) => {
|
|
23
|
+
return (0, order_id_1.fromOrderId)(orderId);
|
|
24
|
+
};
|
|
25
|
+
exports.decodeOrderId = decodeOrderId;
|
|
21
26
|
//# sourceMappingURL=open-order.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-order.js","sourceRoot":"","sources":["../../../src/views/open-order.ts"],"names":[],"mappings":";;;AAEA,sDAKqC;
|
|
1
|
+
{"version":3,"file":"open-order.js","sourceRoot":"","sources":["../../../src/views/open-order.ts"],"names":[],"mappings":";;;AAEA,sDAKqC;AACrC,oEAAoE;AAiB7D,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,OAAO,EACP,EAAE,GAIH,EAAsB,EAAE;IACvB,OAAO,IAAA,0CAAmC,EAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC;AARW,QAAA,YAAY,gBAQvB;AAiBK,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,OAAO,EACP,WAAW,EACX,YAAY,GAKb,EAAwB,EAAE;IACzB,OAAO,IAAA,+CAAwC,EAC7C,OAAO,EACP,WAAW,EACX,YAAY,CACb,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,aAAa,iBAcxB;AAkBK,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,OAAO,EACP,WAAW,EACX,cAAc,GAKf,EAAwB,EAAE;IACzB,OAAO,IAAA,qDAA8C,EACnD,OAAO,EACP,WAAW,EACX,cAAc,CACf,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,mBAAmB,uBAc9B;AAkBK,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,OAAO,EACP,WAAW,EACX,cAAc,GAKf,EAAwB,EAAE;IACzB,OAAO,IAAA,uCAAgC,EAAC,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;AAChF,CAAC,CAAC;AAVW,QAAA,kBAAkB,sBAU7B;AAeK,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,GAGR,EAIC,EAAE;IACF,OAAO,IAAA,sBAAW,EAAC,OAAO,CAAC,CAAC;AAC9B,CAAC,CAAC;AAVW,QAAA,aAAa,iBAUxB"}
|
package/dist/esm/views/book.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { formatUnits } from 'viem';
|
|
1
2
|
import { Subgraph } from '../constants/chain-configs/subgraph';
|
|
2
3
|
import { quoteToBase } from '../utils';
|
|
3
4
|
/**
|
|
@@ -8,11 +9,9 @@ import { quoteToBase } from '../utils';
|
|
|
8
9
|
* @param {bigint} tick - The tick for the trade
|
|
9
10
|
* @param {bigint} quoteUnits - The number of quote units
|
|
10
11
|
*
|
|
11
|
-
* @returns {Promise<{
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
14
|
-
* - baseCurrency: The base currency information
|
|
15
|
-
* - baseAmount: The raw base token amount
|
|
12
|
+
* @returns {Promise<{ quote: CurrencyAmount; base: CurrencyAmount }>} An object containing:
|
|
13
|
+
* - quote: The quote currency and formatted amount
|
|
14
|
+
* - base: The base currency and formatted amount
|
|
16
15
|
*
|
|
17
16
|
* @example
|
|
18
17
|
* import { getTradeInfo } from '@1stdex/first-sdk'
|
|
@@ -23,7 +22,8 @@ import { quoteToBase } from '../utils';
|
|
|
23
22
|
* tick: 1000n,
|
|
24
23
|
* quoteUnits: 5n,
|
|
25
24
|
* })
|
|
26
|
-
*
|
|
25
|
+
* console.log(`Quote: ${result.quote.value} ${result.quote.currency.symbol}`)
|
|
26
|
+
* console.log(`Base: ${result.base.value} ${result.base.currency.symbol}`)
|
|
27
27
|
*/
|
|
28
28
|
export const getTradeInfo = async ({ chainId, bookId, tick, quoteUnits, }) => {
|
|
29
29
|
// Fetch book data from subgraph
|
|
@@ -34,9 +34,9 @@ export const getTradeInfo = async ({ chainId, bookId, tick, quoteUnits, }) => {
|
|
|
34
34
|
throw new Error(`Book not found: ${bookId}`);
|
|
35
35
|
}
|
|
36
36
|
const unitSize = BigInt(book.unitSize);
|
|
37
|
-
// Calculate amounts
|
|
38
|
-
const
|
|
39
|
-
const
|
|
37
|
+
// Calculate raw amounts
|
|
38
|
+
const quoteAmountRaw = quoteUnits * unitSize;
|
|
39
|
+
const baseAmountRaw = quoteToBase(tick, quoteAmountRaw, false);
|
|
40
40
|
// Build currency objects
|
|
41
41
|
const quoteCurrency = {
|
|
42
42
|
address: book.quote.id,
|
|
@@ -50,11 +50,12 @@ export const getTradeInfo = async ({ chainId, bookId, tick, quoteUnits, }) => {
|
|
|
50
50
|
symbol: book.base.symbol,
|
|
51
51
|
decimals: Number(book.base.decimals),
|
|
52
52
|
};
|
|
53
|
+
// Format amounts to strings
|
|
54
|
+
const quoteAmount = formatUnits(quoteAmountRaw, quoteCurrency.decimals);
|
|
55
|
+
const baseAmount = formatUnits(baseAmountRaw, baseCurrency.decimals);
|
|
53
56
|
return {
|
|
54
|
-
quoteCurrency,
|
|
55
|
-
|
|
56
|
-
baseCurrency,
|
|
57
|
-
baseAmount,
|
|
57
|
+
quote: { currency: quoteCurrency, value: quoteAmount },
|
|
58
|
+
base: { currency: baseCurrency, value: baseAmount },
|
|
58
59
|
};
|
|
59
60
|
};
|
|
60
61
|
//# sourceMappingURL=book.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"book.js","sourceRoot":"","sources":["../../../src/views/book.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"book.js","sourceRoot":"","sources":["../../../src/views/book.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,MAAM,CAAC;AAGnC,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAE/D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,OAAO,EACP,MAAM,EACN,IAAI,EACJ,UAAU,GAMX,EAGE,EAAE;IACH,gCAAgC;IAChC,MAAM,EACJ,IAAI,EAAE,EAAE,IAAI,EAAE,GACf,GAAG,MAAM,QAAQ,CAAC,GAAG,CAoBpB,OAAO,EACP,cAAc,EACd,2IAA2I,EAC3I;QACE,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;KAC1B,CACF,CAA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ED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { getMarket, getChartLogs, getLatestChartLog, getExpectedOutput, getExpectedInput, getMarketSnapshots, getMarketSnapshot, getQuoteToken, parseMakeOrderIdsFromReceipt, getLimitOrderResult, getMakeOrderResult, } from './market';
|
|
2
2
|
export { getPriceNeighborhood } from './tick';
|
|
3
|
-
export { getOpenOrder, getOpenOrders, getCancelableOrders, getClaimableOrders, } from './open-order';
|
|
3
|
+
export { getOpenOrder, getOpenOrders, getCancelableOrders, getClaimableOrders, decodeOrderId, } from './open-order';
|
|
4
4
|
export { getSubgraphEndpoint, getSubgraphBlockNumber, getSubgraphBlock, } from './subgraph';
|
|
5
5
|
export { getContractAddresses } from './address';
|
|
6
6
|
export { getCurrencies, getStableCurrencies, getLatestPriceMap, getDailyClosePriceMap, getLatestPrice, } from './currency';
|
|
@@ -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,EAC5B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,
|
|
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,EAC5B,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,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,EACL,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,mBAAmB,GACpB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fetchOpenOrderByOrderIdFromSubgraph, fetchOpenOrdersByUserAddressFromSubgraph, fetchCancelableOrdersByUserAddressFromSubgraph, fetchClaimableOrdersFromSubgraph, } from '../entities/open-order/apis';
|
|
2
|
+
import { fromOrderId } from '../entities/open-order/utils/order-id';
|
|
2
3
|
/**
|
|
3
4
|
* Retrieves the open order with the specified ID on the given chain.
|
|
4
5
|
*
|
|
@@ -76,4 +77,20 @@ export const getCancelableOrders = async ({ chainId, userAddress, tokenAddresses
|
|
|
76
77
|
export const getClaimableOrders = async ({ chainId, userAddress, tokenAddresses, }) => {
|
|
77
78
|
return fetchClaimableOrdersFromSubgraph(chainId, userAddress, tokenAddresses);
|
|
78
79
|
};
|
|
80
|
+
/**
|
|
81
|
+
* Decodes an order ID into its constituent parts: book ID, tick, and index.
|
|
82
|
+
*
|
|
83
|
+
* @param {bigint} orderId The order ID to decode.
|
|
84
|
+
* @returns {{ bookId: bigint; tick: bigint; index: bigint }} Object containing the decoded book ID, tick, and index.
|
|
85
|
+
* @example
|
|
86
|
+
* import { decodeOrderId } from '@1stdex/first-sdk'
|
|
87
|
+
*
|
|
88
|
+
* const decoded = decodeOrderId({
|
|
89
|
+
* orderId: 46223845323662364279893361453861711542636620039907198451770258805035840307200n
|
|
90
|
+
* })
|
|
91
|
+
* // Returns: { bookId: 2503n, tick: 0n, index: 0n }
|
|
92
|
+
*/
|
|
93
|
+
export const decodeOrderId = ({ orderId, }) => {
|
|
94
|
+
return fromOrderId(orderId);
|
|
95
|
+
};
|
|
79
96
|
//# sourceMappingURL=open-order.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open-order.js","sourceRoot":"","sources":["../../../src/views/open-order.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mCAAmC,EACnC,wCAAwC,EACxC,8CAA8C,EAC9C,gCAAgC,GACjC,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"open-order.js","sourceRoot":"","sources":["../../../src/views/open-order.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,mCAAmC,EACnC,wCAAwC,EACxC,8CAA8C,EAC9C,gCAAgC,GACjC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AAEpE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,EACjC,OAAO,EACP,EAAE,GAIH,EAAsB,EAAE;IACvB,OAAO,mCAAmC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC1D,CAAC,CAAC;AACF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,KAAK,EAAE,EAClC,OAAO,EACP,WAAW,EACX,YAAY,GAKb,EAAwB,EAAE;IACzB,OAAO,wCAAwC,CAC7C,OAAO,EACP,WAAW,EACX,YAAY,CACb,CAAC;AACJ,CAAC,CAAC;AACF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,EACxC,OAAO,EACP,WAAW,EACX,cAAc,GAKf,EAAwB,EAAE;IACzB,OAAO,8CAA8C,CACnD,OAAO,EACP,WAAW,EACX,cAAc,CACf,CAAC;AACJ,CAAC,CAAC;AACF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,EACvC,OAAO,EACP,WAAW,EACX,cAAc,GAKf,EAAwB,EAAE;IACzB,OAAO,gCAAgC,CAAC,OAAO,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;AAChF,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,EAC5B,OAAO,GAGR,EAIC,EAAE;IACF,OAAO,WAAW,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC,CAAC"}
|