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