@@ -65,7 +65,6 @@ import {
65
65
createWithdrawAndBurnWrapperTokensInstruction ,
66
66
} from "@solendprotocol/token2022-wrapper-sdk" ;
67
67
import { ReserveType } from "./utils" ;
68
- import { getSizeOfTransaction } from "../transaction" ;
69
68
70
69
const SOL_PADDING_FOR_INTEREST = "1000000" ;
71
70
@@ -80,6 +79,8 @@ type ActionConfigType = {
80
79
token2022Mint ?: string ;
81
80
repayToken2022Mint ?: string ;
82
81
debug ?: boolean ;
82
+ computeUnitPriceMicroLamports ?: number ;
83
+ computeUnitLimit ?: number ;
83
84
} ;
84
85
85
86
type SupportType =
@@ -219,6 +220,10 @@ export class SolendActionCore {
219
220
220
221
environment : EnvironmentType ;
221
222
223
+ computeUnitPriceMicroLamports ?: number ;
224
+
225
+ computeUnitLimit ?: number ;
226
+
222
227
private constructor (
223
228
programId : PublicKey ,
224
229
connection : Connection ,
@@ -250,6 +255,8 @@ export class SolendActionCore {
250
255
token2022Mint ?: PublicKey ;
251
256
wrappedAta ?: PublicKey ;
252
257
debug ?: boolean ;
258
+ computeUnitPriceMicroLamports ?: number ;
259
+ computeUnitLimit ?: number ;
253
260
}
254
261
) {
255
262
this . programId = programId ;
@@ -282,6 +289,8 @@ export class SolendActionCore {
282
289
// temporarily default to true
283
290
this . debug = config ?. debug ?? true ;
284
291
this . environment = config ?. environment ?? "production" ;
292
+ this . computeUnitPriceMicroLamports = config ?. computeUnitPriceMicroLamports ;
293
+ this . computeUnitLimit = config ?. computeUnitLimit ;
285
294
}
286
295
287
296
static async initialize (
@@ -391,7 +400,6 @@ export class SolendActionCore {
391
400
amount ,
392
401
depositReserves ,
393
402
borrowReserves ,
394
-
395
403
{
396
404
environment : config . environment ,
397
405
hostAta : config . hostAta ,
@@ -428,6 +436,9 @@ export class SolendActionCore {
428
436
TOKEN_2022_PROGRAM_ID
429
437
)
430
438
: undefined ,
439
+ debug : config . debug ,
440
+ computeUnitPriceMicroLamports : config . computeUnitPriceMicroLamports ,
441
+ computeUnitLimit : config . computeUnitLimit ,
431
442
}
432
443
) ;
433
444
}
@@ -675,7 +686,7 @@ export class SolendActionCore {
675
686
return new VersionedTransaction (
676
687
new TransactionMessage ( {
677
688
payerKey : this . publicKey ,
678
- recentBlockhash : ( await this . connection . getRecentBlockhash ( ) ) . blockhash ,
689
+ recentBlockhash : ( await this . connection . getLatestBlockhash ( ) ) . blockhash ,
679
690
instructions : [
680
691
...this . preTxnIxs ,
681
692
...this . setupIxs ,
@@ -702,17 +713,17 @@ export class SolendActionCore {
702
713
if ( this . preTxnIxs . length ) {
703
714
txns . preLendingTxn = new Transaction ( {
704
715
feePayer : this . publicKey ,
705
- recentBlockhash : ( await this . connection . getRecentBlockhash ( ) ) . blockhash ,
716
+ recentBlockhash : ( await this . connection . getLatestBlockhash ( ) ) . blockhash ,
706
717
} ) . add ( ...this . preTxnIxs ) ;
707
718
}
708
719
txns . lendingTxn = new Transaction ( {
709
720
feePayer : this . publicKey ,
710
- recentBlockhash : ( await this . connection . getRecentBlockhash ( ) ) . blockhash ,
721
+ recentBlockhash : ( await this . connection . getLatestBlockhash ( ) ) . blockhash ,
711
722
} ) . add ( ...this . setupIxs , ...this . lendingIxs , ...this . cleanupIxs ) ;
712
723
if ( this . postTxnIxs . length ) {
713
724
txns . postLendingTxn = new Transaction ( {
714
725
feePayer : this . publicKey ,
715
- recentBlockhash : ( await this . connection . getRecentBlockhash ( ) ) . blockhash ,
726
+ recentBlockhash : ( await this . connection . getLatestBlockhash ( ) ) . blockhash ,
716
727
} ) . add ( ...this . postTxnIxs ) ;
717
728
}
718
729
return txns ;
@@ -754,6 +765,14 @@ export class SolendActionCore {
754
765
pullPriceTxns : null ,
755
766
} ;
756
767
768
+ const priorityFeeIx = ComputeBudgetProgram . setComputeUnitPrice ( {
769
+ microLamports : this . computeUnitPriceMicroLamports ?? 500_000 ,
770
+ } ) ;
771
+
772
+ const modifyComputeUnits = ComputeBudgetProgram . setComputeUnitLimit ( {
773
+ units : this . computeUnitLimit ?? 1_000_000 ,
774
+ } ) ;
775
+
757
776
if ( this . pullPriceTxns . length ) {
758
777
txns . pullPriceTxns = this . pullPriceTxns ;
759
778
}
@@ -763,7 +782,7 @@ export class SolendActionCore {
763
782
new TransactionMessage ( {
764
783
payerKey : this . publicKey ,
765
784
recentBlockhash : blockhash . blockhash ,
766
- instructions : this . preTxnIxs ,
785
+ instructions : [ priorityFeeIx , modifyComputeUnits , ... this . preTxnIxs ] ,
767
786
} ) . compileToV0Message ( )
768
787
) ;
769
788
}
@@ -780,13 +799,6 @@ export class SolendActionCore {
780
799
instructions . push ( tip ) ;
781
800
}
782
801
783
- const priorityFeeIx = ComputeBudgetProgram . setComputeUnitPrice ( {
784
- microLamports : 1_000_000 ,
785
- } ) ;
786
- const modifyComputeUnits = ComputeBudgetProgram . setComputeUnitLimit ( {
787
- units : 1_000_000 ,
788
- } ) ;
789
-
790
802
txns . lendingTxn = new VersionedTransaction (
791
803
new TransactionMessage ( {
792
804
payerKey : this . publicKey ,
@@ -802,7 +814,7 @@ export class SolendActionCore {
802
814
new TransactionMessage ( {
803
815
payerKey : this . publicKey ,
804
816
recentBlockhash : blockhash . blockhash ,
805
- instructions : this . postTxnIxs ,
817
+ instructions : [ priorityFeeIx , modifyComputeUnits , ... this . postTxnIxs ] ,
806
818
} ) . compileToV0Message ( )
807
819
) ;
808
820
}
@@ -1167,6 +1179,13 @@ export class SolendActionCore {
1167
1179
}
1168
1180
1169
1181
private async buildPullPriceTxns ( oracleKeys : Array < string > ) {
1182
+ const priorityFeeIx = ComputeBudgetProgram . setComputeUnitPrice ( {
1183
+ microLamports : this . computeUnitPriceMicroLamports ?? 1_000_000 ,
1184
+ } ) ;
1185
+ const modifyComputeUnits = ComputeBudgetProgram . setComputeUnitLimit ( {
1186
+ units : 1_000_000 ,
1187
+ } ) ;
1188
+
1170
1189
const oracleAccounts = await this . connection . getMultipleAccountsInfo (
1171
1190
oracleKeys . map ( ( o ) => new PublicKey ( o ) ) ,
1172
1191
"processed"
@@ -1230,15 +1249,6 @@ export class SolendActionCore {
1230
1249
accountLookups
1231
1250
) ;
1232
1251
1233
- const priorityFeeIx = ComputeBudgetProgram . setComputeUnitPrice ( {
1234
- microLamports : 1_000_000 ,
1235
- } ) ;
1236
- const modifyComputeUnits = ComputeBudgetProgram . setComputeUnitLimit (
1237
- {
1238
- units : 1_000_000 ,
1239
- }
1240
- ) ;
1241
-
1242
1252
const instructions = [ priorityFeeIx , modifyComputeUnits , ix ] ;
1243
1253
1244
1254
if ( this . debug )
@@ -1326,9 +1336,13 @@ export class SolendActionCore {
1326
1336
0 // shardId of 0
1327
1337
) ;
1328
1338
1339
+ transactionBuilder . addInstructions ( [
1340
+ { instruction : priorityFeeIx , signers : [ ] } ,
1341
+ { instruction : modifyComputeUnits , signers : [ ] } ,
1342
+ ] ) ;
1343
+
1329
1344
const transactionsWithSigners =
1330
1345
await transactionBuilder . buildVersionedTransactions ( {
1331
- tightComputeBudget : true ,
1332
1346
jitoTipLamports : this . pullPriceTxns . length
1333
1347
? undefined
1334
1348
: this . jitoTipAmount ,
@@ -1337,6 +1351,7 @@ export class SolendActionCore {
1337
1351
for ( const transaction of transactionsWithSigners ) {
1338
1352
const signers = transaction . signers ;
1339
1353
const tx = transaction . tx ;
1354
+
1340
1355
if ( signers ) {
1341
1356
tx . sign ( signers ) ;
1342
1357
}
@@ -1363,8 +1378,6 @@ export class SolendActionCore {
1363
1378
] )
1364
1379
) ;
1365
1380
1366
- console . log ( allReserveAddresses ) ;
1367
-
1368
1381
await this . buildPullPriceTxns ( [
1369
1382
...allReserveAddresses . map ( ( address ) => reserveMap [ address ] . pythOracle ) ,
1370
1383
...allReserveAddresses . map (
0 commit comments