@haven-fi/solauto-sdk 1.0.722 → 1.0.724
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/solautoPosition/marginfiSolautoPositionEx.js +1 -1
- package/dist/solautoPosition/positionUtils.js +1 -1
- package/local/logPositions.ts +8 -7
- package/local/txSandbox.ts +13 -9
- package/package.json +1 -1
- package/src/solautoPosition/marginfiSolautoPositionEx.ts +1 -1
- package/src/solautoPosition/positionUtils.ts +3 -3
@@ -78,7 +78,7 @@ class MarginfiSolautoPositionEx extends solautoPositionEx_1.SolautoPositionEx {
|
|
78
78
|
}
|
79
79
|
get supplyUsdWithdrawable() {
|
80
80
|
const deposits = (0, utils_1.fromBaseUnit)((0, utils_1.getBankLiquidityUsedBaseUnit)(this.supplyBank, true), this.supplyMintInfo.decimals);
|
81
|
-
const borrows = (0, utils_1.fromBaseUnit)((0, utils_1.
|
81
|
+
const borrows = (0, utils_1.fromBaseUnit)((0, utils_1.getBankLiquidityUsedBaseUnit)(this.supplyBank, false), this.supplyMintInfo.decimals);
|
82
82
|
return Math.min((deposits - borrows), this.totalSupply) * this.supplyPrice();
|
83
83
|
}
|
84
84
|
async refreshPositionState(priceType) {
|
@@ -37,7 +37,7 @@ async function getPositionExBulk(umi, publicKeys) {
|
|
37
37
|
}
|
38
38
|
async function getOrCreatePositionEx(umi, authority, positionId, programId, customArgs, contextUpdates) {
|
39
39
|
const publicKey = (0, utils_1.getSolautoPositionAccount)(authority, positionId, programId);
|
40
|
-
const data = await (0, generated_1.safeFetchSolautoPosition)(umi, (0, umi_web3js_adapters_1.fromWeb3JsPublicKey)(publicKey));
|
40
|
+
const data = await (0, utils_1.retryWithExponentialBackoff)(async () => await (0, generated_1.safeFetchSolautoPosition)(umi, (0, umi_web3js_adapters_1.fromWeb3JsPublicKey)(publicKey)));
|
41
41
|
const lendingPlatform = data
|
42
42
|
? data.position.lendingPlatform
|
43
43
|
: customArgs.lendingPlatform;
|
package/local/logPositions.ts
CHANGED
@@ -92,12 +92,10 @@ async function main(filterWhitelist: boolean, programEnv: ProgramEnv = "Prod") {
|
|
92
92
|
);
|
93
93
|
}
|
94
94
|
|
95
|
-
const positionsEx = (
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
)
|
100
|
-
).sort((a, b) => a.netWorthUsd() - b.netWorthUsd());
|
95
|
+
const positionsEx = await getPositionExBulk(
|
96
|
+
umi,
|
97
|
+
positions.map((x) => new PublicKey(x.publicKey!))
|
98
|
+
);
|
101
99
|
|
102
100
|
const tokensUsed = Array.from(
|
103
101
|
new Set(
|
@@ -114,7 +112,10 @@ async function main(filterWhitelist: boolean, programEnv: ProgramEnv = "Prod") {
|
|
114
112
|
let unhealthyPositions = 0;
|
115
113
|
let awaitingBoostPositions = 0;
|
116
114
|
|
117
|
-
|
115
|
+
const sortedPositions = positionsEx.sort(
|
116
|
+
(a, b) => a.netWorthUsd() - b.netWorthUsd()
|
117
|
+
);
|
118
|
+
for (const pos of sortedPositions) {
|
118
119
|
const actionToTake = pos.eligibleForRebalance(0);
|
119
120
|
|
120
121
|
const repayFrom = pos.settings!.repayToBps + pos.settings!.repayGap;
|
package/local/txSandbox.ts
CHANGED
@@ -54,16 +54,20 @@ export async function main() {
|
|
54
54
|
// ),
|
55
55
|
});
|
56
56
|
|
57
|
-
|
57
|
+
await client.pos.refreshPositionState();
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
59
|
+
console.log(client.pos.supplyUsdWithdrawable);
|
60
|
+
|
61
|
+
// const transactionItems = [rebalance(client)];
|
62
|
+
|
63
|
+
// const txManager = new ClientTransactionsManager({
|
64
|
+
// txHandler: client,
|
65
|
+
// txRunType: payForTransaction ? "normal" : "only-simulate",
|
66
|
+
// priorityFeeSetting: PriorityFeeSetting.Default,
|
67
|
+
// retryConfig: { totalRetries: 2 },
|
68
|
+
// });
|
69
|
+
// const statuses = await txManager.send(transactionItems);
|
70
|
+
// consoleLog(statuses);
|
67
71
|
}
|
68
72
|
|
69
73
|
async function refreshAll() {
|
package/package.json
CHANGED
@@ -135,7 +135,7 @@ export class MarginfiSolautoPositionEx extends SolautoPositionEx {
|
|
135
135
|
this.supplyMintInfo.decimals
|
136
136
|
);
|
137
137
|
const borrows = fromBaseUnit(
|
138
|
-
|
138
|
+
getBankLiquidityUsedBaseUnit(this.supplyBank, false),
|
139
139
|
this.supplyMintInfo.decimals
|
140
140
|
);
|
141
141
|
return Math.min((deposits - borrows), this.totalSupply) * this.supplyPrice()!;
|
@@ -84,9 +84,9 @@ export async function getOrCreatePositionEx(
|
|
84
84
|
contextUpdates?: ContextUpdates
|
85
85
|
): Promise<SolautoPositionEx> {
|
86
86
|
const publicKey = getSolautoPositionAccount(authority, positionId, programId);
|
87
|
-
const data = await
|
88
|
-
|
89
|
-
|
87
|
+
const data = await retryWithExponentialBackoff(
|
88
|
+
async () =>
|
89
|
+
await safeFetchSolautoPosition(umi, fromWeb3JsPublicKey(publicKey))
|
90
90
|
);
|
91
91
|
|
92
92
|
const lendingPlatform = data
|