@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.
package/dist/index.cjs CHANGED
@@ -627,7 +627,8 @@ async function refreshStableOracles(tx, client, config, pools) {
627
627
  config.oracle.wormholeStateId
628
628
  );
629
629
  await pythClient.updatePriceFeeds(tx, priceUpdateData, pythFeedIds);
630
- } catch {
630
+ } catch (err) {
631
+ console.error("[t2000] Pyth oracle push failed, falling back to cached prices:", err.message ?? err);
631
632
  }
632
633
  }
633
634
  for (const pool of stablePools) {
@@ -745,6 +746,10 @@ async function buildWithdrawTx(client, address, amount, options = {}) {
745
746
  const effectiveAmount = Math.min(amount, Math.max(0, deposited - WITHDRAW_DUST_BUFFER));
746
747
  if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
747
748
  const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
749
+ if (rawAmount <= 0) {
750
+ throw new T2000Error("INVALID_AMOUNT", `Withdrawal amount too small to represent (effective=${effectiveAmount}, raw=${rawAmount}, decimals=${assetInfo.decimals})`);
751
+ }
752
+ console.error(`[t2000] withdraw: asset=${asset} poolId=${pool.id} amount=${amount} deposited=${deposited} effective=${effectiveAmount} raw=${rawAmount} supplyBal=${assetState?.supplyBalance} index=${pool.currentSupplyIndex}`);
748
753
  const tx = new transactions.Transaction();
749
754
  tx.setSender(address);
750
755
  await refreshStableOracles(tx, client, config, pools);
@@ -785,6 +790,10 @@ async function addWithdrawToTx(tx, client, address, amount, options = {}) {
785
790
  const effectiveAmount = Math.min(amount, Math.max(0, deposited - WITHDRAW_DUST_BUFFER));
786
791
  if (effectiveAmount <= 0) throw new T2000Error("NO_COLLATERAL", `Nothing to withdraw for ${assetInfo.displayName} on NAVI`);
787
792
  const rawAmount = Number(stableToRaw(effectiveAmount, assetInfo.decimals));
793
+ if (rawAmount <= 0) {
794
+ throw new T2000Error("INVALID_AMOUNT", `Withdrawal amount too small to represent (effective=${effectiveAmount}, raw=${rawAmount}, decimals=${assetInfo.decimals})`);
795
+ }
796
+ console.error(`[t2000] withdraw: asset=${asset} poolId=${pool.id} amount=${amount} deposited=${deposited} effective=${effectiveAmount} raw=${rawAmount} supplyBal=${assetState?.supplyBalance} index=${pool.currentSupplyIndex}`);
788
797
  await refreshStableOracles(tx, client, config, pools);
789
798
  const [balance] = tx.moveCall({
790
799
  target: `${config.package}::incentive_v3::withdraw_v2`,