@ickb/sdk 1000.0.43 → 1000.0.71

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.
@@ -0,0 +1,178 @@
1
+ import { ccc } from "@ckb-ccc/core";
2
+ import { CapacityManager, SmartTransaction, type ValueComponents } from "@ickb/utils";
3
+ import { type LogicManager, type OwnedOwnerManager } from "@ickb/core";
4
+ import { Info, OrderManager, Ratio, type OrderCell, type OrderGroup } from "@ickb/order";
5
+ import { getConfig } from "./constants.js";
6
+ /**
7
+ * SDK for managing iCKB operations.
8
+ */
9
+ export declare class IckbSdk {
10
+ private readonly ownedOwner;
11
+ private readonly ickbLogic;
12
+ private readonly order;
13
+ private readonly capacity;
14
+ private readonly bots;
15
+ /**
16
+ * Creates an instance of IckbSdk.
17
+ *
18
+ * @param ownedOwner - The manager for owned owner operations.
19
+ * @param ickbLogic - The manager for iCKB logic operations.
20
+ * @param order - The manager for order operations.
21
+ * @param capacity - The capacity manager instance.
22
+ * @param bots - An array of bot lock scripts.
23
+ */
24
+ constructor(ownedOwner: OwnedOwnerManager, ickbLogic: LogicManager, order: OrderManager, capacity: CapacityManager, bots: ccc.Script[]);
25
+ /**
26
+ * Creates an instance of IckbSdk from script dependencies.
27
+ *
28
+ * @param args - Parameters matching those of getConfig.
29
+ * @returns A new instance of IckbSdk.
30
+ */
31
+ static from(...args: Parameters<typeof getConfig>): IckbSdk;
32
+ /**
33
+ * Previews the conversion between CKB and UDT.
34
+ *
35
+ * This method calculates a conversion preview using an exchange ratio midpoint.
36
+ * Optionally, a fee may be applied that influences the effective conversion rate,
37
+ * scaling the converted amount by (feeBase - fee) / feeBase.
38
+ *
39
+ * @param isCkb2Udt - Indicates the conversion direction:
40
+ * - true: Convert CKB to UDT.
41
+ * - false: Convert UDT to CKB.
42
+ * @param amounts - An object containing value components (amounts for CKB and UDT).
43
+ * @param system - The current system state containing exchange ratio, fee rate, tip, and order-related information.
44
+ * @param options - Optional parameters for fee and matching:
45
+ * - fee: The fee to apply in integer terms (defaults to 1n for 0.001% fee).
46
+ * - feeBase: The base used for fee scaling (defaults to 100000n).
47
+ *
48
+ * @returns An object with:
49
+ * - convertedAmount: The estimated converted amount as a FixedPoint.
50
+ * - ckbFee: The fee (or gain) in CKB, as a FixedPoint.
51
+ * - info: Additional conversion metadata.
52
+ * - maturity: Optional maturity information (as ccc.Num) if meets criteria.
53
+ */
54
+ static estimate(isCkb2Udt: boolean, amounts: ValueComponents, system: SystemState, options?: {
55
+ fee?: ccc.Num;
56
+ feeBase?: ccc.Num;
57
+ }): {
58
+ convertedAmount: ccc.FixedPoint;
59
+ ckbFee: ccc.FixedPoint;
60
+ info: Info;
61
+ maturity: ccc.Num | undefined;
62
+ };
63
+ /**
64
+ * Estimates the maturity for an order formatted as a Unix timestamp.
65
+ *
66
+ * Depending on the order type and amount remaining, the method calculates an estimated timestamp
67
+ * when the order (or part thereof) might be fulfilled.
68
+ *
69
+ * @param o - Either an OrderCell or an object containing order Info and value components.
70
+ * @param system - The current system state.
71
+ * @returns The Unix timestamp of estimated maturity as a bigint (in milliseconds) or undefined if not applicable.
72
+ */
73
+ static maturity(o: OrderCell | {
74
+ info: Info;
75
+ amounts: ValueComponents;
76
+ }, system: SystemState): bigint | undefined;
77
+ /**
78
+ * Mints a new order cell and appends it to the transaction.
79
+ *
80
+ * The method performs the following operations:
81
+ * - Creates order cell data using provided amounts and order information.
82
+ * - Adds required cell dependencies and UDT handlers to the transaction.
83
+ * - Appends the order cell to the transaction outputs.
84
+ *
85
+ * @param tx - The smart transaction to which the order cell is added.
86
+ * @param user - The user, represented either as a Signer or a Script.
87
+ * @param info - The order information meta data (usually computed via OrderManager.convert).
88
+ * @param amounts - The value components for the order, including:
89
+ * - ckbValue: The CKB amount (may include an internal surplus).
90
+ * - udtValue: The UDT amount.
91
+ *
92
+ * @returns A Promise resolving to void.
93
+ */
94
+ request(tx: SmartTransaction, user: ccc.Signer | ccc.Script, info: Info, amounts: ValueComponents): Promise<void>;
95
+ /**
96
+ * Melts (cancels) the specified order groups.
97
+ *
98
+ * For each order group, if the option is set to process fulfilled orders only,
99
+ * it filters accordingly. Then, for every valid group, the master and order cells are added
100
+ * as inputs to the transaction.
101
+ *
102
+ * @param tx - The smart transaction to which the inputs are added.
103
+ * @param groups - An array of order groups to be melted.
104
+ * @param options - Optional parameters:
105
+ * - isFulfilledOnly: If true, only order groups with fully or partially fulfilled orders are processed.
106
+ *
107
+ * @returns void
108
+ */
109
+ collect(tx: SmartTransaction, groups: OrderGroup[], options?: {
110
+ isFulfilledOnly?: boolean;
111
+ }): void;
112
+ /**
113
+ * Retrieves the L1 state from the blockchain.
114
+ *
115
+ * The method performs the following:
116
+ * - Obtains the current block tip and calculates the exchange ratio.
117
+ * - Fetches available CKB and the maturing CKB based on bot capacities and deposit snapshots.
118
+ * - Filters orders into user-owned and system orders based on the provided locks.
119
+ * - Estimates user-owned orders maturity.
120
+ *
121
+ * @param client - The blockchain client interface.
122
+ * @param locks - An array of lock scripts used to filter user cells.
123
+ * @returns A promise that resolves to an object containing:
124
+ * - system: The system state (fee rate, tip header, exchange ratio, order pool, etc.).
125
+ * - user: The user's orders grouped as an array of OrderGroup.
126
+ */
127
+ getL1State(client: ccc.Client, locks: ccc.Script[]): Promise<{
128
+ system: SystemState;
129
+ user: {
130
+ orders: OrderGroup[];
131
+ };
132
+ }>;
133
+ /**
134
+ * Retrieves available CKB and maturing CKB values from the blockchain.
135
+ *
136
+ * This method:
137
+ * - Fetches bot withdrawal requests and deposit snapshots.
138
+ * - Aggregates available CKB balances from bot capacities.
139
+ * - Calculates maturing CKB values (with their expected maturity timestamps)
140
+ * based on deposit pool snapshots or via direct deposit cell lookups.
141
+ * - Sorts and cumulatively sums the maturing values for later lookup.
142
+ *
143
+ * @param client - The blockchain client used for fetching data.
144
+ * @param tip - The current block tip header.
145
+ * @returns A Promise that resolves with:
146
+ * - ckbAvailable: The total available CKB (as a FixedPoint).
147
+ * - ckbMaturing: An array of maturing CKB objects containing the cumulative CKB
148
+ * and the associated maturity timestamp.
149
+ */
150
+ private getCkb;
151
+ }
152
+ /**
153
+ * Represents the state of the system.
154
+ */
155
+ export interface SystemState {
156
+ /** The fee rate for transactions. */
157
+ feeRate: ccc.Num;
158
+ /** The tip for the current block header. */
159
+ tip: ccc.ClientBlockHeader;
160
+ /** The exchange ratio between CKB and UDT. */
161
+ exchangeRatio: Ratio;
162
+ /** The order pool containing order cells matching system criteria. */
163
+ orderPool: OrderCell[];
164
+ /** The total available CKB (as FixedPoint). */
165
+ ckbAvailable: ccc.FixedPoint;
166
+ /** Array of CKB maturing entries with cumulative amounts and maturity timestamps. */
167
+ ckbMaturing: CkbCumulative[];
168
+ }
169
+ /**
170
+ * Represents a cumulative CKB maturing entry.
171
+ */
172
+ export interface CkbCumulative {
173
+ /** The cumulative CKB value (as FixedPoint) up to this maturity. */
174
+ ckbCumulative: ccc.FixedPoint;
175
+ /** The maturity timestamp (as ccc.Num). */
176
+ maturity: ccc.Num;
177
+ }
178
+ //# sourceMappingURL=sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAEL,eAAe,EACf,gBAAgB,EAEhB,KAAK,eAAe,EAIrB,MAAM,aAAa,CAAC;AACrB,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,EACL,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C;;GAEG;AACH,qBAAa,OAAO;IAWhB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC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AAO,CACL,EAAE,EAAE,gBAAgB,EACpB,MAAM,EAAE,UAAU,EAAE,EACpB,OAAO,CAAC,EAAE;QACR,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B,GACA,IAAI;IAIP;;;;;;;;;;;;;;OAcG;IACG,UAAU,CACd,MAAM,EAAE,GAAG,CAAC,MAAM,EAClB,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,GAClB,OAAO,CAAC;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE;YAAE,MAAM,EAAE,UAAU,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;IAmDnE;;;;;;;;;;;;;;;;OAgBG;YACW,MAAM;CA8HrB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,qCAAqC;IACrC,OAAO,EAAE,GAAG,CAAC,GAAG,CAAC;IAEjB,4CAA4C;IAC5C,GAAG,EAAE,GAAG,CAAC,iBAAiB,CAAC;IAE3B,8CAA8C;IAC9C,aAAa,EAAE,KAAK,CAAC;IAErB,sEAAsE;IACtE,SAAS,EAAE,SAAS,EAAE,CAAC;IAEvB,+CAA+C;IAC/C,YAAY,EAAE,GAAG,CAAC,UAAU,CAAC;IAE7B,qFAAqF;IACrF,WAAW,EAAE,aAAa,EAAE,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,oEAAoE;IACpE,aAAa,EAAE,GAAG,CAAC,UAAU,CAAC;IAC9B,2CAA2C;IAC3C,QAAQ,EAAE,GAAG,CAAC,GAAG,CAAC;CACnB"}
@@ -0,0 +1,358 @@
1
+ import { ccc } from "@ckb-ccc/core";
2
+ import { collect, binarySearch, hexFrom, getHeader, Epoch, } from "@ickb/utils";
3
+ import { convert, ICKB_DEPOSIT_CAP, ickbExchangeRatio, } from "@ickb/core";
4
+ import { Info, OrderManager, Ratio, } from "@ickb/order";
5
+ import { getConfig } from "./constants.js";
6
+ import { PoolSnapshot } from "./codec.js";
7
+ /**
8
+ * SDK for managing iCKB operations.
9
+ */
10
+ export class IckbSdk {
11
+ /**
12
+ * Creates an instance of IckbSdk.
13
+ *
14
+ * @param ownedOwner - The manager for owned owner operations.
15
+ * @param ickbLogic - The manager for iCKB logic operations.
16
+ * @param order - The manager for order operations.
17
+ * @param capacity - The capacity manager instance.
18
+ * @param bots - An array of bot lock scripts.
19
+ */
20
+ constructor(ownedOwner, ickbLogic, order, capacity, bots) {
21
+ this.ownedOwner = ownedOwner;
22
+ this.ickbLogic = ickbLogic;
23
+ this.order = order;
24
+ this.capacity = capacity;
25
+ this.bots = bots;
26
+ }
27
+ /**
28
+ * Creates an instance of IckbSdk from script dependencies.
29
+ *
30
+ * @param args - Parameters matching those of getConfig.
31
+ * @returns A new instance of IckbSdk.
32
+ */
33
+ static from(...args) {
34
+ const { managers: { ownedOwner, ickbLogic, order, capacity }, bots, } = getConfig(...args);
35
+ return new IckbSdk(ownedOwner, ickbLogic, order, capacity, bots);
36
+ }
37
+ /**
38
+ * Previews the conversion between CKB and UDT.
39
+ *
40
+ * This method calculates a conversion preview using an exchange ratio midpoint.
41
+ * Optionally, a fee may be applied that influences the effective conversion rate,
42
+ * scaling the converted amount by (feeBase - fee) / feeBase.
43
+ *
44
+ * @param isCkb2Udt - Indicates the conversion direction:
45
+ * - true: Convert CKB to UDT.
46
+ * - false: Convert UDT to CKB.
47
+ * @param amounts - An object containing value components (amounts for CKB and UDT).
48
+ * @param system - The current system state containing exchange ratio, fee rate, tip, and order-related information.
49
+ * @param options - Optional parameters for fee and matching:
50
+ * - fee: The fee to apply in integer terms (defaults to 1n for 0.001% fee).
51
+ * - feeBase: The base used for fee scaling (defaults to 100000n).
52
+ *
53
+ * @returns An object with:
54
+ * - convertedAmount: The estimated converted amount as a FixedPoint.
55
+ * - ckbFee: The fee (or gain) in CKB, as a FixedPoint.
56
+ * - info: Additional conversion metadata.
57
+ * - maturity: Optional maturity information (as ccc.Num) if meets criteria.
58
+ */
59
+ static estimate(isCkb2Udt, amounts, system, options) {
60
+ // Apply a 0.001% default fee if none provided.
61
+ options = {
62
+ fee: 1n,
63
+ feeBase: 100000n,
64
+ ...options,
65
+ };
66
+ const { convertedAmount, ckbFee, info } = OrderManager.convert(isCkb2Udt, system.exchangeRatio, amounts, options);
67
+ // If the fee meets a threshold, calculate the order maturity; otherwise, maturity is undefined.
68
+ const maturity = ckbFee >= 10n * system.feeRate
69
+ ? IckbSdk.maturity({ info, amounts }, system)
70
+ : undefined;
71
+ return { convertedAmount, ckbFee, info, maturity };
72
+ }
73
+ /**
74
+ * Estimates the maturity for an order formatted as a Unix timestamp.
75
+ *
76
+ * Depending on the order type and amount remaining, the method calculates an estimated timestamp
77
+ * when the order (or part thereof) might be fulfilled.
78
+ *
79
+ * @param o - Either an OrderCell or an object containing order Info and value components.
80
+ * @param system - The current system state.
81
+ * @returns The Unix timestamp of estimated maturity as a bigint (in milliseconds) or undefined if not applicable.
82
+ */
83
+ static maturity(o, system) {
84
+ const info = "info" in o ? o.info : o.data.info;
85
+ const amounts = "amounts" in o
86
+ ? o.amounts
87
+ : { ckbValue: o.ckbUnoccupied, udtValue: o.udtValue };
88
+ // Dual-ratio orders have no fixed maturity.
89
+ if (info.isDualRatio()) {
90
+ return;
91
+ }
92
+ const isCkb2Udt = info.isCkb2Udt();
93
+ const amount = isCkb2Udt ? amounts.ckbValue : amounts.udtValue;
94
+ const ratio = isCkb2Udt ? info.ckbToUdt : info.udtToCkb;
95
+ // If order is already fulfilled.
96
+ if (amount === 0n) {
97
+ return 0n;
98
+ }
99
+ const { tip, exchangeRatio, orderPool, ckbAvailable, ckbMaturing } = system;
100
+ // Create a reference ratio instance for comparison.
101
+ const b = new Info(ratio, ratio, 1);
102
+ let ckb = isCkb2Udt ? amount : 0n;
103
+ let udt = isCkb2Udt ? 0n : amount;
104
+ for (const o of orderPool) {
105
+ const a = o.data.info;
106
+ if (a.isCkb2Udt()) {
107
+ // If not isCkb2Udt or a worse ratio, add available CKB.
108
+ if (!isCkb2Udt || a.ckb2UdtCompare(b) < 0) {
109
+ ckb += o.ckbUnoccupied;
110
+ }
111
+ }
112
+ else {
113
+ // Conversely for UDT to CKB orders.
114
+ if (isCkb2Udt || a.udt2CkbCompare(b) < 0) {
115
+ udt += o.udtValue;
116
+ }
117
+ }
118
+ }
119
+ // Adjust ckb by the converted UDT amount.
120
+ ckb -= convert(false, udt, exchangeRatio);
121
+ // Minimum maturity of 10 minutes (in milliseconds).
122
+ let maturity = 10n * 60n * 1000n;
123
+ if (isCkb2Udt) {
124
+ // For CKB to UDT orders, extend maturity based on the CKB amount.
125
+ if (ckb > 0n) {
126
+ maturity *= 1n + ckb / ccc.fixedPointFrom("200000");
127
+ }
128
+ return maturity + ("info" in o ? BigInt(Date.now()) : tip.timestamp);
129
+ }
130
+ // For UDT to CKB orders, add available CKB.
131
+ ckb += ckbAvailable;
132
+ if (ckb >= 0) {
133
+ return maturity + ("info" in o ? BigInt(Date.now()) : tip.timestamp);
134
+ }
135
+ // Find the earliest maturity in the ckbMaturing array that satisfies the required CKB.
136
+ const ckbNeeded = -ckb;
137
+ const i = binarySearch(ckbMaturing.length,
138
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
139
+ (n) => ckbMaturing[n].ckbCumulative >= ckbNeeded);
140
+ return ckbMaturing[i]?.maturity;
141
+ }
142
+ /**
143
+ * Mints a new order cell and appends it to the transaction.
144
+ *
145
+ * The method performs the following operations:
146
+ * - Creates order cell data using provided amounts and order information.
147
+ * - Adds required cell dependencies and UDT handlers to the transaction.
148
+ * - Appends the order cell to the transaction outputs.
149
+ *
150
+ * @param tx - The smart transaction to which the order cell is added.
151
+ * @param user - The user, represented either as a Signer or a Script.
152
+ * @param info - The order information meta data (usually computed via OrderManager.convert).
153
+ * @param amounts - The value components for the order, including:
154
+ * - ckbValue: The CKB amount (may include an internal surplus).
155
+ * - udtValue: The UDT amount.
156
+ *
157
+ * @returns A Promise resolving to void.
158
+ */
159
+ async request(tx, user, info, amounts) {
160
+ // If the user is provided as a Signer, extract the recommended lock script.
161
+ user =
162
+ "codeHash" in user
163
+ ? user
164
+ : (await user.getRecommendedAddressObj()).script;
165
+ this.order.mint(tx, user, info, amounts);
166
+ }
167
+ /**
168
+ * Melts (cancels) the specified order groups.
169
+ *
170
+ * For each order group, if the option is set to process fulfilled orders only,
171
+ * it filters accordingly. Then, for every valid group, the master and order cells are added
172
+ * as inputs to the transaction.
173
+ *
174
+ * @param tx - The smart transaction to which the inputs are added.
175
+ * @param groups - An array of order groups to be melted.
176
+ * @param options - Optional parameters:
177
+ * - isFulfilledOnly: If true, only order groups with fully or partially fulfilled orders are processed.
178
+ *
179
+ * @returns void
180
+ */
181
+ collect(tx, groups, options) {
182
+ this.order.melt(tx, groups, options);
183
+ }
184
+ /**
185
+ * Retrieves the L1 state from the blockchain.
186
+ *
187
+ * The method performs the following:
188
+ * - Obtains the current block tip and calculates the exchange ratio.
189
+ * - Fetches available CKB and the maturing CKB based on bot capacities and deposit snapshots.
190
+ * - Filters orders into user-owned and system orders based on the provided locks.
191
+ * - Estimates user-owned orders maturity.
192
+ *
193
+ * @param client - The blockchain client interface.
194
+ * @param locks - An array of lock scripts used to filter user cells.
195
+ * @returns A promise that resolves to an object containing:
196
+ * - system: The system state (fee rate, tip header, exchange ratio, order pool, etc.).
197
+ * - user: The user's orders grouped as an array of OrderGroup.
198
+ */
199
+ async getL1State(client, locks) {
200
+ const tip = await client.getTipHeader();
201
+ const exchangeRatio = Ratio.from(ickbExchangeRatio(tip));
202
+ // Parallel fetching of system components.
203
+ const [{ ckbAvailable, ckbMaturing }, orders, feeRate] = await Promise.all([
204
+ this.getCkb(client, tip),
205
+ collect(this.order.findOrders(client)),
206
+ client.getFeeRate(),
207
+ ]);
208
+ const midInfo = new Info(exchangeRatio, exchangeRatio, 1);
209
+ const userOrders = [];
210
+ const systemOrders = [];
211
+ for (const group of orders) {
212
+ if (group.isOwner(...locks)) {
213
+ userOrders.push(group);
214
+ }
215
+ const { order } = group;
216
+ const info = order.data.info;
217
+ if ((order.isCkb2UdtMatchable() && info.ckb2UdtCompare(midInfo) < 0) ||
218
+ (order.isUdt2CkbMatchable() && info.udt2CkbCompare(midInfo) < 0)) {
219
+ systemOrders.push(order);
220
+ }
221
+ }
222
+ const system = {
223
+ feeRate,
224
+ tip,
225
+ exchangeRatio,
226
+ orderPool: systemOrders,
227
+ ckbAvailable,
228
+ ckbMaturing,
229
+ };
230
+ // Estimates user orders maturity.
231
+ for (const { order } of userOrders) {
232
+ order.maturity = IckbSdk.maturity(order, system);
233
+ }
234
+ return {
235
+ system,
236
+ user: {
237
+ orders: userOrders,
238
+ },
239
+ };
240
+ }
241
+ /**
242
+ * Retrieves available CKB and maturing CKB values from the blockchain.
243
+ *
244
+ * This method:
245
+ * - Fetches bot withdrawal requests and deposit snapshots.
246
+ * - Aggregates available CKB balances from bot capacities.
247
+ * - Calculates maturing CKB values (with their expected maturity timestamps)
248
+ * based on deposit pool snapshots or via direct deposit cell lookups.
249
+ * - Sorts and cumulatively sums the maturing values for later lookup.
250
+ *
251
+ * @param client - The blockchain client used for fetching data.
252
+ * @param tip - The current block tip header.
253
+ * @returns A Promise that resolves with:
254
+ * - ckbAvailable: The total available CKB (as a FixedPoint).
255
+ * - ckbMaturing: An array of maturing CKB objects containing the cumulative CKB
256
+ * and the associated maturity timestamp.
257
+ */
258
+ async getCkb(client, tip) {
259
+ const opts = {
260
+ onChain: true,
261
+ tip,
262
+ };
263
+ // Start fetching bot iCKB withdrawal requests.
264
+ const promiseBotWithdrawals = collect(this.ownedOwner.findWithdrawalGroups(client, this.bots, opts));
265
+ // Initialize deposit pool snapshot.
266
+ let poolSnapshotHex = "0x";
267
+ let poolSnapshotEpoch = Epoch.from([0n, 0n, 1n]);
268
+ // Map to track each bot's available CKB (minus a reserved amount for internal operations).
269
+ const bot2Ckb = new Map();
270
+ const reserved = -ccc.fixedPointFrom("2000");
271
+ for await (const c of this.capacity.findCapacities(client, this.bots, opts)) {
272
+ const key = hexFrom(c.cell.cellOutput.lock);
273
+ const ckb = (bot2Ckb.get(key) ?? reserved) + c.ckbValue;
274
+ bot2Ckb.set(key, ckb);
275
+ // Find the most recent deposit pool snapshot from bot cell output data.
276
+ const outputData = c.cell.outputData;
277
+ if (outputData.length % 256 === 2) {
278
+ const h = await getHeader(client, {
279
+ type: "txHash",
280
+ value: c.cell.outPoint.txHash,
281
+ });
282
+ const e = Epoch.from(h.epoch);
283
+ if (poolSnapshotEpoch.compare(e) < 0) {
284
+ poolSnapshotHex = outputData;
285
+ poolSnapshotEpoch = e;
286
+ }
287
+ }
288
+ }
289
+ const ckbMaturing = new Array();
290
+ for (const wr of await promiseBotWithdrawals) {
291
+ if (wr.owned.isReady) {
292
+ // Update the bot's CKB based on withdrawal if the bot is ready.
293
+ const key = hexFrom(wr.owner.cell.cellOutput.lock);
294
+ const ckb = (bot2Ckb.get(key) ?? reserved) + wr.ckbValue;
295
+ bot2Ckb.set(key, ckb);
296
+ continue;
297
+ }
298
+ // Otherwise, add to maturing amounts.
299
+ ckbMaturing.push({
300
+ ckbValue: wr.ckbValue,
301
+ maturity: wr.owned.maturity.toUnix(tip),
302
+ });
303
+ }
304
+ // Sum available CKB across all bot lock scripts.
305
+ let ckbAvailable = 0n;
306
+ for (const ckb of bot2Ckb.values()) {
307
+ if (ckb > 0n) {
308
+ ckbAvailable += ckb;
309
+ }
310
+ }
311
+ // Estimate available CKB from deposit pool snapshot.
312
+ const tipEpoch = Epoch.from(tip.epoch);
313
+ const oneCycle = Epoch.from([180n, 0n, 1n]);
314
+ if (poolSnapshotHex !== "0x") {
315
+ const eNumber = tip.epoch[0];
316
+ let start = Epoch.from([eNumber - (eNumber % 180n), 0n, 1n]);
317
+ const step = Epoch.from([0n, 180n, 1024n]);
318
+ const depositSize = convert(false, ICKB_DEPOSIT_CAP, tip);
319
+ for (const binAmount of PoolSnapshot.decode(poolSnapshotHex)) {
320
+ const end = start.add(step);
321
+ if (binAmount > 0) {
322
+ ckbMaturing.push({
323
+ ckbValue: BigInt(binAmount) * depositSize,
324
+ maturity: tipEpoch.compare(tipEpoch) < 0
325
+ ? // If the bin has already started, assume worst-case timing.
326
+ end.add(oneCycle).toUnix(tip)
327
+ : // Otherwise, use the bin end as the maturity.
328
+ end.toUnix(tip),
329
+ });
330
+ }
331
+ start = end;
332
+ }
333
+ }
334
+ else {
335
+ // Without snapshot data, fetch deposits directly.
336
+ for await (const d of this.ickbLogic.findDeposits(client, opts)) {
337
+ ckbMaturing.push({
338
+ ckbValue: d.ckbValue,
339
+ maturity: d.maturity.toUnix(tip),
340
+ });
341
+ }
342
+ }
343
+ // Sort maturing CKB entries by their maturity timestamp.
344
+ ckbMaturing.sort((a, b) => Number(a.maturity - b.maturity));
345
+ // Calculate cumulative maturing CKB values.
346
+ let cumulative = 0n;
347
+ const ckbCumulativeMaturing = [];
348
+ for (const { ckbValue, maturity } of ckbMaturing) {
349
+ cumulative += ckbValue;
350
+ ckbCumulativeMaturing.push({ ckbCumulative: cumulative, maturity });
351
+ }
352
+ return {
353
+ ckbAvailable,
354
+ ckbMaturing: ckbCumulativeMaturing,
355
+ };
356
+ }
357
+ }
358
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EACL,OAAO,EAGP,YAAY,EAEZ,OAAO,EACP,SAAS,EACT,KAAK,GACN,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,iBAAiB,GAGlB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,KAAK,GAGN,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,OAAO;IAClB;;;;;;;;O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;YACd,CAAC;QACH,CAAC;aAAM,CAAC;YACN,kDAAkD;YAClD,IAAI,KAAK,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;gBAChE,WAAW,CAAC,IAAI,CAAC;oBACf,QAAQ,EAAE,CAAC,CAAC,QAAQ;oBACpB,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC;iBACjC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,yDAAyD;QACzD,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE5D,4CAA4C;QAC5C,IAAI,UAAU,GAAG,EAAE,CAAC;QACpB,MAAM,qBAAqB,GAAoB,EAAE,CAAC;QAClD,KAAK,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,WAAW,EAAE,CAAC;YACjD,UAAU,IAAI,QAAQ,CAAC;YACvB,qBAAqB,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QACtE,CAAC;QAED,OAAO;YACL,YAAY;YACZ,WAAW,EAAE,qBAAqB;SACnC,CAAC;IACJ,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ickb/sdk",
3
- "version": "1000.0.43",
3
+ "version": "1000.0.71",
4
4
  "description": "iCKB SDK built on top of CCC",
