@t2000/sdk 0.18.24 → 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 +17 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +17 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -58942,7 +58942,7 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
58942
58942
|
const earningAssets = new Set(
|
|
58943
58943
|
this.portfolio.getPositions().filter((p) => p.earning).map((p) => p.asset)
|
|
58944
58944
|
);
|
|
58945
|
-
|
|
58945
|
+
let savePositions = allPositions.flatMap(
|
|
58946
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) => ({
|
|
58947
58947
|
protocolId: p.protocolId,
|
|
58948
58948
|
protocol: p.protocol,
|
|
@@ -58952,7 +58952,22 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
58952
58952
|
}))
|
|
58953
58953
|
);
|
|
58954
58954
|
if (savePositions.length === 0) {
|
|
58955
|
-
|
|
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
|
+
}
|
|
58956
58971
|
}
|
|
58957
58972
|
const borrowPositions = allPositions.flatMap(
|
|
58958
58973
|
(p) => p.positions.borrows.filter((b2) => b2.amount > 0.01)
|