@t2000/sdk 0.18.25 → 0.18.26

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.js CHANGED
@@ -56159,19 +56159,14 @@ async function trySponsored(client, keypair, tx) {
56159
56159
  };
56160
56160
  }
56161
56161
  async function waitForIndexer(client, digest) {
56162
- const start = Date.now();
56163
56162
  for (let i = 0; i < 3; i++) {
56164
56163
  try {
56165
56164
  await client.getTransactionBlock({ digest, options: { showObjectChanges: true } });
56166
- break;
56165
+ return;
56167
56166
  } catch {
56168
56167
  await new Promise((r) => setTimeout(r, 500));
56169
56168
  }
56170
56169
  }
56171
- const elapsed = Date.now() - start;
56172
- if (elapsed < 2e3) {
56173
- await new Promise((r) => setTimeout(r, 2e3 - elapsed));
56174
- }
56175
56170
  }
56176
56171
  async function executeWithGas(client, keypair, buildTx, options) {
56177
56172
  if (options?.enforcer && options?.metadata) {
@@ -57243,10 +57238,17 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
57243
57238
  reportFee(this._address, "save", fee.amount, fee.rate, gasResult.digest);
57244
57239
  this.emitBalanceChange(asset, saveAmount, "save", gasResult.digest);
57245
57240
  let savingsBalance = saveAmount;
57246
- try {
57247
- const positions = await this.positions();
57248
- savingsBalance = positions.positions.filter((p) => p.type === "save" && p.asset === asset).reduce((sum, p) => sum + p.amount, 0);
57249
- } catch {
57241
+ for (let attempt = 0; attempt < 5; attempt++) {
57242
+ try {
57243
+ const positions = await this.positions();
57244
+ const actual = positions.positions.filter((p) => p.type === "save" && p.asset === asset).reduce((sum, p) => sum + p.amount, 0);
57245
+ if (actual > 0) {
57246
+ savingsBalance = actual;
57247
+ break;
57248
+ }
57249
+ } catch {
57250
+ }
57251
+ await new Promise((r) => setTimeout(r, 2e3));
57250
57252
  }
57251
57253
  return {
57252
57254
  success: true,
@@ -57353,6 +57355,14 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
57353
57355
  }
57354
57356
  }
57355
57357
  this.emitBalanceChange("USDC", finalAmount, "withdraw", gasResult.digest);
57358
+ for (let attempt = 0; attempt < 5; attempt++) {
57359
+ try {
57360
+ const bal = await queryBalance(this.client, this._address);
57361
+ if ((bal.stables.USDC ?? 0) > 0.5) break;
57362
+ } catch {
57363
+ }
57364
+ await new Promise((r) => setTimeout(r, 2e3));
57365
+ }
57356
57366
  return {
57357
57367
  success: true,
57358
57368
  tx: gasResult.digest,
@@ -57473,6 +57483,14 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
57473
57483
  if (totalUsdcReceived <= 0) {
57474
57484
  throw new T2000Error("NO_COLLATERAL", "No savings to withdraw across any protocol");
57475
57485
  }
57486
+ for (let attempt = 0; attempt < 5; attempt++) {
57487
+ try {
57488
+ const bal = await queryBalance(this.client, this._address);
57489
+ if ((bal.stables.USDC ?? 0) > 0.5) break;
57490
+ } catch {
57491
+ }
57492
+ await new Promise((r) => setTimeout(r, 2e3));
57493
+ }
57476
57494
  return {
57477
57495
  success: true,
57478
57496
  tx: gasResult.digest,
@@ -59196,6 +59214,17 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
59196
59214
  txDigests.push(depositResult.digest);
59197
59215
  totalGasCost += depositResult.gasCostSui;
59198
59216
  }
59217
+ for (let attempt = 0; attempt < 5; attempt++) {
59218
+ try {
59219
+ const positions = await this.positions();
59220
+ const newPos = positions.positions.find(
59221
+ (p) => p.type === "save" && p.asset === bestRate.asset && p.amount > 0.01
59222
+ );
59223
+ if (newPos) break;
59224
+ } catch {
59225
+ }
59226
+ await new Promise((r) => setTimeout(r, 2e3));
59227
+ }
59199
59228
  return {
59200
59229
  executed: true,
59201
59230
  steps,