@t2000/sdk 0.9.7 → 0.9.9

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.
@@ -376,7 +376,8 @@ async function refreshStableOracles(tx, client, config, pools) {
376
376
  config.oracle.wormholeStateId
377
377
  );
378
378
  await pythClient.updatePriceFeeds(tx, priceUpdateData, pythFeedIds);
379
- } catch {
379
+ } catch (err) {
380
+ console.error("[t2000] Pyth oracle push failed, falling back to cached prices:", err.message ?? err);
380
381
  }
381
382
  }
382
383
  for (const pool of stablePools) {
@@ -494,6 +495,9 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
494
495
  const effectiveAmount = Math.min(amount, Math.max(0, deposited - WITHDRAW_DUST_BUFFER));
495
496
  if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
496
497
  const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
498
+ if (rawAmount <= 0) {
499
+ throw new T2000Error("INVALID_AMOUNT", `Withdrawal amount rounds to zero \u2014 balance is dust`);
500
+ }
497
501
  const tx = new transactions.Transaction();
498
502
  tx.setSender(address);
499
503
  await refreshStableOracles(tx, client, config, pools);
@@ -534,6 +538,13 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
534
538
  const effectiveAmount = Math.min(amount, Math.max(0, deposited - WITHDRAW_DUST_BUFFER));
535
539
  if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
536
540
  const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
541
+ if (rawAmount <= 0) {
542
+ const [coin2] = tx.moveCall({
543
+ target: "0x2::coin::zero",
544
+ typeArguments: [pool.suiCoinType]
545
+ });
546
+ return { coin: coin2, effectiveAmount: 0 };
547
+ }
537
548
  await refreshStableOracles(tx, client, config, pools);
538
549
  const [balance] = tx.moveCall({
539
550
  target: `${config.package}::incentive_v3::withdraw_v2`,