@liberfi.io/ui-perpetuals 0.2.17 → 0.2.19

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.mts CHANGED
@@ -12,7 +12,7 @@ declare global {
12
12
  };
13
13
  }
14
14
  }
15
- declare const _default: "0.2.17";
15
+ declare const _default: "0.2.19";
16
16
 
17
17
  /**
18
18
  * Trading pair symbol format
@@ -2223,9 +2223,17 @@ type PlaceOrderFormWidgetProps = {
2223
2223
  * control.
2224
2224
  */
2225
2225
  onAddFunds?: () => void;
2226
+ /**
2227
+ * Optional callback fired when the user confirms a new leverage value
2228
+ * in the leverage modal. The host app should sign + relay the
2229
+ * `updateLeverage` action to Hyperliquid and surface a toast. While
2230
+ * the returned promise is pending the modal's button shows a spinner;
2231
+ * if it rejects, the modal stays open so the user can retry.
2232
+ */
2233
+ onUpdateLeverage?: (leverage: number) => Promise<void>;
2226
2234
  className?: string;
2227
2235
  };
2228
- declare function PlaceOrderFormWidget({ symbol, userAddress, maxLeverage, onSuccess, onError, onAddFunds, className, }: PlaceOrderFormWidgetProps): react_jsx_runtime.JSX.Element;
2236
+ declare function PlaceOrderFormWidget({ symbol, userAddress, maxLeverage, onSuccess, onError, onAddFunds, onUpdateLeverage, className, }: PlaceOrderFormWidgetProps): react_jsx_runtime.JSX.Element;
2229
2237
 
