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