@invisible-labs/sdk 0.6.0-devnet.2 → 0.6.0-devnet.4

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.
Files changed (45) hide show
  1. package/README.md +186 -70
  2. package/dist/.invisible-sdk-build-target.json +7 -0
  3. package/dist/{chunk-TQNNTV5F.js → chunk-4X5OCCQW.js} +3 -3
  4. package/dist/{chunk-TQNNTV5F.js.map → chunk-4X5OCCQW.js.map} +1 -1
  5. package/dist/{chunk-7DSVN3MV.js → chunk-5NNEO7IK.js} +41 -36
  6. package/dist/chunk-5NNEO7IK.js.map +1 -0
  7. package/dist/chunk-BRDLLGCZ.js +59 -0
  8. package/dist/chunk-BRDLLGCZ.js.map +1 -0
  9. package/dist/{chunk-NCY4FCYU.js → chunk-DIA6U2CV.js} +19 -3
  10. package/dist/chunk-DIA6U2CV.js.map +1 -0
  11. package/dist/{chunk-LBC7ALYO.js → chunk-E4DCEDAG.js} +177 -12
  12. package/dist/chunk-E4DCEDAG.js.map +1 -0
  13. package/dist/{chunk-OHIM2YWU.js → chunk-GHBQF3A7.js} +2 -2
  14. package/dist/chunk-GHBQF3A7.js.map +1 -0
  15. package/dist/{chunk-SZAYO2L5.js → chunk-NHEHCUS5.js} +3 -3
  16. package/dist/{chunk-SZAYO2L5.js.map → chunk-NHEHCUS5.js.map} +1 -1
  17. package/dist/{chunk-XUWBGET5.js → chunk-UADJCUPK.js} +125 -18
  18. package/dist/chunk-UADJCUPK.js.map +1 -0
  19. package/dist/{chunk-JRMKCE3S.js → chunk-V5HXJRBW.js} +3 -3
  20. package/dist/{chunk-JRMKCE3S.js.map → chunk-V5HXJRBW.js.map} +1 -1
  21. package/dist/{coordinator-7Y45MCCZ.js → coordinator-ZNLGAYXD.js} +3 -3
  22. package/dist/{coordinator-7Y45MCCZ.js.map → coordinator-ZNLGAYXD.js.map} +1 -1
  23. package/dist/events.js +3 -3
  24. package/dist/index.d.ts +62 -300
  25. package/dist/index.js +98 -43
  26. package/dist/index.js.map +1 -1
  27. package/dist/lp.d.ts +51 -10
  28. package/dist/lp.js +313 -86
  29. package/dist/lp.js.map +1 -1
  30. package/dist/presets.d.ts +5 -42
  31. package/dist/presets.js +11 -62
  32. package/dist/presets.js.map +1 -1
  33. package/dist/stats.js +1 -1
  34. package/dist/storage.js +1 -1
  35. package/dist/{createSession-D3ym-Ira.d.ts → types.generated-DJBTjLpP.d.ts} +37 -53
  36. package/dist/user.d.ts +94 -112
  37. package/dist/user.js +649 -248
  38. package/dist/user.js.map +1 -1
  39. package/package.json +2 -28
  40. package/dist/chunk-7DSVN3MV.js.map +0 -1
  41. package/dist/chunk-LBC7ALYO.js.map +0 -1
  42. package/dist/chunk-NCY4FCYU.js.map +0 -1
  43. package/dist/chunk-OHIM2YWU.js.map +0 -1
  44. package/dist/chunk-XUWBGET5.js.map +0 -1
  45. package/dist/types.generated-CHGSbmLp.d.ts +0 -67
package/dist/lp.js CHANGED
@@ -1,8 +1,8 @@
1
- import { isValidLpPositionId, LP_DEFAULT_REFILL_BATCH_SIZE, LP_DEFAULT_TARGET_SHARDS, LP_MAX_TARGET_SHARDS, LP_MAX_REFILL_BATCH_SIZE } from './chunk-TQNNTV5F.js';
2
- import { publicKey, assertAttested, lamports } from './chunk-SZAYO2L5.js';
3
- import { requestEnvelope } from './chunk-XUWBGET5.js';
4
- import { getSessionState } from './chunk-JRMKCE3S.js';
5
- import { CommandError, PolicyValidationError, RoutingError, LpLifecycleError } from './chunk-OHIM2YWU.js';
1
+ import { isValidLpPositionId, LP_DEFAULT_REFILL_BATCH_SIZE, LP_DEFAULT_TARGET_SHARDS, LP_MAX_TARGET_SHARDS, LP_MAX_REFILL_BATCH_SIZE } from './chunk-4X5OCCQW.js';
2
+ import { publicKey, assertAttested, lamports } from './chunk-NHEHCUS5.js';
3
+ import { requestEnvelope } from './chunk-UADJCUPK.js';
4
+ import { getSessionState } from './chunk-V5HXJRBW.js';
5
+ import { CommandError, PolicyValidationError, TransportError, RoutingError, LpLifecycleError } from './chunk-GHBQF3A7.js';
6
6
  import './chunk-VR6T6OJS.js';
7
7
 
8
8
  // src/lp/positionCode.ts
