@pear-protocol/hyperliquid-sdk 0.1.35 → 0.1.37
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.ts +1 -1
- package/dist/index.js +22 -3
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -341,7 +341,7 @@ type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE' | 'PRICE' | 'P
|
|
|
341
341
|
/**
|
|
342
342
|
* Trigger type for trigger orders
|
|
343
343
|
*/
|
|
344
|
-
type TriggerType = 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'BTC_DOM' | 'CROSS_ASSET_PRICE' | 'PREDICTION_MARKET_OUTCOME';
|
|
344
|
+
type TriggerType = 'PRICE' | 'PRICE_LIMIT' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'BTC_DOM' | 'CROSS_ASSET_PRICE' | 'PREDICTION_MARKET_OUTCOME';
|
|
345
345
|
type CloseTriggerType = 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
346
346
|
type CloseExecutionType = 'MARKET' | 'TWAP' | 'TRIGGER';
|
|
347
347
|
type OrderDirection = 'MORE_THAN' | 'LESS_THAN';
|
package/dist/index.js
CHANGED
|
@@ -6801,6 +6801,8 @@ const CANDLE_INTERVAL_MS = {
|
|
|
6801
6801
|
'1w': 7 * 24 * 60 * 60 * 1000,
|
|
6802
6802
|
'1M': 30 * 24 * 60 * 60 * 1000,
|
|
6803
6803
|
};
|
|
6804
|
+
const FIXED_PRICE_SYMBOLS = new Set(['USDC', 'USDH', 'USDE', 'USDT0']);
|
|
6805
|
+
const isFixedPriceSymbol = (symbol) => FIXED_PRICE_SYMBOLS.has(symbol.toUpperCase());
|
|
6804
6806
|
/**
|
|
6805
6807
|
* Composes historical price fetching with basket candle computation.
|
|
6806
6808
|
* - Listens to `longTokens` and `shortTokens` from user selection.
|
|
@@ -6931,7 +6933,7 @@ const useBasketCandles = () => {
|
|
|
6931
6933
|
for (const symbol of symbolSet) {
|
|
6932
6934
|
const c = candleData.get(symbol);
|
|
6933
6935
|
if (!c)
|
|
6934
|
-
|
|
6936
|
+
continue; // no candle feed (e.g. stablecoin), handled per-token below
|
|
6935
6937
|
snapshot[symbol] = c;
|
|
6936
6938
|
if (t === null || c.t > t) {
|
|
6937
6939
|
t = c.t;
|
|
@@ -6944,6 +6946,19 @@ const useBasketCandles = () => {
|
|
|
6944
6946
|
const maxCarryForwardMs = intervalMs * 2;
|
|
6945
6947
|
const getCandleForTargetWindow = (symbol) => {
|
|
6946
6948
|
const c = snapshot[symbol];
|
|
6949
|
+
if (!c) {
|
|
6950
|
+
if (!isFixedPriceSymbol(symbol))
|
|
6951
|
+
return null;
|
|
6952
|
+
return {
|
|
6953
|
+
s: symbol,
|
|
6954
|
+
t,
|
|
6955
|
+
T,
|
|
6956
|
+
o: 1,
|
|
6957
|
+
h: 1,
|
|
6958
|
+
l: 1,
|
|
6959
|
+
c: 1,
|
|
6960
|
+
};
|
|
6961
|
+
}
|
|
6947
6962
|
if (c.t === t)
|
|
6948
6963
|
return c;
|
|
6949
6964
|
if (c.t > t || t - c.t > maxCarryForwardMs)
|
|
@@ -6965,10 +6980,12 @@ const useBasketCandles = () => {
|
|
|
6965
6980
|
let longOpen = 1, longHigh = 1, longLow = 1, longClose = 1;
|
|
6966
6981
|
let shortOpen = 1, shortHigh = 1, shortLow = 1, shortClose = 1;
|
|
6967
6982
|
for (const token of longTokens) {
|
|
6983
|
+
const w = token.weight / 100;
|
|
6984
|
+
if (w === 0)
|
|
6985
|
+
continue;
|
|
6968
6986
|
const c = getCandleForTargetWindow(token.symbol);
|
|
6969
6987
|
if (!c)
|
|
6970
6988
|
return null;
|
|
6971
|
-
const w = token.weight / 100;
|
|
6972
6989
|
const o = c.o, h = c.h, l = c.l, cl = c.c;
|
|
6973
6990
|
if (!(o > 0 && h > 0 && l > 0 && cl > 0))
|
|
6974
6991
|
return null;
|
|
@@ -6978,10 +6995,12 @@ const useBasketCandles = () => {
|
|
|
6978
6995
|
longClose *= Math.pow(cl, w);
|
|
6979
6996
|
}
|
|
6980
6997
|
for (const token of shortTokens) {
|
|
6998
|
+
const w = -(token.weight / 100);
|
|
6999
|
+
if (w === 0)
|
|
7000
|
+
continue;
|
|
6981
7001
|
const c = getCandleForTargetWindow(token.symbol);
|
|
6982
7002
|
if (!c)
|
|
6983
7003
|
return null;
|
|
6984
|
-
const w = -(token.weight / 100);
|
|
6985
7004
|
const o = c.o, h = c.h, l = c.l, cl = c.c;
|
|
6986
7005
|
if (!(o > 0 && h > 0 && l > 0 && cl > 0))
|
|
6987
7006
|
return null;
|
package/dist/types.d.ts
CHANGED
|
@@ -313,7 +313,7 @@ export type TpSlTriggerType = 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE' | 'PRIC
|
|
|
313
313
|
/**
|
|
314
314
|
* Trigger type for trigger orders
|
|
315
315
|
*/
|
|
316
|
-
export type TriggerType = 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'BTC_DOM' | 'CROSS_ASSET_PRICE' | 'PREDICTION_MARKET_OUTCOME';
|
|
316
|
+
export type TriggerType = 'PRICE' | 'PRICE_LIMIT' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'BTC_DOM' | 'CROSS_ASSET_PRICE' | 'PREDICTION_MARKET_OUTCOME';
|
|
317
317
|
export type CloseTriggerType = 'PRICE' | 'PRICE_RATIO' | 'WEIGHTED_RATIO' | 'PERCENTAGE' | 'DOLLAR' | 'POSITION_VALUE';
|
|
318
318
|
export type CloseExecutionType = 'MARKET' | 'TWAP' | 'TRIGGER';
|
|
319
319
|
export type OrderDirection = 'MORE_THAN' | 'LESS_THAN';
|