@t2000/sdk 0.9.7 → 0.9.8

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.
@@ -374,7 +374,8 @@ async function refreshStableOracles(tx, client, config, pools) {
374
374
  config.oracle.wormholeStateId
375
375
  );
376
376
  await pythClient.updatePriceFeeds(tx, priceUpdateData, pythFeedIds);
377
- } catch {
377
+ } catch (err) {
378
+ console.error("[t2000] Pyth oracle push failed, falling back to cached prices:", err.message ?? err);
378
379
  }
379
380
  }
380
381
  for (const pool of stablePools) {
@@ -492,6 +493,10 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
492
493
  const effectiveAmount = Math.min(amount, Math.max(0, deposited - WITHDRAW_DUST_BUFFER));
493
494
  if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
494
495
  const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
496
+ if (rawAmount <= 0) {
497
+ throw new T2000Error("INVALID_AMOUNT", `Withdrawal amount too small to represent (effective=${effectiveAmount}, raw=${rawAmount}, decimals=${assetInfo.decimals})`);
498
+ }
499
+ console.error(`[t2000] withdraw: asset=${asset} poolId=${pool.id} amount=${amount} deposited=${deposited} effective=${effectiveAmount} raw=${rawAmount} supplyBal=${assetState?.supplyBalance} index=${pool.currentSupplyIndex}`);
495
500
  const tx = new Transaction();
496
501
  tx.setSender(address);
497
502
  await refreshStableOracles(tx, client, config, pools);
@@ -532,6 +537,10 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
532
537
  const effectiveAmount = Math.min(amount, Math.max(0, deposited - WITHDRAW_DUST_BUFFER));
533
538
  if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
534
539
  const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
540
+ if (rawAmount <= 0) {
541
+ throw new T2000Error("INVALID_AMOUNT", `Withdrawal amount too small to represent (effective=${effectiveAmount}, raw=${rawAmount}, decimals=${assetInfo.decimals})`);
542
+ }
543
+ console.error(`[t2000] withdraw: asset=${asset} poolId=${pool.id} amount=${amount} deposited=${deposited} effective=${effectiveAmount} raw=${rawAmount} supplyBal=${assetState?.supplyBalance} index=${pool.currentSupplyIndex}`);
535
544
  await refreshStableOracles(tx, client, config, pools);
536
545
  const [balance] = tx.moveCall({
537
546
  target: `${config.package}::incentive_v3::withdraw_v2`,