@t2000/sdk 0.18.23 → 0.18.25

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,14 +56159,19 @@ async function trySponsored(client, keypair, tx) {
56159
56159
  };
56160
56160
  }
56161
56161
  async function waitForIndexer(client, digest) {
56162
+ const start = Date.now();
56162
56163
  for (let i = 0; i < 3; i++) {
56163
56164
  try {
56164
56165
  await client.getTransactionBlock({ digest, options: { showObjectChanges: true } });
56165
- return;
56166
+ break;
56166
56167
  } catch {
56167
- await new Promise((r) => setTimeout(r, 1e3));
56168
+ await new Promise((r) => setTimeout(r, 500));
56168
56169
  }
56169
56170
  }
56171
+ const elapsed = Date.now() - start;
56172
+ if (elapsed < 2e3) {
56173
+ await new Promise((r) => setTimeout(r, 2e3 - elapsed));
56174
+ }
56170
56175
  }
56171
56176
  async function executeWithGas(client, keypair, buildTx, options) {
56172
56177
  if (options?.enforcer && options?.metadata) {
@@ -58937,7 +58942,7 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
58937
58942
  const earningAssets = new Set(
58938
58943
  this.portfolio.getPositions().filter((p) => p.earning).map((p) => p.asset)
58939
58944
  );
58940
- const savePositions = allPositions.flatMap(
58945
+ let savePositions = allPositions.flatMap(
58941
58946
  (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) => ({
58942
58947
  protocolId: p.protocolId,
58943
58948
  protocol: p.protocol,
@@ -58947,7 +58952,22 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
58947
58952
  }))
58948
58953
  );
58949
58954
  if (savePositions.length === 0) {
58950
- throw new T2000Error("NO_COLLATERAL", "No savings positions to rebalance. Use `t2000 save <amount>` first.");
58955
+ for (let retry = 0; retry < 2 && savePositions.length === 0; retry++) {
58956
+ await new Promise((r) => setTimeout(r, 3e3));
58957
+ const freshPositions = await this.registry.allPositions(this._address);
58958
+ savePositions = freshPositions.flatMap(
58959
+ (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) => ({
58960
+ protocolId: p.protocolId,
58961
+ protocol: p.protocol,
58962
+ asset: s.asset,
58963
+ amount: s.amount,
58964
+ apy: s.apy
58965
+ }))
58966
+ );
58967
+ }
58968
+ if (savePositions.length === 0) {
58969
+ throw new T2000Error("NO_COLLATERAL", "No savings positions to rebalance. Use `t2000 save <amount>` first.");
58970
+ }
58951
58971
  }
58952
58972
  const borrowPositions = allPositions.flatMap(
58953
58973
  (p) => p.positions.borrows.filter((b2) => b2.amount > 0.01)