@haven-fi/solauto-sdk 1.0.99 → 1.0.101
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoClient.d.ts +0 -1
- package/dist/clients/solautoClient.d.ts.map +1 -1
- package/dist/clients/solautoClient.js +9 -4
- package/dist/transactions/transactionUtils.d.ts +1 -1
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +2 -2
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/solautoClient.ts +9 -10
- package/src/transactions/transactionUtils.ts +7 -8
- package/src/transactions/transactionsManager.ts +0 -1
@@ -40,7 +40,6 @@ export declare abstract class SolautoClient extends TxHandler {
|
|
40
40
|
solautoFeesWallet: PublicKey;
|
41
41
|
solautoFeesSupplyTa: PublicKey;
|
42
42
|
authorityLutAddress?: PublicKey;
|
43
|
-
upToDateLutAccounts: PublicKey[];
|
44
43
|
livePositionUpdates: LivePositionUpdates;
|
45
44
|
constructor(heliusApiKey: string, localTest?: boolean | undefined);
|
46
45
|
initialize(args: SolautoClientArgs, lendingPlatform: LendingPlatform): Promise<void>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,
|
1
|
+
{"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAEL,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAOnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC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AW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAEf,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAalE"}
|
@@ -80,9 +80,6 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
80
80
|
this.authorityLutAddress = authorityReferralStateData?.lookupTable && !(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(authorityReferralStateData.lookupTable).equals(web3_js_1.PublicKey.default)
|
81
81
|
? (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(authorityReferralStateData.lookupTable)
|
82
82
|
: undefined;
|
83
|
-
this.upToDateLutAccounts = (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey).equals(this.authority)
|
84
|
-
? await this.fetchExistingAuthorityLutAccounts()
|
85
|
-
: [];
|
86
83
|
this.log("Position state: ", this.solautoPositionState);
|
87
84
|
this.log("Position settings: ", this.solautoPositionData?.position?.settingParams);
|
88
85
|
this.log("Position DCA: ", (this.solautoPositionData?.position?.dca?.automation?.targetPeriods ??
|
@@ -127,35 +124,41 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
127
124
|
];
|
128
125
|
}
|
129
126
|
async fetchExistingAuthorityLutAccounts() {
|
127
|
+
console.log("Fetching lut accounts", this.authorityLutAddress?.toString());
|
130
128
|
const lookupTable = this.authorityLutAddress
|
131
129
|
? await this.connection.getAddressLookupTable(this.authorityLutAddress)
|
132
130
|
: null;
|
131
|
+
console.log(lookupTable?.value);
|
133
132
|
if (!lookupTable || lookupTable?.value === null) {
|
134
133
|
this.authorityLutAddress = undefined;
|
135
134
|
}
|
136
135
|
return lookupTable?.value?.state.addresses ?? [];
|
137
136
|
}
|
138
137
|
async updateLookupTable() {
|
138
|
+
console.log("Getting existing accoutns");
|
139
139
|
const existingLutAccounts = await this.fetchExistingAuthorityLutAccounts();
|
140
|
+
console.log("existing accoutns", existingLutAccounts.length);
|
140
141
|
if (this.lutAccountsToAdd().every((element) => existingLutAccounts
|
141
142
|
.map((x) => x.toString().toLowerCase())
|
142
143
|
.includes(element.toString().toLowerCase()))) {
|
143
144
|
return undefined;
|
144
145
|
}
|
145
146
|
let tx = (0, umi_1.transactionBuilder)();
|
147
|
+
console.log("lut address", this.authorityLutAddress?.toString());
|
146
148
|
if (this.authorityLutAddress === undefined) {
|
147
149
|
const [createLookupTableInst, lookupTableAddress] = web3_js_1.AddressLookupTableProgram.createLookupTable({
|
148
150
|
authority: this.authority,
|
149
151
|
payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
|
150
152
|
recentSlot: await this.umi.rpc.getSlot({ commitment: "finalized" }),
|
151
153
|
});
|
154
|
+
console.log("new luit", lookupTableAddress.toString());
|
152
155
|
this.authorityLutAddress = lookupTableAddress;
|
153
156
|
tx = tx.add((0, solanaUtils_1.getWrappedInstruction)(this.signer, createLookupTableInst));
|
154
157
|
}
|
155
158
|
const accountsToAdd = this.lutAccountsToAdd().filter((x) => !existingLutAccounts
|
156
159
|
.map((x) => x.toString().toLowerCase())
|
157
160
|
.includes(x.toString().toLowerCase()));
|
158
|
-
|
161
|
+
console.log("add accounts", accountsToAdd.length);
|
159
162
|
if (accountsToAdd.length > 0) {
|
160
163
|
tx = tx.add((0, solanaUtils_1.getWrappedInstruction)(this.signer, web3_js_1.AddressLookupTableProgram.extendLookupTable({
|
161
164
|
payer: (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(this.signer.publicKey),
|
@@ -164,12 +167,14 @@ class SolautoClient extends txHandler_1.TxHandler {
|
|
164
167
|
addresses: accountsToAdd,
|
165
168
|
})));
|
166
169
|
}
|
170
|
+
console.log("Hello");
|
167
171
|
const addingReferredBy = accountsToAdd.length === 1 &&
|
168
172
|
accountsToAdd[0].toString().toLowerCase() ===
|
169
173
|
this.referredBySupplyTa?.toString().toLowerCase();
|
170
174
|
if (tx.getInstructions().length > 0) {
|
171
175
|
this.log("Updating authority lookup table...");
|
172
176
|
}
|
177
|
+
console.log("instructions", tx.getInstructions().length);
|
173
178
|
return { updateLutTx: tx, needsToBeIsolated: !addingReferredBy };
|
174
179
|
}
|
175
180
|
solautoPositionSettings() {
|
@@ -8,5 +8,5 @@ export declare function buildSolautoRebalanceTransaction(client: SolautoClient,
|
|
8
8
|
tx: TransactionBuilder;
|
9
9
|
lookupTableAddresses: string[];
|
10
10
|
} | undefined>;
|
11
|
-
export declare function convertReferralFeesToDestination(umi: Umi, referralState: ReferralState, tokenAccount: SplTokenAccount): Promise<[TransactionBuilder, string[]]>;
|
11
|
+
export declare function convertReferralFeesToDestination(umi: Umi, referralState: ReferralState, tokenAccount: SplTokenAccount): Promise<[TransactionBuilder, string[]] | undefined>;
|
12
12
|
//# sourceMappingURL=transactionUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAuMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC;IACT,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACG,SAAS,CACZ,CAyHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CA8BrD"}
|
@@ -47,9 +47,9 @@ function getWSolUsage(client, solautoActions, initiatingDcaIn, cancellingDcaIn)
|
|
47
47
|
}
|
48
48
|
async function transactionChoresBefore(client, accountsGettingCreated, solautoActions, initiatingDcaIn) {
|
49
49
|
let chores = (0, umi_1.transactionBuilder)();
|
50
|
-
if (client.referralStateManager.
|
50
|
+
if (client.referralStateManager.referralStateData === null ||
|
51
51
|
(client.referredByState !== undefined &&
|
52
|
-
client.referralStateManager.referralStateData
|
52
|
+
client.referralStateManager.referralStateData?.referredByState ===
|
53
53
|
(0, umi_1.publicKey)(web3_js_1.PublicKey.default)) ||
|
54
54
|
(client.authorityLutAddress !== undefined &&
|
55
55
|
client.referralStateManager.referralStateData.lookupTable ==
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7D,cAAM,YAAY;IAGG,WAAW,EAAE,MAAM,EAAE;IAAE,OAAO,CAAC,GAAG;IAFrD,KAAK,EAAE,uBAAuB,EAAE,CAAM;gBAEnB,WAAW,EAAE,MAAM,EAAE,EAAU,GAAG,EAAE,GAAG;IAGpD,YAAY,CAChB,m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,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,aAAa,CAAC;IARxB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,YAAY,CAAC,EAAE,OAAO,YAAA,EACtB,YAAY,CAAC,EAAE,OAAO,YAAA,EACtB,aAAa,CAAC,EAAE,aAAa,YAAA;YAKzB,uBAAuB;IAsCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAiB9D,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,kBAAkB;IAkB7D,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,eAAe,CAAC,EAAE,kBAAkB;IAkEzE,IAAI,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,eAAe,CAAC,EAAE,kBAAkB,EAAE,WAAW,CAAC,EAAE,OAAO;CAyGjG"}
|
package/package.json
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
import "rpc-websockets/dist/lib/client";
|
2
2
|
import {
|
3
3
|
AddressLookupTableProgram,
|
4
|
-
Connection,
|
5
4
|
PublicKey,
|
6
5
|
} from "@solana/web3.js";
|
7
6
|
import {
|
8
7
|
Signer,
|
9
8
|
TransactionBuilder,
|
10
|
-
Umi,
|
11
9
|
isOption,
|
12
10
|
publicKey,
|
13
11
|
PublicKey as UmiPublicKey,
|
@@ -47,7 +45,6 @@ import {
|
|
47
45
|
} from "../constants/generalAccounts";
|
48
46
|
import { JupSwapDetails } from "../utils/jupiterUtils";
|
49
47
|
import {
|
50
|
-
getSolanaRpcConnection,
|
51
48
|
getWrappedInstruction,
|
52
49
|
splTokenTransferUmiIx,
|
53
50
|
} from "../utils/solanaUtils";
|
@@ -103,7 +100,6 @@ export abstract class SolautoClient extends TxHandler {
|
|
103
100
|
public solautoFeesSupplyTa!: PublicKey;
|
104
101
|
|
105
102
|
public authorityLutAddress?: PublicKey;
|
106
|
-
public upToDateLutAccounts!: PublicKey[];
|
107
103
|
|
108
104
|
public livePositionUpdates: LivePositionUpdates = new LivePositionUpdates();
|
109
105
|
|
@@ -207,11 +203,6 @@ export abstract class SolautoClient extends TxHandler {
|
|
207
203
|
this.authorityLutAddress = authorityReferralStateData?.lookupTable && !toWeb3JsPublicKey(authorityReferralStateData.lookupTable).equals(PublicKey.default)
|
208
204
|
? toWeb3JsPublicKey(authorityReferralStateData.lookupTable)
|
209
205
|
: undefined;
|
210
|
-
this.upToDateLutAccounts = toWeb3JsPublicKey(this.signer.publicKey).equals(
|
211
|
-
this.authority
|
212
|
-
)
|
213
|
-
? await this.fetchExistingAuthorityLutAccounts()
|
214
|
-
: [];
|
215
206
|
|
216
207
|
this.log("Position state: ", this.solautoPositionState);
|
217
208
|
this.log(
|
@@ -271,9 +262,11 @@ export abstract class SolautoClient extends TxHandler {
|
|
271
262
|
}
|
272
263
|
|
273
264
|
async fetchExistingAuthorityLutAccounts(): Promise<PublicKey[]> {
|
265
|
+
console.log("Fetching lut accounts", this.authorityLutAddress?.toString());
|
274
266
|
const lookupTable = this.authorityLutAddress
|
275
267
|
? await this.connection.getAddressLookupTable(this.authorityLutAddress)
|
276
268
|
: null;
|
269
|
+
console.log(lookupTable?.value);
|
277
270
|
if (!lookupTable || lookupTable?.value === null) {
|
278
271
|
this.authorityLutAddress = undefined;
|
279
272
|
}
|
@@ -283,7 +276,9 @@ export abstract class SolautoClient extends TxHandler {
|
|
283
276
|
async updateLookupTable(): Promise<
|
284
277
|
{ updateLutTx: TransactionBuilder; needsToBeIsolated: boolean } | undefined
|
285
278
|
> {
|
279
|
+
console.log("Getting existing accoutns");
|
286
280
|
const existingLutAccounts = await this.fetchExistingAuthorityLutAccounts();
|
281
|
+
console.log("existing accoutns", existingLutAccounts.length);
|
287
282
|
if (
|
288
283
|
this.lutAccountsToAdd().every((element) =>
|
289
284
|
existingLutAccounts
|
@@ -296,6 +291,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
296
291
|
|
297
292
|
let tx = transactionBuilder();
|
298
293
|
|
294
|
+
console.log("lut address", this.authorityLutAddress?.toString());
|
299
295
|
if (this.authorityLutAddress === undefined) {
|
300
296
|
const [createLookupTableInst, lookupTableAddress] =
|
301
297
|
AddressLookupTableProgram.createLookupTable({
|
@@ -303,6 +299,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
303
299
|
payer: toWeb3JsPublicKey(this.signer.publicKey),
|
304
300
|
recentSlot: await this.umi.rpc.getSlot({ commitment: "finalized" }),
|
305
301
|
});
|
302
|
+
console.log("new luit", lookupTableAddress.toString());
|
306
303
|
this.authorityLutAddress = lookupTableAddress;
|
307
304
|
tx = tx.add(getWrappedInstruction(this.signer, createLookupTableInst));
|
308
305
|
}
|
@@ -313,7 +310,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
313
310
|
.map((x) => x.toString().toLowerCase())
|
314
311
|
.includes(x.toString().toLowerCase())
|
315
312
|
);
|
316
|
-
|
313
|
+
console.log("add accounts", accountsToAdd.length);
|
317
314
|
|
318
315
|
if (accountsToAdd.length > 0) {
|
319
316
|
tx = tx.add(
|
@@ -328,6 +325,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
328
325
|
)
|
329
326
|
);
|
330
327
|
}
|
328
|
+
console.log("Hello");
|
331
329
|
|
332
330
|
const addingReferredBy =
|
333
331
|
accountsToAdd.length === 1 &&
|
@@ -337,6 +335,7 @@ export abstract class SolautoClient extends TxHandler {
|
|
337
335
|
if (tx.getInstructions().length > 0) {
|
338
336
|
this.log("Updating authority lookup table...");
|
339
337
|
}
|
338
|
+
console.log("instructions", tx.getInstructions().length);
|
340
339
|
|
341
340
|
return { updateLutTx: tx, needsToBeIsolated: !addingReferredBy };
|
342
341
|
}
|
@@ -110,9 +110,9 @@ async function transactionChoresBefore(
|
|
110
110
|
let chores = transactionBuilder();
|
111
111
|
|
112
112
|
if (
|
113
|
-
client.referralStateManager.
|
113
|
+
client.referralStateManager.referralStateData === null ||
|
114
114
|
(client.referredByState !== undefined &&
|
115
|
-
client.referralStateManager.referralStateData
|
115
|
+
client.referralStateManager.referralStateData?.referredByState ===
|
116
116
|
publicKey(PublicKey.default)) ||
|
117
117
|
(client.authorityLutAddress !== undefined &&
|
118
118
|
client.referralStateManager.referralStateData!.lookupTable ==
|
@@ -553,11 +553,10 @@ export async function buildSolautoRebalanceTransaction(
|
|
553
553
|
client: SolautoClient,
|
554
554
|
targetLiqUtilizationRateBps?: number,
|
555
555
|
attemptNum?: number
|
556
|
-
): Promise<
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
}
|
556
|
+
): Promise<{
|
557
|
+
tx: TransactionBuilder;
|
558
|
+
lookupTableAddresses: string[];
|
559
|
+
}
|
561
560
|
| undefined
|
562
561
|
> {
|
563
562
|
client.solautoPositionState = await client.getFreshPositionState();
|
@@ -686,7 +685,7 @@ export async function convertReferralFeesToDestination(
|
|
686
685
|
umi: Umi,
|
687
686
|
referralState: ReferralState,
|
688
687
|
tokenAccount: SplTokenAccount
|
689
|
-
): Promise<[TransactionBuilder, string[]]> {
|
688
|
+
): Promise<[TransactionBuilder, string[]] | undefined> {
|
690
689
|
const { lookupTableAddresses, setupInstructions, swapIx } =
|
691
690
|
await getJupSwapTransaction(umi.identity, {
|
692
691
|
amount: tokenAccount.amount,
|
@@ -16,7 +16,6 @@ import {
|
|
16
16
|
} from "../utils/generalUtils";
|
17
17
|
import { getTransactionChores } from "./transactionUtils";
|
18
18
|
import { PriorityFeeSetting } from "../types";
|
19
|
-
import { Connection, PublicKey } from "@solana/web3.js";
|
20
19
|
import { ReferralStateManager, TxHandler } from "../clients";
|
21
20
|
// import { sendJitoBundledTransactions } from "../utils/jitoUtils";
|
22
21
|
|