@@ -172,14 +172,8 @@ function getCrypto() {
172
172
  var SINGLE_DESTINATION_WITHDRAWAL_MESSAGE = "single-destination withdrawal is privacy-degrading; pass allowManyToOne: true to acknowledge";
173
173
  var DESTINATION_SOURCE_COUNT_MESSAGE = "LP withdrawal requires one destination per withdrawable source unless allowManyToOne is true";
174
174
  var SOURCE_COUNT_MESSAGE = "LP withdrawal source count must be a positive integer";
175
- function validateLpWithdrawalPlan(input) {
176
- const {
177
- depositPrincipalLamports,
178
- earnedFeeLamports,
179
- destinationAddresses,
180
- allowManyToOne,
181
- sourceCount
182
- } = input;
175
+ function validateLpWithdrawalClaim(input) {
176
+ const { depositPrincipalLamports, earnedFeeLamports } = input;
183
177
  lamports(depositPrincipalLamports);
184
178
  lamports(earnedFeeLamports);
185
179
  if (depositPrincipalLamports === 0 && earnedFeeLamports === 0) {
@@ -188,6 +182,16 @@ function validateLpWithdrawalPlan(input) {
188
182
  "LP withdrawal requires a non-zero principal or earned-fee claim"
189
183
  );
190
184
  }
185
+ }
186
+ function validateLpWithdrawalPlan(input) {
187
+ const {
188
+ depositPrincipalLamports,
189
+ earnedFeeLamports,
190
+ destinationAddresses,
191
+ allowManyToOne,
192
+ sourceCount
193
+ } = input;
194
+ validateLpWithdrawalClaim({ depositPrincipalLamports, earnedFeeLamports });
191
195
  validateDestinationAddresses(destinationAddresses);
192
196
  if (sourceCount !== void 0 && (!Number.isInteger(sourceCount) || sourceCount < 1)) {
193
197
  throw new PolicyValidationError("INVALID_WITHDRAWAL_PLAN", SOURCE_COUNT_MESSAGE);
@@ -225,6 +229,7 @@ function validateDestinationAddresses(destinationAddresses) {
225
229
  // src/lp/coordinatorClient.ts
226
230
  var COMMAND_TTL_MS = 3e4;
227
231
  var LP_COMMAND_REQUEST_TIMEOUT_MS = 12e4;
232
+ var LP_DKG_ABORT_REQUEST_TIMEOUT_MS = 1e4;
228
233
  var encoder2 = new TextEncoder();
229
234
  var protocolPromise = null;
230
235
  function createLpCoordinatorClient(session) {
@@ -232,6 +237,9 @@ function createLpCoordinatorClient(session) {
232
237
  initDkg(input, auth) {
233
238
  return initDkg(session, input, auth);
234
239
  },
240
+ abortDkgSessions(lpPositionId, auth) {
241
+ return abortDkgSessions(session, lpPositionId, auth);
242
+ },
235
243
  dkgRound1(input, auth) {
236
244
  return dkgRound1(session, input, auth);
237
245
  },
@@ -241,8 +249,8 @@ function createLpCoordinatorClient(session) {
241
249
  openPosition(input, auth) {
242
250
  return openPosition(session, input, auth);
243
251
  },
244
- getPosition(lpPositionId, auth) {
245
- return getPosition(session, lpPositionId, auth);
252
+ getPosition(lpPositionId, auth, options) {
253
+ return getPosition(session, lpPositionId, auth, options);
246
254
  },
247
255
  finalizeDkgBatch(input, auth) {
248
256
  return finalizeDkgBatch(session, input, auth);
@@ -281,6 +289,21 @@ async function initDkg(session, input, auth) {
281
289
  if (response.case !== "dkgInit") throw new Error("Unexpected LP DKG init response");
282
290
  return { sessionId: response.value.session_id };
283
291
  }
292
+ async function abortDkgSessions(session, lpPositionId, auth) {
293
+ const response = await requestForPosition(
294
+ session,
295
+ lpPositionId,
296
+ auth,
297
+ "dkg_abort",
298
+ {
299
+ case: "dkgAbort",
300
+ value: {}
301
+ },
302
+ { timeoutMs: LP_DKG_ABORT_REQUEST_TIMEOUT_MS }
303
+ );
304
+ if (response.case !== "dkgAbort") throw new Error("Unexpected LP DKG abort response");
305
+ return { abortedSessionCount: response.value.aborted_session_count };
306
+ }
284
307
  async function dkgRound1(session, input, auth) {
285
308
  const response = await request(session, auth, "dkg_round1", {
286
309
  case: "dkgRound1",
@@ -329,15 +352,23 @@ async function openPosition(session, input, auth) {
329
352
  });
330
353
  return expectPosition(response);
331
354
  }
332
- async function getPosition(session, lpPositionId, auth) {
355
+ async function getPosition(session, lpPositionId, auth, options = {}) {
333
356
  let cursor;
334
357
  let position;
335
358
  const seenCursors = /* @__PURE__ */ new Set();
336
359
  for (; ; ) {
337
- const response = await requestForPosition(session, lpPositionId, auth, "position_get", {
338
- case: "positionGet",
339
- value: cursor === void 0 ? {} : { redemption_history_cursor: cursor }
340
- });
360
+ const pageOptions = lpPositionPageRequestOptions(options);
361
+ const response = await requestForPosition(
362
+ session,
363
+ lpPositionId,
364
+ auth,
365
+ "position_get",
366
+ {
367
+ case: "positionGet",
368
+ value: cursor === void 0 ? {} : { redemption_history_cursor: cursor }
369
+ },
370
+ pageOptions
371
+ );
341
372
  const page = expectPosition(response);
342
373
  const mergedPosition = position === void 0 ? page : mergePositionHistoryPages(position, page);
343
374
  position = mergedPosition;
@@ -354,6 +385,18 @@ async function getPosition(session, lpPositionId, auth) {
354
385
  cursor = nextCursor;
355
386
  }
356
387
  }
388
+ function lpPositionPageRequestOptions(options) {
389
+ if (options.deadlineMs === void 0) return options;
390
+ const remainingMs = options.deadlineMs - Date.now();
391
+ if (remainingMs <= 0) {
392
+ throw new CommandError("REJECTED_STALE_JOB", "LP position observation deadline elapsed");
393
+ }
394
+ return {
395
+ deadlineMs: options.deadlineMs,
396
+ signal: options.signal,
397
+ timeoutMs: Math.min(options.timeoutMs ?? LP_COMMAND_REQUEST_TIMEOUT_MS, remainingMs)
398
+ };
399
+ }
357
400
  async function finalizeDkgBatch(session, input, auth) {
358
401
  const response = await requestForPosition(session, input.lpPositionId, auth, "dkg_finalize", {
359
402
  case: "dkgFinalize",
@@ -442,41 +485,64 @@ async function makeAvailable(session, input, auth) {
442
485
  async function executeWithdrawal(session, input, auth) {
443
486
  validateLpWithdrawalPlan({
444
487
  destinationAddresses: input.destinationAddresses,
445
- depositPrincipalLamports: input.depositPrincipalLamports,
446
- earnedFeeLamports: input.earnedFeeLamports,
447
- allowManyToOne: input.allowManyToOne
488
+ depositPrincipalLamports: input.withdrawalMode === "max_available" ? 1 : input.depositPrincipalLamports,
489
+ earnedFeeLamports: input.withdrawalMode === "max_available" ? 0 : input.earnedFeeLamports,
490
+ // Max mode deliberately does not preview source count. The coordinator
491
+ // owns the accepted split, so local destination validation must not reject
492
+ // a one-destination request based on an unknown current source count.
493
+ allowManyToOne: input.withdrawalMode === "max_available" || input.allowManyToOne
448
494
  });
449
495
  const response = await requestForPosition(session, input.lpPositionId, auth, "withdraw_request", {
450
496
  case: "withdrawRequest",
451
497
  value: {
452
498
  destination_addresses: input.destinationAddresses,
453
- deposit_principal_lamports: input.depositPrincipalLamports,
454
- earned_fee_lamports: input.earnedFeeLamports,
499
+ deposit_principal_lamports: input.withdrawalMode === "max_available" ? 0 : input.depositPrincipalLamports,
500
+ earned_fee_lamports: input.withdrawalMode === "max_available" ? 0 : input.earnedFeeLamports,
501
+ withdrawal_mode: input.withdrawalMode,
455
502
  requested_at_ms: input.requestedAtMs
456
503
  }
457
504
  });
458
505
  if (response.case !== "withdrawalExecution") {
459
506
  throw new Error("Unexpected LP withdrawal execution response");
460
507
  }
508
+ const execution = response.value;
509
+ if (BigInt(execution.accepted_lamports) !== BigInt(execution.accepted_deposit_principal_lamports) + BigInt(execution.accepted_earned_fee_lamports)) {
510
+ throw new PolicyValidationError(
511
+ "INVALID_WITHDRAWAL_PLAN",
512
+ "Coordinator accepted withdrawal total does not match its principal and fee split"
513
+ );
514
+ }
515
+ if (input.withdrawalMode === "exact" && (execution.accepted_deposit_principal_lamports !== input.depositPrincipalLamports || execution.accepted_earned_fee_lamports !== input.earnedFeeLamports)) {
516
+ throw new PolicyValidationError(
517
+ "INVALID_WITHDRAWAL_PLAN",
518
+ "Coordinator accepted withdrawal split does not match the signed exact claim"
519
+ );
520
+ }
461
521
  return {
462
- withdrawalId: response.value.withdrawal_id,
463
- txSignatures: [...response.value.tx_signatures]
522
+ withdrawalId: execution.withdrawal_id,
523
+ txSignatures: [...execution.tx_signatures],
524
+ acceptedLamports: execution.accepted_lamports,
525
+ acceptedDepositPrincipalLamports: execution.accepted_deposit_principal_lamports,
526
+ acceptedEarnedFeeLamports: execution.accepted_earned_fee_lamports
464
527
  };
465
528
  }
466
529
  function request(session, auth, action, payload) {
467
530
  return requestForPosition(session, auth.lpPositionId, auth, action, payload);
468
531
  }
469
- async function requestForPosition(session, lpPositionId, auth, action, payload) {
532
+ async function requestForPosition(session, lpPositionId, auth, action, payload, options = {}) {
533
+ const timeoutMs = options.timeoutMs ?? LP_COMMAND_REQUEST_TIMEOUT_MS;
470
534
  assertAuthMatchesPosition(lpPositionId, auth);
471
535
  const protocol = await loadProtocol();
472
536
  const state = getSessionState(session);
473
537
  const attestation = state.channel?.attestation;
474
- if (!attestation) throw new Error("LP coordinator attestation is not available");
538
+ if (!attestation) {
539
+ throw new TransportError("CONNECTION_LOST", "LP coordinator attestation is not available");
540
+ }
475
541
  const command = {
476
542
  lp_position_id: lpPositionId,
477
543
  action,
478
544
  nonce: randomBytes(32),
479
- expires_at_ms: Date.now() + COMMAND_TTL_MS,
545
+ expires_at_ms: Date.now() + Math.min(COMMAND_TTL_MS, timeoutMs),
480
546
  coordinator_attestation_hash: await coordinatorAttestationHash(
481
547
  attestation.binaryHash,
482
548
  attestation.pubkeyHex
@@ -485,8 +551,10 @@ async function requestForPosition(session, lpPositionId, auth, action, payload)
485
551
  };
486
552
  const signature = await signLpCommandBytes(auth, protocol.encodeLpCommandForSigning(command));
487
553
  const { type, payload: envelopePayload } = protocol.lpSignedCommandEnvelope(command, signature);
554
+ const requestOptions = lpPositionPageRequestOptions(options);
488
555
  const envelope = await requestEnvelope(session, type, envelopePayload, {
489
- timeoutMs: LP_COMMAND_REQUEST_TIMEOUT_MS
556
+ timeoutMs: requestOptions.timeoutMs ?? LP_COMMAND_REQUEST_TIMEOUT_MS,
557
+ signal: requestOptions.signal
490
558
  });
491
559
  return protocol.asLpCommandResponsePayload(envelope);
492
560
  }
@@ -545,6 +613,7 @@ function mapLpActorSync(actorSync) {
545
613
  lifetimeEarnedLamports: actorSync.lifetime_earned_lamports ?? 0,
546
614
  redeemablePrincipalSourceCount: actorSync.redeemable_principal_source_count ?? 0,
547
615
  redeemableFeeSourceCount: actorSync.redeemable_fee_source_count ?? 0,
616
+ redeemableSourceCount: actorSync.redeemable_source_count,
548
617
  pendingReservationCount: actorSync.pending_reservation_count,
549
618
  reservedPayoutLamports: actorSync.reserved_payout_lamports,
550
619
  estimatedNetworkFeeLamports: actorSync.estimated_network_fee_lamports,
@@ -588,6 +657,7 @@ function mapLpRedemptionHistory(history) {
588
657
  return {
589
658
  redemptionId: history.redemption_id,
590
659
  state: history.state,
660
+ ...history.withdrawal_mode === void 0 ? {} : { withdrawalMode: history.withdrawal_mode },
591
661
  acceptedLamports: history.accepted_lamports,
592
662
  acceptedDepositPrincipalLamports: history.accepted_deposit_principal_lamports,
593
663
  acceptedEarnedFeeLamports: history.accepted_earned_fee_lamports,
@@ -666,13 +736,17 @@ function randomBytes(length) {
666
736
  return bytes;
667
737
  }
668
738
  function loadProtocol() {
669
- protocolPromise ??= import('./coordinator-7Y45MCCZ.js');
739
+ protocolPromise ??= import('./coordinator-ZNLGAYXD.js');
670
740
  return protocolPromise;
671
741
  }
672
742
 
673
743
  // src/lp/dkgBatch.ts
674
744
  var MAX_LP_DKG_CONCURRENCY = 8;
675
745
  var DEFAULT_LP_DKG_CONCURRENCY = MAX_LP_DKG_CONCURRENCY;
746
+ var LP_DKG_WORKER_REQUEST_TIMEOUT_MS = 3e4;
747
+ var LP_DKG_WORKER_REQUEST_TIMEOUT_MESSAGE = "LP DKG worker request timed out";
748
+ var LP_DKG_ABORT_CLEANUP_TIMEOUT_MS = 1e4;
749
+ var LP_DKG_ABORT_CLEANUP_TIMEOUT_MESSAGE = "LP DKG session cleanup timed out";
676
750
  var LP_DKG_COMPLETED_SHARD_POLL_INTERVAL_MS = 500;
677
751
  var LP_DKG_COMPLETED_SHARD_POLL_TIMEOUT_MS = 5 * 6e4 + 15e3;
678
752
  var LP_DKG_ACTIVE_SESSION_RETRY_INTERVAL_MS = 2e3;
@@ -693,11 +767,20 @@ async function createLpDkgBatch(input) {
693
767
  return addresses2;
694
768
  }
695
769
  const workerCount = resolveConcurrency(input.count, input.concurrency);
696
- const workers = Array.from({ length: workerCount }, () => createWorker(input.workerFactory));
770
+ const workers = [];
771
+ let workersTerminated = false;
772
+ const terminateWorkers = () => {
773
+ if (workersTerminated) return;
774
+ workersTerminated = true;
775
+ workers.forEach((worker) => worker.terminate());
776
+ };
697
777
  const addresses = new Array(input.count);
698
778
  let completed = 0;
699
779
  let nextOffset = 0;
700
780
  try {
781
+ for (let index = 0; index < workerCount; index += 1) {
782
+ workers.push(createWorker(input.workerFactory));
783
+ }
701
784
  await Promise.all(
702
785
  workers.map(async (worker) => {
703
786
  for (; ; ) {
@@ -717,8 +800,34 @@ async function createLpDkgBatch(input) {
717
800
  })
718
801
  );
719
802
  return addresses;
803
+ } catch (error) {
804
+ terminateWorkers();
805
+ if (!isLpDkgSessionCoordinationError(error)) {
806
+ await abortDkgSessionsAfterFailure(input);
807
+ }
808
+ throw error;
720
809
  } finally {
721
- workers.forEach((worker) => worker.terminate());
810
+ terminateWorkers();
811
+ }
812
+ }
813
+ async function abortDkgSessionsAfterFailure(input) {
814
+ const abortDkgSessions2 = input.client.abortDkgSessions;
815
+ if (typeof abortDkgSessions2 !== "function") return;
816
+ let timeoutId;
817
+ try {
818
+ const cleanupTimeout = new Promise((_, reject) => {
819
+ timeoutId = globalThis.setTimeout(
820
+ () => reject(new Error(LP_DKG_ABORT_CLEANUP_TIMEOUT_MESSAGE)),
821
+ LP_DKG_ABORT_CLEANUP_TIMEOUT_MS
822
+ );
823
+ });
824
+ await Promise.race([
825
+ abortDkgSessions2.call(input.client, input.lpPositionId, input.auth),
826
+ cleanupTimeout
827
+ ]);
828
+ } catch {
829
+ } finally {
830
+ if (timeoutId !== void 0) globalThis.clearTimeout(timeoutId);
722
831
  }
723
832
  }
724
833
  async function createLpDkgShard(input, worker, index) {
@@ -802,6 +911,7 @@ async function getCompletedShardAddress(input, index) {
802
911
  }
803
912
  function workerRequest(worker, request2) {
804
913
  return new Promise((resolve, reject) => {
914
+ let timeoutId;
805
915
  const onMessage = (event) => {
806
916
  const message = event.data;
807
917
  if (message.id !== request2.id) return;
@@ -817,12 +927,22 @@ function workerRequest(worker, request2) {
817
927
  reject(new Error(event.message));
818
928
  };
819
929
  const cleanup = () => {
930
+ if (timeoutId !== void 0) globalThis.clearTimeout(timeoutId);
820
931
  worker.removeEventListener("message", onMessage);
821
932
  worker.removeEventListener("error", onError);
822
933
  };
823
934
  worker.addEventListener("message", onMessage);
824
935
  worker.addEventListener("error", onError);
825
- worker.postMessage(request2);
936
+ timeoutId = globalThis.setTimeout(() => {
937
+ cleanup();
938
+ reject(new Error(LP_DKG_WORKER_REQUEST_TIMEOUT_MESSAGE));
939
+ }, LP_DKG_WORKER_REQUEST_TIMEOUT_MS);
940
+ try {
941
+ worker.postMessage(request2);
942
+ } catch (error) {
943
+ cleanup();
944
+ reject(error instanceof Error ? error : new Error(String(error)));
945
+ }
826
946
  });
827
947
  }
828
948
  function createWorker(workerFactory) {
@@ -844,6 +964,13 @@ function isLpDkgCompletedOrVisibleError(error) {
844
964
  function isLpDkgActiveSessionError(error) {
845
965
  return error instanceof Error && error.message.includes("LP DKG session already active for position index");
846
966
  }
967
+ function isLpDkgIndexDriftError(error) {
968
+ if (!(error instanceof Error)) return false;
969
+ return error.message.includes("LP DKG index") && error.message.includes("already exists for position") || error.message.includes("LP DKG expected index");
970
+ }
971
+ function isLpDkgSessionCoordinationError(error) {
972
+ return isLpDkgActiveSessionError(error) || isLpDkgIndexDriftError(error);
973
+ }
847
974
  function resolveConcurrency(count, requested) {
848
975
  if (count <= 0) return 0;
849
976
  const concurrency = requested ?? DEFAULT_LP_DKG_CONCURRENCY;
@@ -867,6 +994,8 @@ var LP_DKG_ACTIVE_SESSION_RETRY_DELAY_MS = 2e3;
867
994
  var LP_DKG_ACTIVE_SESSION_RETRY_TIMEOUT_MS2 = 5 * 6e4 + 15e3;
868
995
  var LP_WITHDRAWAL_CONFIRMATION_POLL_INTERVAL_MS = 3e3;
869
996
  var LP_WITHDRAWAL_CONFIRMATION_TIMEOUT_MS = 15 * 6e4;
997
+ var LP_WITHDRAWAL_READINESS_RETRY_DELAY_MS = 1e3;
998
+ var LP_WITHDRAWAL_READINESS_RETRY_ATTEMPTS = 30;
870
999
  var LP_TOP_UP_WAIT_POLL_INTERVAL_MS = 1e3;
871
1000
  var LP_REDEMPTION_HISTORY_OPEN_STATES = /* @__PURE__ */ new Set([
872
1001
  "requested",
@@ -882,8 +1011,9 @@ var WITHDRAWAL_MISSING_RECORD_MESSAGE = "LP withdrawal record is missing";
882
1011
  var WITHDRAWAL_RECORD_MISMATCH_MESSAGE = "LP withdrawal record does not match this confirmation request";
883
1012
  var WITHDRAWAL_NO_LAMPORTS_MESSAGE = "LP redemption did not land any lamports on-chain";
884
1013
  var WITHDRAWAL_HISTORY_MISMATCH_MESSAGE = "LP redemption history does not match this request";
1014
+ var LP_WITHDRAWAL_UNRESOLVED_FUNDING_MESSAGE = "LP position has unresolved funding shards before redemption";
885
1015
  var UNSUPPORTED_FEE_POLICY_MESSAGE = "LP fee policy overrides are not advertised by the coordinator";
886
- var FEE_SOURCE_COUNT_UNAVAILABLE_MESSAGE = "LP earned-fee source count is not available; pass allowManyToOne: true to acknowledge many-to-one withdrawal risk";
1016
+ var LP_FEE_SOURCE_COUNT_UNAVAILABLE_MESSAGE = "LP earned-fee source count is not available; pass allowManyToOne: true to acknowledge many-to-one withdrawal risk";
887
1017
  var LpRedemptionReconcilingError = class extends LpLifecycleError {
888
1018
  constructor() {
889
1019
  super("LP_REDEMPTION_RECONCILING", LP_REDEMPTION_RECONCILING_MESSAGE);
@@ -902,6 +1032,16 @@ function isLpRedemptionReconcilingError(error) {
902
1032
  function isLpPositionAuthMissingError(error) {
903
1033
  return error instanceof LpPositionAuthMissingError || error instanceof Error && error.message === LP_MISSING_POSITION_CODE_MESSAGE;
904
1034
  }
1035
+ function previewLpWithdrawalPlan(position, args = {}) {
1036
+ const claim = resolveWithdrawalClaim(position, args);
1037
+ return {
1038
+ ...claim,
1039
+ sourceCount: lpWithdrawalSourceCountForClaim(position, {
1040
+ ...claim,
1041
+ allowManyToOne: args.allowManyToOne
1042
+ })
1043
+ };
1044
+ }
905
1045
  var lifecycleClients = /* @__PURE__ */ new WeakMap();
906
1046
  function createLpLifecycleClient(session, runtime = {}) {
907
1047
  const state = {
@@ -931,6 +1071,20 @@ function createLpLifecycleClient(session, runtime = {}) {
931
1071
  const auth = requireAuth(positionId);
932
1072
  return rememberPosition(await client.getPosition(positionId, auth));
933
1073
  };
1074
+ const executeWithdrawalAfterFundingReadiness = async (positionId, input, auth) => {
1075
+ for (let attempt = 0; ; attempt += 1) {
1076
+ try {
1077
+ return await client.executeWithdrawal(input, auth);
1078
+ } catch (error) {
1079
+ const retryable = error instanceof CommandError && error.message.includes(LP_WITHDRAWAL_UNRESOLVED_FUNDING_MESSAGE);
1080
+ if (!retryable || attempt >= LP_WITHDRAWAL_READINESS_RETRY_ATTEMPTS - 1) {
1081
+ throw error;
1082
+ }
1083
+ await sleep2(LP_WITHDRAWAL_READINESS_RETRY_DELAY_MS);
1084
+ await client.reconcileFunding(positionId, auth).catch(() => void 0);
1085
+ }
1086
+ }
1087
+ };
934
1088
  const completeDkgBatch2 = async (positionId, options = {}) => {
935
1089
  assertAttested(session);
936
1090
  const auth = requireAuth(positionId);
@@ -985,7 +1139,7 @@ function createLpLifecycleClient(session, runtime = {}) {
985
1139
  activeSessionRetryStartedAtMs = null;
986
1140
  continue;
987
1141
  }
988
- if (!isLpDkgActiveSessionError2(error)) throw error;
1142
+ if (!isLpDkgActiveSessionError(error)) throw error;
989
1143
  const currentTime = nowMs();
990
1144
  activeSessionRetryStartedAtMs ??= currentTime;
991
1145
  if (currentTime - activeSessionRetryStartedAtMs >= LP_DKG_ACTIVE_SESSION_RETRY_TIMEOUT_MS2) {
@@ -1028,7 +1182,12 @@ function createLpLifecycleClient(session, runtime = {}) {
1028
1182
  async recoverPosition(args) {
1029
1183
  const auth = await deriveLpPositionCodeAuth(args.code);
1030
1184
  rememberAuth(auth);
1031
- const position = rememberPosition(await client.getPosition(auth.lpPositionId, auth));
1185
+ const position = rememberPosition(
1186
+ await client.getPosition(auth.lpPositionId, auth, {
1187
+ deadlineMs: args.deadlineMs,
1188
+ signal: args.signal
1189
+ })
1190
+ );
1032
1191
  assertPositionMatchesAuth(position, auth);
1033
1192
  return position;
1034
1193
  },
@@ -1163,7 +1322,10 @@ function createLpLifecycleClient(session, runtime = {}) {
1163
1322
  if (existingRedemption !== void 0) {
1164
1323
  const execution2 = {
1165
1324
  withdrawalId: existingRedemption.redemptionId,
1166
- txSignatures: [...existingRedemption.txSignatures]
1325
+ txSignatures: [...existingRedemption.txSignatures],
1326
+ acceptedLamports: existingRedemption.acceptedLamports,
1327
+ acceptedDepositPrincipalLamports: existingRedemption.acceptedDepositPrincipalLamports,
1328
+ acceptedEarnedFeeLamports: existingRedemption.acceptedEarnedFeeLamports
1167
1329
  };
1168
1330
  const redemption2 = {
1169
1331
  ...buildLpRedemptionRecord({
@@ -1183,38 +1345,44 @@ function createLpLifecycleClient(session, runtime = {}) {
1183
1345
  state.redemptions.set(execution2.withdrawalId, redemption2);
1184
1346
  return { execution: execution2, position: before, redemption: redemption2 };
1185
1347
  }
1186
- const claim = resolveWithdrawalClaim(before, args);
1187
- const sourceCount = lpWithdrawalSourceCountForClaim(before, {
1188
- ...claim,
1189
- allowManyToOne: args.allowManyToOne
1190
- });
1191
- const validationInput = {
1192
- lpPositionId: positionId,
1193
- destinationAddresses: args.destinationAddresses,
1194
- depositPrincipalLamports: claim.depositPrincipalLamports,
1195
- earnedFeeLamports: claim.earnedFeeLamports,
1196
- requestedAtMs: nowMs(),
1197
- allowManyToOne: args.allowManyToOne ?? false,
1198
- sourceCount
1199
- };
1200
- validateLpWithdrawalPlan(validationInput);
1201
- const execution = await client.executeWithdrawal(
1348
+ const preview = args.withdrawalMode === "exact" ? previewLpWithdrawalPlan(before, args) : void 0;
1349
+ const requestedAtMs = nowMs();
1350
+ if (args.withdrawalMode === "exact") {
1351
+ validateLpWithdrawalPlan({
1352
+ destinationAddresses: args.destinationAddresses,
1353
+ depositPrincipalLamports: preview.depositPrincipalLamports,
1354
+ earnedFeeLamports: preview.earnedFeeLamports,
1355
+ allowManyToOne: args.allowManyToOne ?? false,
1356
+ sourceCount: preview.sourceCount
1357
+ });
1358
+ }
1359
+ const execution = await executeWithdrawalAfterFundingReadiness(
1360
+ positionId,
1202
1361
  {
1203
- lpPositionId: validationInput.lpPositionId,
1204
- destinationAddresses: validationInput.destinationAddresses,
1205
- depositPrincipalLamports: validationInput.depositPrincipalLamports,
1206
- earnedFeeLamports: validationInput.earnedFeeLamports,
1207
- requestedAtMs: validationInput.requestedAtMs,
1208
- allowManyToOne: args.allowManyToOne === true || sourceCount === 1
1362
+ lpPositionId: positionId,
1363
+ destinationAddresses: args.destinationAddresses,
1364
+ depositPrincipalLamports: args.withdrawalMode === "max_available" ? 0 : preview.depositPrincipalLamports,
1365
+ earnedFeeLamports: args.withdrawalMode === "max_available" ? 0 : preview.earnedFeeLamports,
1366
+ withdrawalMode: args.withdrawalMode,
1367
+ requestedAtMs,
1368
+ allowManyToOne: args.allowManyToOne === true || preview?.sourceCount === 1
1209
1369
  },
1210
1370
  auth
1211
1371
  );
1372
+ const acceptedLamports = execution.acceptedLamports;
1373
+ if (args.withdrawalMode === "max_available" && acceptedLamports === void 0) {
1374
+ throw new PolicyValidationError(
1375
+ "INVALID_WITHDRAWAL_PLAN",
1376
+ "LP redemption response did not include the sealed accepted amount"
1377
+ );
1378
+ }
1379
+ const acceptedAmount = acceptedLamports ?? preview.depositPrincipalLamports + preview.earnedFeeLamports;
1212
1380
  const pendingRedemption = buildLpRedemptionRecord({
1213
1381
  execution,
1214
1382
  position: before,
1215
1383
  destinationAddresses: args.destinationAddresses,
1216
- acceptedLamports: claim.depositPrincipalLamports + claim.earnedFeeLamports,
1217
- requestedTargetLamports: (before.actorSync?.withdrawalRequestedLamports ?? 0) + claim.depositPrincipalLamports + claim.earnedFeeLamports,
1384
+ acceptedLamports: acceptedAmount,
1385
+ requestedTargetLamports: (before.actorSync?.withdrawalRequestedLamports ?? 0) + acceptedAmount,
1218
1386
  landedBaselineLamports: before.actorSync?.withdrawalLandedLamports ?? 0,
1219
1387
  landedFeeBaselineLamports: before.actorSync?.withdrawalLandedFeeLamports ?? 0,
1220
1388
  txSignatureBaseline: before.actorSync?.withdrawalTxHashes ?? [],
@@ -1235,10 +1403,32 @@ function createLpLifecycleClient(session, runtime = {}) {
1235
1403
  options
1236
1404
  });
1237
1405
  state.redemptions.set(record.redemptionId, record);
1238
- const deadlineMs = nowMs() + (runtime.withdrawalConfirmationTimeoutMs ?? LP_WITHDRAWAL_CONFIRMATION_TIMEOUT_MS);
1406
+ const deadlineMs = options.deadlineMs ?? nowMs() + (runtime.withdrawalConfirmationTimeoutMs ?? LP_WITHDRAWAL_CONFIRMATION_TIMEOUT_MS);
1239
1407
  const pollIntervalMs = runtime.withdrawalConfirmationPollIntervalMs ?? LP_WITHDRAWAL_CONFIRMATION_POLL_INTERVAL_MS;
1240
1408
  for (; ; ) {
1241
- const position = rememberPosition(await client.getPosition(positionId, auth));
1409
+ throwIfWithdrawalConfirmationAborted(options.signal);
1410
+ if (nowMs() >= deadlineMs) {
1411
+ markLpRedemptionReconciling(state, record, options);
1412
+ }
1413
+ const remainingMs = deadlineMs - nowMs();
1414
+ if (remainingMs <= 0) {
1415
+ markLpRedemptionReconciling(state, record, options);
1416
+ }
1417
+ let position;
1418
+ try {
1419
+ position = rememberPosition(
1420
+ await client.getPosition(positionId, auth, {
1421
+ deadlineMs,
1422
+ signal: options.signal
1423
+ })
1424
+ );
1425
+ } catch (error) {
1426
+ if (isLpPositionObservationDeadlineError(error, deadlineMs, nowMs)) {
1427
+ markLpRedemptionReconciling(state, record, options);
1428
+ }
1429
+ throw error;
1430
+ }
1431
+ throwIfWithdrawalConfirmationAborted(options.signal);
1242
1432
  options.onPosition?.(position);
1243
1433
  const reconciled = reconcileLpRedemptionFromActorSync(record, position);
1244
1434
  record = reconciled;
@@ -1254,12 +1444,10 @@ function createLpLifecycleClient(session, runtime = {}) {
1254
1444
  if (reconciled.status === "failed") {
1255
1445
  throw new Error(reconciled.error ?? WITHDRAWAL_NO_LAMPORTS_MESSAGE);
1256
1446
  }
1257
- if (nowMs() > deadlineMs) {
1258
- state.redemptions.set(record.redemptionId, { ...reconciled, status: "reconciling" });
1259
- options.onRedemptionUpdate?.({ ...reconciled, status: "reconciling" });
1260
- throw new LpRedemptionReconcilingError();
1447
+ if (nowMs() >= deadlineMs) {
1448
+ markLpRedemptionReconciling(state, reconciled, options);
1261
1449
  }
1262
- await sleep2(pollIntervalMs);
1450
+ await sleepWithAbort(sleep2, pollIntervalMs, options.signal);
1263
1451
  }
1264
1452
  },
1265
1453
  async withdrawFees(_positionId, args) {
@@ -1368,10 +1556,12 @@ function isLpPositionReadyForInitialFunding(position) {
1368
1556
  }
1369
1557
  function resolveWithdrawalClaim(position, args) {
1370
1558
  if (args.depositPrincipalLamports !== void 0 || args.earnedFeeLamports !== void 0) {
1371
- return {
1559
+ const claim = {
1372
1560
  depositPrincipalLamports: args.depositPrincipalLamports ?? 0,
1373
1561
  earnedFeeLamports: args.earnedFeeLamports ?? 0
1374
1562
  };
1563
+ validateLpWithdrawalClaim(claim);
1564
+ return claim;
1375
1565
  }
1376
1566
  const legacyDepositPrincipalLamports = position.shards.filter((shard) => shard.status === "AVAILABLE" && shard.amountLamports > 0).reduce((sum, shard) => sum + shard.amountLamports, 0);
1377
1567
  const actorRedeemablePrincipalLamports = Math.max(
@@ -1397,11 +1587,11 @@ function resolveWithdrawalClaim(position, args) {
1397
1587
  return { depositPrincipalLamports, earnedFeeLamports };
1398
1588
  }
1399
1589
  function findOpenRedemptionHistory(position, args) {
1400
- const hasExplicitClaim = args.depositPrincipalLamports !== void 0 || args.earnedFeeLamports !== void 0;
1590
+ const hasExplicitClaim = args.withdrawalMode === "exact";
1401
1591
  const requestedPrincipalLamports = args.depositPrincipalLamports ?? 0;
1402
1592
  const requestedFeeLamports = args.earnedFeeLamports ?? 0;
1403
1593
  return position.actorSync?.redemptionHistory?.find(
1404
- (history) => LP_REDEMPTION_HISTORY_OPEN_STATES.has(history.state) && history.detailsTruncated !== true && sameStringList(history.destinationAddresses, args.destinationAddresses) && (!hasExplicitClaim || history.acceptedDepositPrincipalLamports === requestedPrincipalLamports && history.acceptedEarnedFeeLamports === requestedFeeLamports)
1594
+ (history) => LP_REDEMPTION_HISTORY_OPEN_STATES.has(history.state) && history.detailsTruncated !== true && (history.withdrawalMode ?? "exact") === args.withdrawalMode && sameStringList(history.destinationAddresses, args.destinationAddresses) && (!hasExplicitClaim || history.acceptedDepositPrincipalLamports === requestedPrincipalLamports && history.acceptedEarnedFeeLamports === requestedFeeLamports)
1405
1595
  );
1406
1596
  }
1407
1597
  function hasActorSyncLpActivity(sync) {
@@ -1423,11 +1613,25 @@ function hasActorRedeemableProjection(sync) {
1423
1613
  return sync?.redeemableProjectionAvailable === true;
1424
1614
  }
1425
1615
  function validateExplicitWithdrawalInput(args) {
1426
- if (args.depositPrincipalLamports === void 0 && args.earnedFeeLamports === void 0) return;
1616
+ if (args.withdrawalMode === "max_available") {
1617
+ if (args.depositPrincipalLamports !== void 0 || args.earnedFeeLamports !== void 0) {
1618
+ throw new PolicyValidationError(
1619
+ "INVALID_WITHDRAWAL_PLAN",
1620
+ "max_available withdrawal must not carry exact bucket claims"
1621
+ );
1622
+ }
1623
+ return;
1624
+ }
1625
+ if (args.depositPrincipalLamports === void 0 || args.earnedFeeLamports === void 0) {
1626
+ throw new PolicyValidationError(
1627
+ "INVALID_WITHDRAWAL_PLAN",
1628
+ "exact withdrawal requires both bucket claims"
1629
+ );
1630
+ }
1427
1631
  validateLpWithdrawalPlan({
1428
1632
  destinationAddresses: args.destinationAddresses,
1429
- depositPrincipalLamports: args.depositPrincipalLamports ?? 0,
1430
- earnedFeeLamports: args.earnedFeeLamports ?? 0,
1633
+ depositPrincipalLamports: args.depositPrincipalLamports,
1634
+ earnedFeeLamports: args.earnedFeeLamports,
1431
1635
  allowManyToOne: args.allowManyToOne,
1432
1636
  sourceCount: args.destinationAddresses.length
1433
1637
  });
@@ -1460,6 +1664,13 @@ function resolveWithdrawalRecord({
1460
1664
  };
1461
1665
  }
1462
1666
  function lpWithdrawalSourceCountForClaim(position, claim) {
1667
+ const actorSync = position.actorSync;
1668
+ const actorRedeemablePrincipalLamports = actorSync?.redeemablePrincipalLamports ?? 0;
1669
+ const actorRedeemableFeeLamports = actorSync?.redeemableFeeLamports ?? 0;
1670
+ const actorRedeemableSourceCount = actorSync?.redeemableSourceCount;
1671
+ if (actorSync?.redeemableProjectionAvailable === true && claim.depositPrincipalLamports === actorRedeemablePrincipalLamports && claim.earnedFeeLamports === actorRedeemableFeeLamports && actorRedeemableSourceCount !== void 0) {
1672
+ return actorRedeemableSourceCount;
1673
+ }
1463
1674
  let remainingPrincipalLamports = claim.depositPrincipalLamports;
1464
1675
  let principalSourceCount = 0;
1465
1676
  const principalCandidates = [...position.shards].filter((shard) => shard.status === "AVAILABLE" && shard.amountLamports > 0).sort((left, right) => left.shardId.localeCompare(right.shardId));
@@ -1468,7 +1679,6 @@ function lpWithdrawalSourceCountForClaim(position, claim) {
1468
1679
  principalSourceCount += 1;
1469
1680
  remainingPrincipalLamports -= shard.amountLamports;
1470
1681
  }
1471
- const actorRedeemablePrincipalLamports = position.actorSync?.redeemablePrincipalLamports ?? 0;
1472
1682
  const actorRedeemablePrincipalSourceCount = position.actorSync?.redeemablePrincipalSourceCount ?? 0;
1473
1683
  if (claim.depositPrincipalLamports > 0 && position.actorSync?.redeemableProjectionAvailable === true && actorRedeemablePrincipalLamports >= claim.depositPrincipalLamports && actorRedeemablePrincipalSourceCount > 0) {
1474
1684
  principalSourceCount = actorRedeemablePrincipalSourceCount;
@@ -1477,7 +1687,7 @@ function lpWithdrawalSourceCountForClaim(position, claim) {
1477
1687
  if (claim.earnedFeeLamports > 0 && observedEarnedFeeSourceCount < 1 && claim.allowManyToOne !== true) {
1478
1688
  throw new PolicyValidationError(
1479
1689
  "INVALID_WITHDRAWAL_PLAN",
1480
- FEE_SOURCE_COUNT_UNAVAILABLE_MESSAGE
1690
+ LP_FEE_SOURCE_COUNT_UNAVAILABLE_MESSAGE
1481
1691
  );
1482
1692
  }
1483
1693
  const earnedFeeSourceCount = claim.earnedFeeLamports > 0 ? Math.max(1, observedEarnedFeeSourceCount) : 0;
@@ -1617,13 +1827,6 @@ function sameStringList(left, right) {
1617
1827
  function uniqueStrings(values) {
1618
1828
  return Array.from(new Set(values));
1619
1829
  }
1620
- function isLpDkgActiveSessionError2(error) {
1621
- return error instanceof Error && error.message.includes("LP DKG session already active for position index");
1622
- }
1623
- function isLpDkgIndexDriftError(error) {
1624
- if (!(error instanceof Error)) return false;
1625
- return error.message.includes("LP DKG index") && error.message.includes("already exists for position") || error.message.includes("LP DKG expected index");
1626
- }
1627
1830
  function clonePosition(position) {
1628
1831
  return {
1629
1832
  ...position,
@@ -1650,6 +1853,30 @@ function throwIfTopUpWaitAborted(signal) {
1650
1853
  if (signal?.aborted !== true) return;
1651
1854
  throw new DOMException("LP top-up wait aborted", "AbortError");
1652
1855
  }
1856
+ function throwIfWithdrawalConfirmationAborted(signal) {
1857
+ if (signal?.aborted !== true) return;
1858
+ throw new DOMException("LP withdrawal confirmation wait aborted", "AbortError");
1859
+ }
1860
+ function markLpRedemptionReconciling(state, record, options) {
1861
+ const reconciling = { ...record, status: "reconciling" };
1862
+ state.redemptions.set(record.redemptionId, reconciling);
1863
+ options.onRedemptionUpdate?.(reconciling);
1864
+ throw new LpRedemptionReconcilingError();
1865
+ }
1866
+ function isLpPositionObservationDeadlineError(error, deadlineMs, nowMs) {
1867
+ return error instanceof CommandError && error.code === "REJECTED_STALE_JOB" && nowMs() >= deadlineMs;
1868
+ }
1869
+ function sleepWithAbort(sleep2, delayMs, signal) {
1870
+ if (signal === void 0) return sleep2(delayMs);
1871
+ throwIfWithdrawalConfirmationAborted(signal);
1872
+ return new Promise((resolve, reject) => {
1873
+ const onAbort = () => reject(new DOMException("LP withdrawal confirmation wait aborted", "AbortError"));
1874
+ signal.addEventListener("abort", onAbort, { once: true });
1875
+ void sleep2(delayMs).then(resolve, reject).finally(() => {
1876
+ signal.removeEventListener("abort", onAbort);
1877
+ });
1878
+ });
1879
+ }
1653
1880
  function defaultSleep(delayMs) {
1654
1881
  return new Promise((resolve) => {
1655
1882
  globalThis.setTimeout(resolve, delayMs);
@@ -1706,6 +1933,6 @@ function listPositions(session) {
1706
1933
  return defaultLpLifecycleClient(session).listPositions();
1707
1934
  }
1708
1935
 
1709
- export { LP_COMMAND_REQUEST_TIMEOUT_MS, LP_MISSING_POSITION_CODE_MESSAGE, LP_REDEMPTION_RECONCILING_MESSAGE, bytesToHex, completeDkgBatch, confirmPositionCodeSaved, createLpCoordinatorClient, createLpDkgBatch, createLpLifecycleClient, createPosition, defaultLpLifecycleClient, deriveLpPositionCodeAuth, generateLpPositionCode, isLpPositionAuthMissingError, isLpRedemptionReconcilingError, listPositions, normalizeLpPositionCode, prepareInitialFunding, prepareTopUp2 as prepareTopUp, reconcileFunding2 as reconcileFunding, recoverPosition, refill, refreshPosition, signLpCommandBytes, waitForTopUp, waitForWithdrawalConfirmation, withdrawFees, withdrawPosition };
1936
+ export { LP_COMMAND_REQUEST_TIMEOUT_MS, LP_DKG_ABORT_CLEANUP_TIMEOUT_MS, LP_DKG_ABORT_REQUEST_TIMEOUT_MS, LP_DKG_WORKER_REQUEST_TIMEOUT_MESSAGE, LP_DKG_WORKER_REQUEST_TIMEOUT_MS, LP_FEE_SOURCE_COUNT_UNAVAILABLE_MESSAGE, LP_MISSING_POSITION_CODE_MESSAGE, LP_REDEMPTION_RECONCILING_MESSAGE, bytesToHex, completeDkgBatch, confirmPositionCodeSaved, createLpCoordinatorClient, createLpDkgBatch, createLpLifecycleClient, createPosition, defaultLpLifecycleClient, deriveLpPositionCodeAuth, generateLpPositionCode, isLpPositionAuthMissingError, isLpRedemptionReconcilingError, listPositions, normalizeLpPositionCode, prepareInitialFunding, prepareTopUp2 as prepareTopUp, previewLpWithdrawalPlan, reconcileFunding2 as reconcileFunding, recoverPosition, refill, refreshPosition, signLpCommandBytes, waitForTopUp, waitForWithdrawalConfirmation, withdrawFees, withdrawPosition };
1710
1937
  //# sourceMappingURL=lp.js.map
1711
1938
  //# sourceMappingURL=lp.js.map