@haven-fi/solauto-sdk 1.0.692 → 1.0.694
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/services/rebalance/rebalanceTxBuilder.js +1 -1
- package/dist/services/transactions/transactionUtils.js +1 -1
- package/local/shared.ts +2 -4
- package/local/txSandbox.ts +12 -71
- package/package.json +1 -1
- package/src/services/rebalance/rebalanceTxBuilder.ts +1 -1
- package/src/services/transactions/transactionUtils.ts +1 -1
@@ -203,7 +203,7 @@ class RebalanceTxBuilder {
|
|
203
203
|
// TODO: remove me
|
204
204
|
if ((0, utils_1.isMarginfiPosition)(this.client.pos)) {
|
205
205
|
const weightedAssets = this.values.endResult.supplyUsd * (0, utils_1.bytesToI80F48)(this.client.pos.supplyBank.config.assetWeightInit.value);
|
206
|
-
const weightedLiabs = this.values.endResult.debtUsd * (0, utils_1.bytesToI80F48)(this.client.pos.debtBank.config.
|
206
|
+
const weightedLiabs = this.values.endResult.debtUsd * (0, utils_1.bytesToI80F48)(this.client.pos.debtBank.config.liabilityWeightInit.value);
|
207
207
|
(0, utils_1.consoleLog)("Weighted assets & liabs:", weightedAssets, weightedLiabs);
|
208
208
|
}
|
209
209
|
const firstRebalance = this.client.rebalanceIx(generated_1.RebalanceStep.PreSwap, rebalanceDetails);
|
@@ -348,7 +348,7 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
|
|
348
348
|
let errCode;
|
349
349
|
let errName;
|
350
350
|
// sub ixs to account for computeUnitLimit and computeUnitPrice that get added
|
351
|
-
const getComputeIxs = (txIdx) => (0, utils_1.addTxOptimizations)(umi, txs[txIdx], 1,
|
351
|
+
const getComputeIxs = (txIdx) => (0, utils_1.addTxOptimizations)(umi, txs[txIdx], 1, simulationSuccessful ? 1 : undefined).getInstructions().length - txs[txIdx].getInstructions().length;
|
352
352
|
try {
|
353
353
|
if (error instanceof types_1.BundleSimulationError) {
|
354
354
|
errTxIdx = error.details.transactionIdx;
|
package/local/shared.ts
CHANGED
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
import {
|
12
12
|
getSolanaRpcConnection,
|
13
13
|
getBatches,
|
14
|
-
|
14
|
+
LOCAL_IRONFORGE_API_URL,
|
15
15
|
} from "../src";
|
16
16
|
|
17
17
|
function loadSecretKey(keypairPath: string) {
|
@@ -26,9 +26,7 @@ export function getSecretKey(keypairFilename: string = "id"): Uint8Array {
|
|
26
26
|
}
|
27
27
|
|
28
28
|
const keypair = Keypair.fromSecretKey(getSecretKey("solauto-fees"));
|
29
|
-
const [connection, _] = getSolanaRpcConnection(
|
30
|
-
buildIronforgeApiUrl(process.env.IRONFORGE_API_KEY ?? "")
|
31
|
-
);
|
29
|
+
const [connection, _] = getSolanaRpcConnection(LOCAL_IRONFORGE_API_URL);
|
32
30
|
|
33
31
|
export async function createAndSendV0Tx(
|
34
32
|
txInstructions: TransactionInstruction[],
|
package/local/txSandbox.ts
CHANGED
@@ -29,7 +29,7 @@ import {
|
|
29
29
|
import { getSecretKey } from "./shared";
|
30
30
|
|
31
31
|
const payForTransaction = false;
|
32
|
-
const testProgram =
|
32
|
+
const testProgram = false;
|
33
33
|
const lpEnv: ProgramEnv = "Prod";
|
34
34
|
|
35
35
|
let [, umi] = getSolanaRpcConnection(
|
@@ -53,82 +53,23 @@ export async function main() {
|
|
53
53
|
});
|
54
54
|
|
55
55
|
await client.initializeExistingSolautoPosition({
|
56
|
-
positionId:
|
57
|
-
authority: new PublicKey("
|
56
|
+
positionId: 1,
|
57
|
+
authority: new PublicKey("R8Nnj1UqK1BRPnfJYj7MvfPUK3GmEzmgh1CwFFtUNsF"),
|
58
58
|
// lpUserAccount: new PublicKey(
|
59
59
|
// "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
|
60
60
|
// ),
|
61
61
|
});
|
62
62
|
|
63
|
-
const
|
64
|
-
umi,
|
65
|
-
publicKey("6cgYhBFWCc5sNHxkvSRhd5H9AdAHR41zKwuF37HmLry5")
|
66
|
-
);
|
67
|
-
const debtBank = await fetchBank(
|
68
|
-
umi,
|
69
|
-
publicKey("3J5rKmCi7JXG6qmiobFJyAidVTnnNAMGj4jomfBxKGRM")
|
70
|
-
);
|
71
|
-
const supplyWeight = bytesToI80F48(supplyBank.config.assetWeightInit.value);
|
72
|
-
const debtWeight = bytesToI80F48(debtBank.config.liabilityWeightInit.value);
|
73
|
-
|
74
|
-
console.log(
|
75
|
-
getLiqUtilzationRateBps(
|
76
|
-
34.36833665228071,
|
77
|
-
23.61750715267401,
|
78
|
-
client.pos.state.liqThresholdBps
|
79
|
-
),
|
80
|
-
34.36833665228071 * supplyWeight,
|
81
|
-
23.61750715267401 * debtWeight
|
82
|
-
);
|
83
|
-
console.log(
|
84
|
-
getLiqUtilzationRateBps(
|
85
|
-
34.328721976,
|
86
|
-
23.575158311,
|
87
|
-
client.pos.state.liqThresholdBps
|
88
|
-
),
|
89
|
-
34.328721976 * supplyWeight,
|
90
|
-
23.575158311 * debtWeight
|
91
|
-
);
|
92
|
-
console.log(
|
93
|
-
getLiqUtilzationRateBps(
|
94
|
-
34.265152701,
|
95
|
-
23.530695876,
|
96
|
-
client.pos.state.liqThresholdBps
|
97
|
-
),
|
98
|
-
34.265152701 * supplyWeight,
|
99
|
-
23.530695876 * debtWeight
|
100
|
-
);
|
101
|
-
console.log(client.pos.maxBoostToBps);
|
102
|
-
console.log(getMaxLiqUtilizationRateBps(client.pos.state.maxLtvBps, client.pos.state.liqThresholdBps, 0));
|
103
|
-
|
104
|
-
// const debtBank = await fetchBank(
|
105
|
-
// umi,
|
106
|
-
// publicKey("3J5rKmCi7JXG6qmiobFJyAidVTnnNAMGj4jomfBxKGRM")
|
107
|
-
// );
|
108
|
-
// const supplyBank = await fetchBank(
|
109
|
-
// umi,
|
110
|
-
// publicKey("6cgYhBFWCc5sNHxkvSRhd5H9AdAHR41zKwuF37HmLry5")
|
111
|
-
// );
|
112
|
-
|
113
|
-
// console.log(
|
114
|
-
// bytesToI80F48(supplyBank.config.assetWeightInit.value),
|
115
|
-
// bytesToI80F48(debtBank.config.liabilityWeightInit.value)
|
116
|
-
// );
|
117
|
-
|
118
|
-
// await client.pos.refreshPositionState();
|
63
|
+
const transactionItems = [rebalance(client)];
|
119
64
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
// retryConfig: { totalRetries: 5 },
|
129
|
-
// });
|
130
|
-
// const statuses = await txManager.send(transactionItems);
|
131
|
-
// consoleLog(statuses);
|
65
|
+
const txManager = new ClientTransactionsManager({
|
66
|
+
txHandler: client,
|
67
|
+
txRunType: payForTransaction ? "normal" : "only-simulate",
|
68
|
+
priorityFeeSetting: PriorityFeeSetting.Default,
|
69
|
+
retryConfig: { totalRetries: 1 },
|
70
|
+
});
|
71
|
+
const statuses = await txManager.send(transactionItems);
|
72
|
+
consoleLog(statuses);
|
132
73
|
}
|
133
74
|
|
134
75
|
async function refreshAll() {
|
package/package.json
CHANGED
@@ -350,7 +350,7 @@ export class RebalanceTxBuilder {
|
|
350
350
|
// TODO: remove me
|
351
351
|
if (isMarginfiPosition(this.client.pos)) {
|
352
352
|
const weightedAssets = this.values.endResult.supplyUsd * bytesToI80F48(this.client.pos.supplyBank!.config.assetWeightInit.value);
|
353
|
-
const weightedLiabs = this.values.endResult.debtUsd * bytesToI80F48(this.client.pos.debtBank!.config.
|
353
|
+
const weightedLiabs = this.values.endResult.debtUsd * bytesToI80F48(this.client.pos.debtBank!.config.liabilityWeightInit.value);
|
354
354
|
consoleLog("Weighted assets & liabs:", weightedAssets, weightedLiabs);
|
355
355
|
}
|
356
356
|
|