@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.cjs
CHANGED
|
@@ -58945,7 +58945,7 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
58945
58945
|
const earningAssets = new Set(
|
|
58946
58946
|
this.portfolio.getPositions().filter((p) => p.earning).map((p) => p.asset)
|
|
58947
58947
|
);
|
|
58948
|
-
|
|
58948
|
+
let savePositions = allPositions.flatMap(
|
|
58949
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) => ({
|
|
58950
58950
|
protocolId: p.protocolId,
|
|
58951
58951
|
protocol: p.protocol,
|
|
@@ -58955,7 +58955,22 @@ To sell investment: t2000 invest sell ${params.amount} ${fromAsset}`,
|
|
|
58955
58955
|
}))
|
|
58956
58956
|
);
|
|
58957
58957
|
if (savePositions.length === 0) {
|
|
58958
|
-
|
|
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
|
+
}
|
|
58959
58974
|
}
|
|
58960
58975
|
const borrowPositions = allPositions.flatMap(
|
|
58961
58976
|
(p) => p.positions.borrows.filter((b2) => b2.amount > 0.01)
|