@strkfarm/sdk 2.0.0-dev.29 → 2.0.0-dev.30

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 CHANGED
@@ -451,9 +451,12 @@ interface CacheData$1 {
451
451
  }
452
452
  declare class CacheClass {
453
453
  readonly cache: Map<string, CacheData$1>;
454
+ isCacheEnabled: boolean;
454
455
  setCache(key: string, data: any, ttl?: number): void;
455
456
  getCache<T>(key: string): T | null;
456
457
  isCacheValid(key: string): boolean;
458
+ disableCache(): void;
459
+ enableCache(): void;
457
460
  }
458
461
 
459
462
  interface HarvestInfo {
@@ -2183,6 +2186,7 @@ interface CreateOrderRequest {
2183
2186
  price: string;
2184
2187
  side: OrderSide;
2185
2188
  post_only?: boolean;
2189
+ reduce_only?: boolean;
2186
2190
  previous_order_id?: number;
2187
2191
  external_id?: string;
2188
2192
  time_in_force?: TimeInForce;
@@ -2258,11 +2262,15 @@ declare class ExtendedWrapper {
2258
2262
  private apiKey?;
2259
2263
  private timeout;
2260
2264
  private retries;
2265
+ /** Per-market rules from GET /markets (tradingConfig); retained for process lifetime (no TTL). */
2266
+ private marketTradingRulesCache;
2267
+ private marketTradingRulesInflight;
2261
2268
  constructor(config: ExtendedWrapperConfig);
2262
2269
  /**
2263
2270
  * Make HTTP request with retry logic and error handling
2264
2271
  */
2265
2272
  private makeRequest;
2273
+ private resolveTradingRules;
2266
2274
  /**
2267
2275
  * Create a new order on Extended Exchange
2268
2276
  */
@@ -2338,11 +2346,11 @@ declare class ExtendedWrapper {
2338
2346
  * Convenience method to create a buy order
2339
2347
  */
2340
2348
  createBuyOrder(marketName: string, amount: string, price: string, options?: {
2341
- postOnly?: boolean;
2342
- reduceOnly?: boolean;
2343
- previousOrderId?: number;
2344
- externalId?: string;
2345
- timeInForce?: TimeInForce;
2349
+ post_only?: boolean;
2350
+ reduce_only?: boolean;
2351
+ previous_order_id?: number;
2352
+ external_id?: string;
2353
+ time_in_force?: TimeInForce;
2346
2354
  }): Promise<ExtendedApiResponse<PlacedOrder>>;
2347
2355
  /**
2348
2356
  * Get order by ID
@@ -2354,11 +2362,11 @@ declare class ExtendedWrapper {
2354
2362
  * Convenience method to create a sell order
2355
2363
  */
2356
2364
  createSellOrder(marketName: string, amount: string, price: string, options?: {
2357
- postOnly?: boolean;
2358
- reduceOnly?: boolean;
2359
- previousOrderId?: number;
2360
- externalId?: string;
2361
- timeInForce?: TimeInForce;
2365
+ post_only?: boolean;
2366
+ reduce_only?: boolean;
2367
+ previous_order_id?: number;
2368
+ external_id?: string;
2369
+ time_in_force?: TimeInForce;
2362
2370
  }): Promise<ExtendedApiResponse<PlacedOrder>>;
2363
2371
  /**
2364
2372
  * Get positions for a specific market
@@ -3328,12 +3336,12 @@ declare function routeSummary(r: ExecutionRoute): string;
3328
3336
  declare class SolveBudget {
3329
3337
  private unusedBalance;
3330
3338
  private walletBalance;
3331
- /** Idle {@link StateManagerConfig.assetToken} in the vault allocator */
3332
- private vaultAssetBalance;
3333
3339
  /**
3334
- * Idle {@link StateManagerConfig.usdcToken} in the vault allocator.
3335
- * When asset and USDC are the same token, this is null (all VA stablecoin is in {@link vaultAssetBalance} only).
3340
+ * Idle non-stable {@link StateManagerConfig.assetToken} in the vault allocator.
3341
+ * Null when asset and USDC are the same token (VA idle stablecoin is only in {@link vaultUsdcBalance}).
3336
3342
  */
3343
+ private vaultAssetBalance;
3344
+ /** Idle {@link StateManagerConfig.usdcToken} in the vault allocator (including when it is also the strategy asset). */
3337
3345
  private vaultUsdcBalance;
3338
3346
  private extendedPositions;
3339
3347
  private extendedBalance;
@@ -3415,11 +3423,11 @@ declare class SolveBudget {
3415
3423
  */
3416
3424
  applyBuffer(factor: number): void;
3417
3425
  get vesuPoolState(): VesuPoolState;
3418
- /** Buffered VA USD: strategy-asset slot + optional USDC slot. */
3426
+ /** Buffered VA USD: non-stable asset slot (if any) + USDC slot. */
3419
3427
  get vaUsd(): number;
3420
3428
  /** Buffered USD in VA strategy-asset bucket only. */
3421
3429
  get vaAssetUsd(): number;
3422
- /** Buffered USD in VA USDC bucket (0 when asset === USDC). */
3430
+ /** Buffered USD in VA USDC bucket (includes full VA idle when asset === USDC). */
3423
3431
  get vaUsdcUsd(): number;
3424
3432
  get walletUsd(): number;
3425
3433
  get vaWalletUsd(): number;
@@ -3452,8 +3460,10 @@ declare class SolveBudget {
3452
3460
  get vesuDebtDeltas(): readonly Web3Number[];
3453
3461
  /** Per-pool rebalance flags derived from target HF checks. */
3454
3462
  get vesuRebalanceFlags(): readonly boolean[];
3455
- /** Raw USD in VA (USDC slot + asset slot); spend caps when executing transfers. */
3463
+ /** Raw USD in VA (USDC slot + non-stable asset slot when distinct); spend caps when executing transfers. */
3456
3464
  private _vaRawUsd;
3465
+ /** VA liquidity usable for repay / {@link spendVaRawUsd} (matches nominal balances after any {@link applyBuffer} scaling). */
3466
+ get vaRawUsd(): number;
3457
3467
  private _walletRawUsd;
3458
3468
  /** Remove up to `usd` notional from a token balance, scaling token amount proportionally. */
3459
3469
  private _deductUsdFromTokenBalance;
@@ -3571,19 +3581,19 @@ declare class ExtendedSVKVesuStateManager {
3571
3581
  * results in private instance variables.
3572
3582
  */
3573
3583
  private _refresh;
3574
- /** True when strategy asset and USDC share one token — VA USDC slot is unused (all in asset balance). */
3584
+ /** True when strategy asset and USDC share one token — VA idle balance is tracked as USDC, not as asset. */
3575
3585
  private _vaultAssetAndUsdcAreSameToken;
3576
3586
  /**
3577
- * Reads the {@link StateManagerConfig.assetToken} balance idle in the vault allocator.
3587
+ * Reads idle {@link StateManagerConfig.assetToken} in the vault allocator when it differs from USDC.
3588
+ * When asset and USDC are the same token, returns null (that balance is reported via {@link _fetchVaultAllocatorUsdcBalanceIfDistinct} only).
3578
3589
  */
3579
3590
  private _fetchVaultAllocatorAssetBalance;
3580
3591
  /**
3581
- * Reads {@link StateManagerConfig.usdcToken} in the vault allocator when it differs from
3582
- * {@link StateManagerConfig.assetToken}. Otherwise returns null (treat VA USDC as 0; stablecoin is only under asset).
3592
+ * Reads {@link StateManagerConfig.usdcToken} idle in the vault allocator (always distinct asset or USDC-as-asset).
3583
3593
  */
3584
3594
  private _fetchVaultAllocatorUsdcBalanceIfDistinct;
3585
3595
  /**
3586
- * Merges vault-allocator asset, optional vault-allocator USDC, and operator wallet
3596
+ * Merges vault-allocator asset (if any), vault-allocator USDC, and operator wallet
3587
3597
  * balances into entries keyed by token address.
3588
3598
  */
3589
3599
  private _computeUnusedBalances;
@@ -3744,7 +3754,9 @@ declare class ExtendedSVKVesuStateManager {
3744
3754
  * Design: accumulate all ext-to-wallet moves, add transfer routes at the end (principle #3).
3745
3755
  */
3746
3756
  /**
3747
- * Unified LTV classifier. Computes both Vesu repay and Extended margin needs,
3757
+ * Unified LTV / exposure classifier: `rebalance()` drives both LTV (debt, margin,
3758
+ * funding) and Vesu↔Extended position alignment. There is no separate imbalance pass.
3759
+ * Computes both Vesu repay and Extended margin needs,
3748
3760
  * then builds all routes in a single pass with no duplicate transfers.
3749
3761
  *
3750
3762
  * Vesu repay priority: VA > Wallet > ExtAvl > ExtUpnl
@@ -3756,8 +3768,9 @@ declare class ExtendedSVKVesuStateManager {
3756
3768
  private _isLtvRebalanceNoop;
3757
3769
  /**
3758
3770
  * Turn pure rebalance() deltas into execution routes.
3759
- * Order: Vesu multiply (decrease/increase) → Extended lever → aggregated transfers
3760
- * (REALISE_PNL, EXTENDED_TO_WALLET + WAIT, WALLET_TO_VA, VESU_BORROW, VESU_REPAY, VA_TO_EXTENDED).
3771
+ * Order: Vesu multiply decrease → Extended decrease → aggregated transfers
3772
+ * (REALISE_PNL, EXTENDED_TO_WALLET + WAIT, WALLET_TO_VA, VESU_BORROW, VESU_REPAY, VA_TO_EXTENDED),
3773
+ * then Vesu multiply increase and Extended increase (need VA / Extended funded first).
3761
3774
  */
3762
3775
  private _buildLtvRoutesFromRebalanceDeltas;
3763
3776
  /**
@@ -3797,6 +3810,7 @@ declare class ExtendedSVKVesuStateManager {
3797
3810
  * CRISIS_UNDO_EXTENDED_MAX_LEVERAGE]
3798
3811
  */
3799
3812
  private _rebalanceFunds;
3813
+ private _scaleVesuPoolDeltasByFactor;
3800
3814
  /**
3801
3815
  * 3. New Deposits / Excess Funds
3802
3816
  *
@@ -3811,6 +3825,11 @@ declare class ExtendedSVKVesuStateManager {
3811
3825
  * Computes allocation split between Vesu and Extended, then sources
3812
3826
  * funds and creates lever-increase routes.
3813
3827
  *
3828
+ * Order: {@link _rebalanceFunds} first → project VA / Extended liquid after the same funding
3829
+ * routes (wallet→VA, borrow→VA, VA→Extended, Extended→wallet→VA) → ideal Vesu/Extended deltas
3830
+ * from distributable split → cap common BTC by min(Vesu fundable, Extended fundable) → scale
3831
+ * Vesu deltas and recompute Extended deltas so both sides stay matched.
3832
+ *
3814
3833
  * Fund flow (single pass — avoid VA→Extended then Extended→wallet round-trips):
3815
3834
  * 1) Treat Vesu borrow headroom that the multiply route will consume as covering
3816
3835
  * part of the Vesu USDC need (no standalone VESU_BORROW for that slice). Cap