otomato-sdk 2.0.533 → 2.0.534

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.
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = '2.0.533';
1
+ export const SDK_VERSION = '2.0.534';
2
2
  export function compareVersions(v1, v2) {
3
3
  // Split the version strings into parts
4
4
  const v1Parts = v1.split('.').map(Number);
@@ -890,3 +890,26 @@ export function isMaxBigInt(value) {
890
890
  const valueBigInt = typeof value === 'string' ? BigInt(value) : value;
891
891
  return valueBigInt == MAX_BIGINT;
892
892
  }
893
+ /**
894
+ * Format a Health Factor for display.
895
+ *
896
+ * Rules:
897
+ * - If value is MAX_BIGINT (or equivalent sentinel) → return MAX_BIGINT (no-op, caller emits as-is).
898
+ * - If HF < 1.04 → 4 decimals (users need precision near liquidation).
899
+ * - Otherwise → 2 decimals.
900
+ *
901
+ * Accepts number | bigint | string. Non-finite / unparseable inputs fall back to MAX_BIGINT
902
+ * so unhealthy-but-unknown positions are treated as "safe/max" (matches existing sentinel
903
+ * convention used by AAVE/Hyperlend/Hypurr/Moonwell handlers).
904
+ */
905
+ export function formatHealthFactor(value) {
906
+ if (typeof value === 'bigint') {
907
+ return isMaxBigInt(value) ? MAX_BIGINT : formatHealthFactor(Number(value));
908
+ }
909
+ const num = typeof value === 'string' ? parseFloat(value) : value;
910
+ if (!Number.isFinite(num)) {
911
+ return MAX_BIGINT;
912
+ }
913
+ const decimals = num < 1.04 ? 4 : 2;
914
+ return num.toFixed(decimals);
915
+ }
@@ -1,2 +1,2 @@
1
- export declare const SDK_VERSION = "2.0.533";
1
+ export declare const SDK_VERSION = "2.0.534";
2
2
  export declare function compareVersions(v1: string, v2: string): number;
@@ -247,3 +247,16 @@ export declare function isTickInRange(currentTick: number | null, tickLower: num
247
247
  export declare function calculateRangePercentage(currentTick: number | null, tickLower: number, tickUpper: number): number | null;
248
248
  export declare const MAX_BIGINT: bigint;
249
249
  export declare function isMaxBigInt(value: bigint | string): boolean;
250
+ /**
251
+ * Format a Health Factor for display.
252
+ *
253
+ * Rules:
254
+ * - If value is MAX_BIGINT (or equivalent sentinel) → return MAX_BIGINT (no-op, caller emits as-is).
255
+ * - If HF < 1.04 → 4 decimals (users need precision near liquidation).
256
+ * - Otherwise → 2 decimals.
257
+ *
258
+ * Accepts number | bigint | string. Non-finite / unparseable inputs fall back to MAX_BIGINT
259
+ * so unhealthy-but-unknown positions are treated as "safe/max" (matches existing sentinel
260
+ * convention used by AAVE/Hyperlend/Hypurr/Moonwell handlers).
261
+ */
262
+ export declare function formatHealthFactor(value: number | bigint | string): string | bigint;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "otomato-sdk",
3
- "version": "2.0.533",
3
+ "version": "2.0.534",
4
4
  "description": "An SDK for building and managing automations on Otomato",
5
5
  "repository": {
6
6
  "type": "git",