@gala-chain/gswap-sdk 2.0.0-rc.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2242,7 +2242,7 @@ export type OnramperMode = (typeof ONRAMPER_MODES)[number];
2242
2242
  * `networkPrefix` `gala_gala`).
2243
2243
  */
2244
2244
  export interface OnramperWidgetRequest {
2245
- /** The wallet that receives the crypto, sent as given (the backend wants an `0x` Ethereum address). */
2245
+ /** The wallet that receives the crypto, sent as given (the backend accepts `0x…` or `eth|…` Ethereum addresses and `client|…` aliases, and canonicalizes them). */
2246
2246
  walletAddress: string;
2247
2247
  mode?: OnramperMode | undefined;
2248
2248
  defaultFiat?: string | undefined;
@@ -3101,10 +3101,12 @@ export declare class Positions {
3101
3101
  * and would never confirm a full close, whose whole point is that the position stops
3102
3102
  * existing).
3103
3103
  *
3104
- * The "before" state is captured lazily, on the confirmation closure's own first poll —
3105
- * not eagerly here in `submit()` — so confirming a write never adds an extra round-trip to
3106
- * the write itself; the cost of establishing the baseline is paid by `confirm()`, only if
3107
- * and when the caller actually asks to confirm.
3104
+ * The "before" state is read here, before the write is sent. Liquidity writes execute
3105
+ * synchronously, so by the time `confirm()` first polls the effect has already landed: a
3106
+ * baseline taken on that first poll would already include it, and an add or partial remove
3107
+ * would never be seen to change and would time out. Only a full close needs no baseline
3108
+ * (it waits for the position to disappear). If the baseline read fails the write is still
3109
+ * sent and the closure falls back to taking the baseline on its first poll.
3108
3110
  */
3109
3111
  private buildPositionConfirmation;
3110
3112
  private get;
package/dist/index.d.ts CHANGED
@@ -2242,7 +2242,7 @@ export type OnramperMode = (typeof ONRAMPER_MODES)[number];
2242
2242
  * `networkPrefix` `gala_gala`).
2243
2243
  */
2244
2244
  export interface OnramperWidgetRequest {
2245
- /** The wallet that receives the crypto, sent as given (the backend wants an `0x` Ethereum address). */
2245
+ /** The wallet that receives the crypto, sent as given (the backend accepts `0x…` or `eth|…` Ethereum addresses and `client|…` aliases, and canonicalizes them). */
2246
2246
  walletAddress: string;
2247
2247
  mode?: OnramperMode | undefined;
2248
2248
  defaultFiat?: string | undefined;
@@ -3101,10 +3101,12 @@ export declare class Positions {
3101
3101
  * and would never confirm a full close, whose whole point is that the position stops
3102
3102
  * existing).
3103
3103
  *
3104
- * The "before" state is captured lazily, on the confirmation closure's own first poll —
3105
- * not eagerly here in `submit()` — so confirming a write never adds an extra round-trip to
3106
- * the write itself; the cost of establishing the baseline is paid by `confirm()`, only if
3107
- * and when the caller actually asks to confirm.
3104
+ * The "before" state is read here, before the write is sent. Liquidity writes execute
3105
+ * synchronously, so by the time `confirm()` first polls the effect has already landed: a
3106
+ * baseline taken on that first poll would already include it, and an add or partial remove
3107
+ * would never be seen to change and would time out. Only a full close needs no baseline
3108
+ * (it waits for the position to disappear). If the baseline read fails the write is still
3109
+ * sent and the closure falls back to taking the baseline on its first poll.
3108
3110
  */
3109
3111
  private buildPositionConfirmation;
3110
3112
  private get;
package/dist/index.mjs CHANGED
@@ -4950,7 +4950,7 @@ var Positions = class {
4950
4950
  const signed = await signPreSend(this.signer, method, dto);
4951
4951
  const submitOptions = this.walletAddress === void 0 ? {} : { walletAddress: this.walletAddress };
4952
4952
  const owner = this.walletAddress;
4953
- const positionConfirmation = this.buildPositionConfirmation(confirmation, owner);
4953
+ const positionConfirmation = await this.buildPositionConfirmation(confirmation, owner);
4954
4954
  const options = {
4955
4955
  ...submitOptions,
4956
4956
  ...positionConfirmation === void 0 ? {} : { positionConfirmation }
@@ -4964,12 +4964,14 @@ var Positions = class {
4964
4964
  * and would never confirm a full close, whose whole point is that the position stops
4965
4965
  * existing).
4966
4966
  *
4967
- * The "before" state is captured lazily, on the confirmation closure's own first poll —
4968
- * not eagerly here in `submit()` — so confirming a write never adds an extra round-trip to
4969
- * the write itself; the cost of establishing the baseline is paid by `confirm()`, only if
4970
- * and when the caller actually asks to confirm.
4967
+ * The "before" state is read here, before the write is sent. Liquidity writes execute
4968
+ * synchronously, so by the time `confirm()` first polls the effect has already landed: a
4969
+ * baseline taken on that first poll would already include it, and an add or partial remove
4970
+ * would never be seen to change and would time out. Only a full close needs no baseline
4971
+ * (it waits for the position to disappear). If the baseline read fails the write is still
4972
+ * sent and the closure falls back to taking the baseline on its first poll.
4971
4973
  */
4972
- buildPositionConfirmation(confirmation, owner) {
4974
+ async buildPositionConfirmation(confirmation, owner) {
4973
4975
  if (confirmation === void 0) return void 0;
4974
4976
  if (confirmation.kind === "createPool") {
4975
4977
  const { token0, token1, fee } = confirmation;
@@ -4986,17 +4988,26 @@ var Positions = class {
4986
4988
  }
4987
4989
  if (owner === void 0) return void 0;
4988
4990
  const { kind, identity } = confirmation;
4991
+ const toBaseline = (current) => ({
4992
+ liquidity: new BigNumber((current === null || current === void 0 ? void 0 : current.liquidity) ?? 0),
4993
+ fees: new BigNumber((current === null || current === void 0 ? void 0 : current.fees0) ?? 0).plus(new BigNumber((current === null || current === void 0 ? void 0 : current.fees1) ?? 0))
4994
+ });
4989
4995
  let baseline;
4996
+ if (kind !== "removeFull") try {
4997
+ baseline = toBaseline(await this.getPosition({
4998
+ ...identity,
4999
+ owner
5000
+ }));
5001
+ } catch {
5002
+ baseline = void 0;
5003
+ }
4990
5004
  return async (signal) => {
4991
5005
  const current = await this.getPosition({
4992
5006
  ...identity,
4993
5007
  owner
4994
5008
  }, signal);
4995
5009
  if (baseline === void 0) {
4996
- baseline = {
4997
- liquidity: new BigNumber((current === null || current === void 0 ? void 0 : current.liquidity) ?? 0),
4998
- fees: new BigNumber((current === null || current === void 0 ? void 0 : current.fees0) ?? 0).plus(new BigNumber((current === null || current === void 0 ? void 0 : current.fees1) ?? 0))
4999
- };
5010
+ baseline = toBaseline(current);
5000
5011
  return kind === "removeFull" && current === null ? {
5001
5012
  confirmed: true,
5002
5013
  position: null