@t2000/sdk 0.18.27 → 0.18.28
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 +2 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -44
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57355,14 +57355,6 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
|
|
|
57355
57355
|
}
|
|
57356
57356
|
}
|
|
57357
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
|
-
}
|
|
57366
57358
|
return {
|
|
57367
57359
|
success: true,
|
|
57368
57360
|
tx: gasResult.digest,
|
|
@@ -57483,14 +57475,6 @@ To access invested funds: t2000 invest sell ${params.amount} ${asset}`,
|
|
|
57483
57475
|
if (totalUsdcReceived <= 0) {
|
|
57484
57476
|
throw new T2000Error("NO_COLLATERAL", "No savings to withdraw across any protocol");
|
|
57485
57477
|
}
|
|
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
|
-
}
|
|
57494
57478
|
return {
|
|
57495
57479
|
success: true,
|
|
57496
57480
|
tx: gasResult.digest,
|
|
@@ -58960,7 +58944,7 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
58960
58944
|
const earningAssets = new Set(
|
|
58961
58945
|
this.portfolio.getPositions().filter((p) => p.earning).map((p) => p.asset)
|
|
58962
58946
|
);
|
|
58963
|
-
|
|
58947
|
+
const savePositions = allPositions.flatMap(
|
|
58964
58948
|
(p) => p.positions.supplies.filter((s) => s.amount > 0.01).filter((s) => !earningAssets.has(s.asset)).filter((s) => !(s.asset in INVESTMENT_ASSETS)).map((s) => ({
|
|
58965
58949
|
protocolId: p.protocolId,
|
|
58966
58950
|
protocol: p.protocol,
|
|
@@ -58970,22 +58954,7 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
58970
58954
|
}))
|
|
58971
58955
|
);
|
|
58972
58956
|
if (savePositions.length === 0) {
|
|
58973
|
-
|
|
58974
|
-
await new Promise((r) => setTimeout(r, 3e3));
|
|
58975
|
-
const freshPositions = await this.registry.allPositions(this._address);
|
|
58976
|
-
savePositions = freshPositions.flatMap(
|
|
58977
|
-
(p) => p.positions.supplies.filter((s) => s.amount > 0.01).filter((s) => !earningAssets.has(s.asset)).filter((s) => !(s.asset in INVESTMENT_ASSETS)).map((s) => ({
|
|
58978
|
-
protocolId: p.protocolId,
|
|
58979
|
-
protocol: p.protocol,
|
|
58980
|
-
asset: s.asset,
|
|
58981
|
-
amount: s.amount,
|
|
58982
|
-
apy: s.apy
|
|
58983
|
-
}))
|
|
58984
|
-
);
|
|
58985
|
-
}
|
|
58986
|
-
if (savePositions.length === 0) {
|
|
58987
|
-
throw new T2000Error("NO_COLLATERAL", "No savings positions to rebalance. Use `t2000 save <amount>` first.");
|
|
58988
|
-
}
|
|
58957
|
+
throw new T2000Error("NO_COLLATERAL", "No savings positions to rebalance. Use `t2000 save <amount>` first.");
|
|
58989
58958
|
}
|
|
58990
58959
|
const borrowPositions = allPositions.flatMap(
|
|
58991
58960
|
(p) => p.positions.borrows.filter((b2) => b2.amount > 0.01)
|
|
@@ -59214,17 +59183,6 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
59214
59183
|
txDigests.push(depositResult.digest);
|
|
59215
59184
|
totalGasCost += depositResult.gasCostSui;
|
|
59216
59185
|
}
|
|
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
|
-
}
|
|
59228
59186
|
return {
|
|
59229
59187
|
executed: true,
|
|
59230
59188
|
steps,
|