@haven-fi/solauto-sdk 1.0.108 → 1.0.110
Sign up to get free protection for your applications and to get access to all the features.
@@ -42,13 +42,13 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
42
42
|
this.solautoPositionData = await (0, generated_1.safeFetchSolautoPosition)(this.umi, (0, umi_1.publicKey)(this.solautoPosition));
|
43
43
|
this.solautoPositionState = this.solautoPositionData?.state;
|
44
44
|
this.supplyMint =
|
45
|
-
args.supplyMint ??
|
46
|
-
(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.solautoPositionData.position.supplyMint);
|
45
|
+
(args.supplyMint ??
|
46
|
+
this.solautoPositionData) ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.solautoPositionData.position.supplyMint) : web3_js_1.PublicKey.default;
|
47
47
|
this.positionSupplyTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition, this.supplyMint);
|
48
48
|
this.signerSupplyTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.supplyMint);
|
49
49
|
this.debtMint =
|
50
|
-
args.debtMint ??
|
51
|
-
(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.solautoPositionData.position.debtMint);
|
50
|
+
(args.debtMint ??
|
51
|
+
this.solautoPositionData) ? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.solautoPositionData.position.debtMint) : web3_js_1.PublicKey.default;
|
52
52
|
this.positionDebtTa = (0, accountUtils_1.getTokenAccount)(this.solautoPosition, this.debtMint);
|
53
53
|
this.signerDebtTa = (0, accountUtils_1.getTokenAccount)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey), this.debtMint);
|
54
54
|
this.referralStateManager = new referralStateManager_1.ReferralStateManager(this.heliusApiKey);
|
@@ -119,7 +119,7 @@ async function rebalanceChoresBefore(client, tx, accountsGettingCreated) {
|
|
119
119
|
if (rebalanceInstructions.length === 0) {
|
120
120
|
return (0, umi_1.transactionBuilder)();
|
121
121
|
}
|
122
|
-
const usesAccount = (key) =>
|
122
|
+
const usesAccount = (key) => tx.getInstructions().some((t) => t.keys.some((k) => (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(k.pubkey).equals(key)));
|
123
123
|
const checkReferralSupplyTa = client.referredBySupplyTa && usesAccount(client.referredBySupplyTa);
|
124
124
|
const checkSolautoFeesTa = usesAccount(client.solautoFeesSupplyTa);
|
125
125
|
const checkIntermediaryMfiAccount = client.lendingPlatform === generated_1.LendingPlatform.Marginfi &&
|
package/package.json
CHANGED
@@ -144,7 +144,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
144
144
|
|
145
145
|
this.supplyMint =
|
146
146
|
args.supplyMint ??
|
147
|
-
toWeb3JsPublicKey(this.solautoPositionData!.position.supplyMint);
|
147
|
+
this.solautoPositionData ? toWeb3JsPublicKey(this.solautoPositionData!.position.supplyMint) : PublicKey.default;
|
148
148
|
this.positionSupplyTa = getTokenAccount(
|
149
149
|
this.solautoPosition,
|
150
150
|
this.supplyMint
|
@@ -156,7 +156,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
156
156
|
|
157
157
|
this.debtMint =
|
158
158
|
args.debtMint ??
|
159
|
-
toWeb3JsPublicKey(this.solautoPositionData!.position.debtMint);
|
159
|
+
this.solautoPositionData ? toWeb3JsPublicKey(this.solautoPositionData!.position.debtMint) : PublicKey.default;
|
160
160
|
this.positionDebtTa = getTokenAccount(this.solautoPosition, this.debtMint);
|
161
161
|
this.signerDebtTa = getTokenAccount(
|
162
162
|
toWeb3JsPublicKey(this.signer.publicKey),
|
@@ -235,10 +235,10 @@ export async function rebalanceChoresBefore(
|
|
235
235
|
}
|
236
236
|
|
237
237
|
const usesAccount = (key: PublicKey) =>
|
238
|
-
|
238
|
+
tx.getInstructions().some((t) =>
|
239
239
|
t.keys.some((k) => toWeb3JsPublicKey(k.pubkey).equals(key))
|
240
240
|
);
|
241
|
-
|
241
|
+
|
242
242
|
const checkReferralSupplyTa =
|
243
243
|
client.referredBySupplyTa && usesAccount(client.referredBySupplyTa);
|
244
244
|
const checkSolautoFeesTa = usesAccount(client.solautoFeesSupplyTa);
|
@@ -20,12 +20,12 @@ import { PublicKey } from "@solana/web3.js";
|
|
20
20
|
import { USDC_MINT } from "../../src/constants";
|
21
21
|
|
22
22
|
describe("Solauto Marginfi tests", async () => {
|
23
|
-
|
24
|
-
const signer = setupTest("solauto-manager");
|
23
|
+
const signer = setupTest();
|
24
|
+
// const signer = setupTest("solauto-manager");
|
25
25
|
|
26
26
|
const payForTransactions = false;
|
27
27
|
const useJitoBundle = false;
|
28
|
-
const positionId =
|
28
|
+
const positionId = 1;
|
29
29
|
|
30
30
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
31
31
|
|
@@ -39,7 +39,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
39
39
|
{
|
40
40
|
signer,
|
41
41
|
positionId,
|
42
|
-
authority: new PublicKey("92xmP49BQycn3t2HkGxLAweN3jjrExxSNpywA3xF7mYY")
|
42
|
+
// authority: new PublicKey("92xmP49BQycn3t2HkGxLAweN3jjrExxSNpywA3xF7mYY")
|
43
43
|
// marginfiAccount: new PublicKey(
|
44
44
|
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
45
45
|
// ),
|
@@ -123,7 +123,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
123
123
|
transactionItems.push(
|
124
124
|
new TransactionItem(
|
125
125
|
async (attemptNum) =>
|
126
|
-
await buildSolautoRebalanceTransaction(client,
|
126
|
+
await buildSolautoRebalanceTransaction(client, 1500, attemptNum),
|
127
127
|
"rebalance"
|
128
128
|
)
|
129
129
|
);
|