@haven-fi/solauto-sdk 1.0.394 → 1.0.396
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/constants/marginfiAccounts.js +14 -14
- package/dist/constants/tokenConstants.js +6 -6
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jitoUtils.js +9 -5
- package/package.json +1 -1
- package/src/constants/marginfiAccounts.ts +14 -14
- package/src/constants/tokenConstants.ts +6 -6
- package/src/utils/jitoUtils.ts +8 -5
- package/tests/transactions/solautoMarginfi.ts +75 -73
@@ -190,19 +190,19 @@ exports.MARGINFI_ACCOUNTS = {
|
|
190
190
|
priceOracle: USDC_PRICE_ORACLE,
|
191
191
|
},
|
192
192
|
},
|
193
|
-
["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
}
|
193
|
+
// ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
|
194
|
+
// [tokens.HMTR]: {
|
195
|
+
// bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
|
196
|
+
// liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
|
197
|
+
// vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
|
198
|
+
// priceOracle: SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
|
199
|
+
// },
|
200
|
+
// [tokens.USDC]: {
|
201
|
+
// bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
|
202
|
+
// liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
|
203
|
+
// vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
|
204
|
+
// priceOracle: USDC_PRICE_ORACLE,
|
205
|
+
// }
|
206
|
+
// }
|
207
207
|
};
|
208
208
|
exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
|
@@ -49,7 +49,7 @@ exports.ALL_SUPPORTED_TOKENS = [
|
|
49
49
|
exports.POPCAT,
|
50
50
|
exports.RETARDIO,
|
51
51
|
exports.BILLY,
|
52
|
-
|
52
|
+
// HMTR,
|
53
53
|
];
|
54
54
|
exports.TOKEN_INFO = {
|
55
55
|
[web3_js_1.PublicKey.default.toString()]: {
|
@@ -161,9 +161,9 @@ exports.TOKEN_INFO = {
|
|
161
161
|
decimals: 6,
|
162
162
|
isMeme: true,
|
163
163
|
},
|
164
|
-
[
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
},
|
164
|
+
// [HMTR]: {
|
165
|
+
// ticker: "HMTR",
|
166
|
+
// decimals: 0,
|
167
|
+
// isMeme: true,
|
168
|
+
// },
|
169
169
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;
|
1
|
+
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AA2MD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAuE/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -75,16 +75,17 @@ async function simulateJitoBundle(umi, txs) {
|
|
75
75
|
"Content-Type": "application/json",
|
76
76
|
},
|
77
77
|
});
|
78
|
-
const res = resp.data
|
79
|
-
if (res && res.summary.failed) {
|
80
|
-
const
|
78
|
+
const res = resp.data;
|
79
|
+
if (res.result.value && res.result.value.summary.failed) {
|
80
|
+
const resValue = res.result.value;
|
81
|
+
const transactionResults = resValue.transactionResults;
|
81
82
|
transactionResults.forEach((x) => {
|
82
83
|
x.logs?.forEach((y) => {
|
83
84
|
(0, generalUtils_1.consoleLog)(y);
|
84
85
|
});
|
85
86
|
});
|
86
87
|
const failedTxIdx = transactionResults.length;
|
87
|
-
const txFailure =
|
88
|
+
const txFailure = resValue.summary.failed.error.TransactionFailure;
|
88
89
|
if (txFailure) {
|
89
90
|
const info = parseJitoErrorMessage(txFailure[1]);
|
90
91
|
if (info) {
|
@@ -95,7 +96,10 @@ async function simulateJitoBundle(umi, txs) {
|
|
95
96
|
});
|
96
97
|
}
|
97
98
|
}
|
98
|
-
throw new Error(txFailure ? txFailure[1] :
|
99
|
+
throw new Error(txFailure ? txFailure[1] : resValue.summary.failed.toString());
|
100
|
+
}
|
101
|
+
else if (res.error.message) {
|
102
|
+
throw new Error(res.error.message);
|
99
103
|
}
|
100
104
|
return res;
|
101
105
|
});
|
package/package.json
CHANGED
@@ -172,20 +172,20 @@ export const MARGINFI_ACCOUNTS: {
|
|
172
172
|
priceOracle: USDC_PRICE_ORACLE,
|
173
173
|
},
|
174
174
|
},
|
175
|
-
["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
}
|
175
|
+
// ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
|
176
|
+
// [tokens.HMTR]: {
|
177
|
+
// bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
|
178
|
+
// liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
|
179
|
+
// vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
|
180
|
+
// priceOracle: SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
|
181
|
+
// },
|
182
|
+
// [tokens.USDC]: {
|
183
|
+
// bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
|
184
|
+
// liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
|
185
|
+
// vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
|
186
|
+
// priceOracle: USDC_PRICE_ORACLE,
|
187
|
+
// }
|
188
|
+
// }
|
189
189
|
};
|
190
190
|
|
191
191
|
export const MARGINFI_ACCOUNTS_LOOKUP_TABLE =
|
@@ -48,7 +48,7 @@ export const ALL_SUPPORTED_TOKENS = [
|
|
48
48
|
POPCAT,
|
49
49
|
RETARDIO,
|
50
50
|
BILLY,
|
51
|
-
HMTR,
|
51
|
+
// HMTR,
|
52
52
|
];
|
53
53
|
|
54
54
|
interface TokenInfo {
|
@@ -170,9 +170,9 @@ export const TOKEN_INFO: { [key: string]: TokenInfo } = {
|
|
170
170
|
decimals: 6,
|
171
171
|
isMeme: true,
|
172
172
|
},
|
173
|
-
[HMTR]: {
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
},
|
173
|
+
// [HMTR]: {
|
174
|
+
// ticker: "HMTR",
|
175
|
+
// decimals: 0,
|
176
|
+
// isMeme: true,
|
177
|
+
// },
|
178
178
|
};
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -103,11 +103,12 @@ async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
|
|
103
103
|
}
|
104
104
|
);
|
105
105
|
|
106
|
-
const res = resp.data
|
106
|
+
const res = resp.data as any;
|
107
107
|
|
108
|
-
if (res && res.summary.failed) {
|
108
|
+
if (res.result.value && res.result.value.summary.failed) {
|
109
|
+
const resValue = res.result.value;
|
109
110
|
const transactionResults =
|
110
|
-
|
111
|
+
resValue.transactionResults as SimulatedTransactionResponse[];
|
111
112
|
transactionResults.forEach((x) => {
|
112
113
|
x.logs?.forEach((y) => {
|
113
114
|
consoleLog(y);
|
@@ -115,7 +116,7 @@ async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
|
|
115
116
|
});
|
116
117
|
|
117
118
|
const failedTxIdx = transactionResults.length;
|
118
|
-
const txFailure =
|
119
|
+
const txFailure = resValue.summary.failed.error.TransactionFailure;
|
119
120
|
|
120
121
|
if (txFailure) {
|
121
122
|
const info = parseJitoErrorMessage(txFailure[1] as string);
|
@@ -128,7 +129,9 @@ async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
|
|
128
129
|
}
|
129
130
|
}
|
130
131
|
|
131
|
-
throw new Error(txFailure ? txFailure[1] :
|
132
|
+
throw new Error(txFailure ? txFailure[1] : resValue.summary.failed.toString());
|
133
|
+
} else if (res.error.message) {
|
134
|
+
throw new Error(res.error.message);
|
132
135
|
}
|
133
136
|
|
134
137
|
return res;
|
@@ -60,12 +60,12 @@ export function getLeverageFactor(
|
|
60
60
|
}
|
61
61
|
|
62
62
|
describe("Solauto Marginfi tests", async () => {
|
63
|
-
const signer = setupTest();
|
64
|
-
|
63
|
+
// const signer = setupTest();
|
64
|
+
const signer = setupTest("solauto-manager");
|
65
65
|
|
66
66
|
const payForTransactions = false;
|
67
|
-
const testProgram =
|
68
|
-
const positionId =
|
67
|
+
const testProgram = false;
|
68
|
+
const positionId = 4;
|
69
69
|
|
70
70
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
71
71
|
const client = new SolautoMarginfiClient(
|
@@ -78,18 +78,20 @@ describe("Solauto Marginfi tests", async () => {
|
|
78
78
|
const supplyDecimals = 6;
|
79
79
|
const debtDecimals = 6;
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
81
|
+
await client.initialize({
|
82
|
+
signer,
|
83
|
+
positionId,
|
84
|
+
authority: new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"),
|
85
|
+
// new: true,
|
86
|
+
// marginfiAccount: new PublicKey(
|
87
|
+
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
88
|
+
// ),
|
89
|
+
// marginfiGroup: new PublicKey("G1rt3EpQ43K3bY457rhukQGRAo2QxydFAGRKqnjKzyr5"),
|
90
|
+
// supplyMint: new PublicKey("3B5wuUrMEi5yATD7on46hKfej3pfmd7t1RKgrsN3pump"),
|
91
|
+
// debtMint: new PublicKey(USDC),
|
92
|
+
});
|
93
|
+
|
94
|
+
console.log(await client.getFreshPositionState());
|
93
95
|
|
94
96
|
// console.log(JSON.stringify(await getJupPriceData([new PublicKey("7JhmUcZrrfhyt5nTSu3AfsrUq2L9992a7AhwdSDxdoL2")], true), null, 2));
|
95
97
|
// console.log(JSON.stringify(await getJupPriceData([new PublicKey(POPCAT)], true), null, 2));
|
@@ -133,7 +135,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
133
135
|
// );
|
134
136
|
// console.log(stateKeverage);
|
135
137
|
|
136
|
-
console.log(await fetchTokenPrices([new PublicKey(HMTR)]));
|
138
|
+
// console.log(await fetchTokenPrices([new PublicKey(HMTR)]));
|
137
139
|
|
138
140
|
const transactionItems: TransactionItem[] = [];
|
139
141
|
// const settingParams: SolautoSettingsParametersInpArgs = {
|
@@ -203,13 +205,13 @@ describe("Solauto Marginfi tests", async () => {
|
|
203
205
|
// )
|
204
206
|
// );
|
205
207
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
208
|
+
transactionItems.push(
|
209
|
+
new TransactionItem(
|
210
|
+
async (attemptNum) =>
|
211
|
+
await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
|
212
|
+
"rebalance"
|
213
|
+
)
|
214
|
+
);
|
213
215
|
|
214
216
|
// transactionItems.push(
|
215
217
|
// new TransactionItem(
|
@@ -240,44 +242,44 @@ describe("Solauto Marginfi tests", async () => {
|
|
240
242
|
// )
|
241
243
|
// );
|
242
244
|
|
243
|
-
transactionItems.push(
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
);
|
245
|
+
// transactionItems.push(
|
246
|
+
// new TransactionItem(
|
247
|
+
// async () => ({
|
248
|
+
// tx: transactionBuilder()
|
249
|
+
// .add(
|
250
|
+
// client.protocolInteraction(
|
251
|
+
// solautoAction("Withdraw", [
|
252
|
+
// { __kind: "Some", fields: [toBaseUnit(0.01, 9)] },
|
253
|
+
// ])
|
254
|
+
// )
|
255
|
+
// )
|
256
|
+
// }),
|
257
|
+
// "withdraw"
|
258
|
+
// )
|
259
|
+
// );
|
258
260
|
|
259
|
-
transactionItems.push(
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
);
|
261
|
+
// transactionItems.push(
|
262
|
+
// new TransactionItem(
|
263
|
+
// async () => ({
|
264
|
+
// tx: transactionBuilder()
|
265
|
+
// .add(
|
266
|
+
// client.protocolInteraction(
|
267
|
+
// solautoAction("Withdraw", [
|
268
|
+
// { __kind: "Some", fields: [toBaseUnit(0.01, 9)] },
|
269
|
+
// ])
|
270
|
+
// )
|
271
|
+
// )
|
272
|
+
// .add(
|
273
|
+
// client.protocolInteraction(
|
274
|
+
// solautoAction("Withdraw", [
|
275
|
+
// { __kind: "Some", fields: [toBaseUnit(300, 9)] },
|
276
|
+
// ])
|
277
|
+
// )
|
278
|
+
// )
|
279
|
+
// }),
|
280
|
+
// "withdraw"
|
281
|
+
// )
|
282
|
+
// );
|
281
283
|
|
282
284
|
// transactionItems.push(
|
283
285
|
// new TransactionItem(
|
@@ -288,19 +290,19 @@ describe("Solauto Marginfi tests", async () => {
|
|
288
290
|
// )
|
289
291
|
// );
|
290
292
|
|
291
|
-
|
292
|
-
|
293
|
+
const temp = (statuses: TransactionManagerStatuses) =>
|
294
|
+
console.log(statuses);
|
293
295
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
296
|
+
const statuses = await new TransactionsManager(
|
297
|
+
client,
|
298
|
+
temp,
|
299
|
+
!payForTransactions ? "only-simulate" : "normal",
|
300
|
+
PriorityFeeSetting.Low,
|
301
|
+
true,
|
302
|
+
undefined,
|
303
|
+
0
|
304
|
+
).clientSend(transactionItems);
|
303
305
|
|
304
|
-
|
306
|
+
console.log(statuses);
|
305
307
|
});
|
306
308
|
});
|