2230
2238
  type PlaceOrderFormData = {
2231
2239
  price?: number;
@@ -2242,6 +2250,19 @@ type UsePlaceOrderFormScriptParams = {
2242
2250
  maxLeverage?: number;
2243
2251
  onSuccess?: () => void;
2244
2252
  onError?: (error: Error) => void;
2253
+ /**
2254
+ * Optional callback fired when the user confirms a new leverage value
2255
+ * in the leverage modal. The host app is expected to sign + relay the
2256
+ * `updateLeverage` action to Hyperliquid (and surface a toast). The
2257
+ * widget tracks the returned promise to drive the modal's button
2258
+ * loading state — when the promise rejects, the modal stays open so
2259
+ * the user can retry.
2260
+ *
2261
+ * When omitted, the modal falls back to a local-only update: the
2262
+ * leverage slider commits to the form state without contacting the
2263
+ * exchange.
2264
+ */
2265
+ onUpdateLeverage?: (leverage: number) => Promise<void>;
2245
2266
  };
2246
2267
  type UsePlaceOrderFormScriptResult = {
2247
2268
  form: ReturnType<typeof useForm<PlaceOrderFormData>>;
@@ -2259,8 +2280,16 @@ type UsePlaceOrderFormScriptResult = {
2259
2280
  accountValue: number;
2260
2281
  currentPosition?: number;
2261
2282
  maxLeverage: number;
2283
+ /**
2284
+ * Leverage currently configured on Hyperliquid for the active symbol's
2285
+ * position. `undefined` when the user has no open position for the
2286
+ * symbol (and therefore no per-asset leverage to read).
2287
+ */
2288
+ currentLeverage?: number;
2289
+ /** Forwarded callback (see {@link UsePlaceOrderFormScriptParams.onUpdateLeverage}). */
2290
+ onUpdateLeverage?: (leverage: number) => Promise<void>;
2262
2291
  };
2263
- declare function usePlaceOrderFormScript({ symbol, userAddress, maxLeverage: maxLeverageProp, onSuccess, onError, }: UsePlaceOrderFormScriptParams): UsePlaceOrderFormScriptResult;
2292
+ declare function usePlaceOrderFormScript({ symbol, userAddress, maxLeverage: maxLeverageProp, onSuccess, onError, onUpdateLeverage, }: UsePlaceOrderFormScriptParams): UsePlaceOrderFormScriptResult;
2264
2293
 
2265
2294
  type PlaceOrderFormUIProps = {
2266
2295
  methods: UseFormReturn<PlaceOrderFormData>;
@@ -2286,8 +2315,17 @@ type PlaceOrderFormUIProps = {
2286
2315
  * don't support a deposit flow don't render a dead control.
2287
2316
  */
2288
2317
  onAddFunds?: () => void;
2318
+ /**
2319
+ * Optional callback fired when the user confirms a new leverage in
2320
+ * the leverage modal. The widget tracks the returned promise to
2321
+ * drive the modal's button loading state — when it rejects the
2322
+ * modal stays open so the caller can retry. When omitted, the
2323
+ * leverage value is committed to the form locally without contacting
2324
+ * the exchange.
2325
+ */
2326
+ onUpdateLeverage?: (leverage: number) => Promise<void>;
2289
2327
  };
2290
- declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage, onAddFunds, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
2328
+ declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage: _maxLeverage, onAddFunds, onUpdateLeverage, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
2291
2329
 
2292
2330
  type PositionsWidgetProps = {
2293
2331
  userAddress?: string;
package/dist/index.d.ts CHANGED
@@ -12,7 +12,7 @@ declare global {
12
12
  };
13
13
  }
14
14
  }
15
- declare const _default: "0.2.17";
15
+ declare const _default: "0.2.19";
16
16
 
17
17
  /**
18
18
  * Trading pair symbol format
@@ -2223,9 +2223,17 @@ type PlaceOrderFormWidgetProps = {
2223
2223
  * control.
2224
2224
  */
2225
2225
  onAddFunds?: () => void;
2226
+ /**
2227
+ * Optional callback fired when the user confirms a new leverage value
2228
+ * in the leverage modal. The host app should sign + relay the
2229
+ * `updateLeverage` action to Hyperliquid and surface a toast. While
2230
+ * the returned promise is pending the modal's button shows a spinner;
2231
+ * if it rejects, the modal stays open so the user can retry.
2232
+ */
2233
+ onUpdateLeverage?: (leverage: number) => Promise<void>;
2226
2234
  className?: string;
2227
2235
  };
2228
- declare function PlaceOrderFormWidget({ symbol, userAddress, maxLeverage, onSuccess, onError, onAddFunds, className, }: PlaceOrderFormWidgetProps): react_jsx_runtime.JSX.Element;
2236
+ declare function PlaceOrderFormWidget({ symbol, userAddress, maxLeverage, onSuccess, onError, onAddFunds, onUpdateLeverage, className, }: PlaceOrderFormWidgetProps): react_jsx_runtime.JSX.Element;
2229
2237
 
2230
2238
  type PlaceOrderFormData = {
2231
2239
  price?: number;
@@ -2242,6 +2250,19 @@ type UsePlaceOrderFormScriptParams = {
2242
2250
  maxLeverage?: number;
2243
2251
  onSuccess?: () => void;
2244
2252
  onError?: (error: Error) => void;
2253
+ /**
2254
+ * Optional callback fired when the user confirms a new leverage value
2255
+ * in the leverage modal. The host app is expected to sign + relay the
2256
+ * `updateLeverage` action to Hyperliquid (and surface a toast). The
2257
+ * widget tracks the returned promise to drive the modal's button
2258
+ * loading state — when the promise rejects, the modal stays open so
2259
+ * the user can retry.
2260
+ *
2261
+ * When omitted, the modal falls back to a local-only update: the
2262
+ * leverage slider commits to the form state without contacting the
2263
+ * exchange.
2264
+ */
2265
+ onUpdateLeverage?: (leverage: number) => Promise<void>;
2245
2266
  };
2246
2267
  type UsePlaceOrderFormScriptResult = {
2247
2268
  form: ReturnType<typeof useForm<PlaceOrderFormData>>;
@@ -2259,8 +2280,16 @@ type UsePlaceOrderFormScriptResult = {
2259
2280
  accountValue: number;
2260
2281
  currentPosition?: number;
2261
2282
  maxLeverage: number;
2283
+ /**
2284
+ * Leverage currently configured on Hyperliquid for the active symbol's
2285
+ * position. `undefined` when the user has no open position for the
2286
+ * symbol (and therefore no per-asset leverage to read).
2287
+ */
2288
+ currentLeverage?: number;
2289
+ /** Forwarded callback (see {@link UsePlaceOrderFormScriptParams.onUpdateLeverage}). */
2290
+ onUpdateLeverage?: (leverage: number) => Promise<void>;
2262
2291
  };
2263
- declare function usePlaceOrderFormScript({ symbol, userAddress, maxLeverage: maxLeverageProp, onSuccess, onError, }: UsePlaceOrderFormScriptParams): UsePlaceOrderFormScriptResult;
2292
+ declare function usePlaceOrderFormScript({ symbol, userAddress, maxLeverage: maxLeverageProp, onSuccess, onError, onUpdateLeverage, }: UsePlaceOrderFormScriptParams): UsePlaceOrderFormScriptResult;
2264
2293
 
2265
2294
  type PlaceOrderFormUIProps = {
2266
2295
  methods: UseFormReturn<PlaceOrderFormData>;
@@ -2286,8 +2315,17 @@ type PlaceOrderFormUIProps = {
2286
2315
  * don't support a deposit flow don't render a dead control.
2287
2316
  */
2288
2317
  onAddFunds?: () => void;
2318
+ /**
2319
+ * Optional callback fired when the user confirms a new leverage in
2320
+ * the leverage modal. The widget tracks the returned promise to
2321
+ * drive the modal's button loading state — when it rejects the
2322
+ * modal stays open so the caller can retry. When omitted, the
2323
+ * leverage value is committed to the form locally without contacting
2324
+ * the exchange.
2325
+ */
2326
+ onUpdateLeverage?: (leverage: number) => Promise<void>;
2289
2327
  };
2290
- declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage, onAddFunds, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
2328
+ declare function PlaceOrderFormUI({ methods, side, orderType, onSideChange, onOrderTypeChange, onSubmit, isSubmitting, symbol, currentPrice, estimatedFee, liquidationPrice, availableMargin, accountValue, currentPosition, maxLeverage: _maxLeverage, onAddFunds, onUpdateLeverage, }: PlaceOrderFormUIProps): react_jsx_runtime.JSX.Element;
2291
2329
 
2292
2330
  type PositionsWidgetProps = {
2293
2331
  userAddress?: string;