5
5
  "author": "phroi",
6
6
  "license": "MIT",
@@ -23,18 +23,18 @@
23
23
  "provenance": true
24
24
  },
25
25
  "devDependencies": {
26
- "@eslint/js": "^9.25.1",
27
- "eslint": "^9.25.1",
26
+ "@eslint/js": "^9.28.0",
27
+ "eslint": "^9.28.0",
28
28
  "prettier": "^3.5.3",
29
29
  "typescript": "^5.8.3",
30
- "typescript-eslint": "^8.31.1"
30
+ "typescript-eslint": "^8.33.0"
31
31
  },
32
32
  "dependencies": {
33
- "@ckb-ccc/core": "^1.8.0",
34
- "@ickb/core": "^1000.0.43",
35
- "@ickb/dao": "^1000.0.41",
36
- "@ickb/order": "^1000.0.43",
37
- "@ickb/utils": "^1000.0.43"
33
+ "@ckb-ccc/core": "^1.8.1",
34
+ "@ickb/core": "^1000.0.71",
35
+ "@ickb/dao": "^1000.0.71",
36
+ "@ickb/order": "^1000.0.71",
37
+ "@ickb/utils": "^1000.0.71"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "pnpm run build:esm && pnpm run build:cjs && node dist/cjs/index.js",