@@ -69,17 +69,21 @@ import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
69
69
70
70
export type SaveWallet = {
71
71
publicKey : PublicKey ;
72
- name : string ;
73
- signTransaction < T extends Transaction | VersionedTransaction > (
74
- tx : T
75
- ) : Promise < T > ;
76
- signAllTransactions < T extends Transaction | VersionedTransaction > (
77
- txs : T [ ]
78
- ) : Promise < T [ ] > ;
79
72
} ;
80
73
81
74
const SOL_PADDING_FOR_INTEREST = "1000000" ;
82
75
76
+ export type InputReserveType = {
77
+ address : string ;
78
+ liquidityAddress : string ;
79
+ cTokenMint : string ;
80
+ cTokenLiquidityAddress : string ;
81
+ pythOracle : string ;
82
+ switchboardOracle : string ;
83
+ mintAddress : string ;
84
+ liquidityFeeReceiverAddress : string ;
85
+ } ;
86
+
83
87
type ActionConfigType = {
84
88
environment ?: EnvironmentType ;
85
89
customObligationAddress ?: PublicKey ;
@@ -158,12 +162,21 @@ export type ActionType =
158
162
| "forgive"
159
163
| "liquidate" ;
160
164
165
+ type InputPoolReserveType = {
166
+ address : string ;
167
+ pythOracle : string ;
168
+ switchboardOracle : string ;
169
+ mintAddress : string ;
170
+ liquidityFeeReceiverAddress : string ;
171
+ extraOracle ?: string ;
172
+ } ;
173
+
161
174
type InputPoolType = {
162
175
address : string ;
163
176
owner : string ;
164
177
name : string | null ;
165
178
authorityAddress : string ;
166
- reserves : Array < ReserveType > ;
179
+ reserves : Array < InputPoolReserveType > ;
167
180
} ;
168
181
169
182
export type InstructionWithSigners = {
@@ -188,7 +201,7 @@ export class SolendActionCore {
188
201
189
202
connection : Connection ;
190
203
191
- reserve : ReserveType ;
204
+ reserve : InputReserveType ;
192
205
193
206
pool : InputPoolType ;
194
207
@@ -263,7 +276,7 @@ export class SolendActionCore {
263
276
private constructor (
264
277
programId : PublicKey ,
265
278
connection : Connection ,
266
- reserve : ReserveType ,
279
+ reserve : InputReserveType ,
267
280
pool : InputPoolType ,
268
281
wallet : SaveWallet ,
269
282
obligationAddress : PublicKey ,
@@ -333,7 +346,7 @@ export class SolendActionCore {
333
346
334
347
static async initialize (
335
348
pool : InputPoolType ,
336
- reserve : ReserveType ,
349
+ reserve : InputReserveType ,
337
350
action : ActionType ,
338
351
amount : BN ,
339
352
wallet : SaveWallet ,
@@ -490,7 +503,7 @@ export class SolendActionCore {
490
503
491
504
static async buildForgiveTxns (
492
505
pool : InputPoolType ,
493
- reserve : ReserveType ,
506
+ reserve : InputReserveType ,
494
507
connection : Connection ,
495
508
amount : string ,
496
509
wallet : SaveWallet ,
@@ -518,7 +531,7 @@ export class SolendActionCore {
518
531
519
532
static async buildDepositTxns (
520
533
pool : InputPoolType ,
521
- reserve : ReserveType ,
534
+ reserve : InputReserveType ,
522
535
connection : Connection ,
523
536
amount : string ,
524
537
wallet : SaveWallet ,
@@ -542,7 +555,7 @@ export class SolendActionCore {
542
555
543
556
static async buildBorrowTxns (
544
557
pool : InputPoolType ,
545
- reserve : ReserveType ,
558
+ reserve : InputReserveType ,
546
559
connection : Connection ,
547
560
amount : string ,
548
561
wallet : SaveWallet ,
@@ -565,7 +578,7 @@ export class SolendActionCore {
565
578
}
566
579
static async buildDepositReserveLiquidityTxns (
567
580
pool : InputPoolType ,
568
- reserve : ReserveType ,
581
+ reserve : InputReserveType ,
569
582
connection : Connection ,
570
583
amount : string ,
571
584
wallet : SaveWallet ,
@@ -587,7 +600,7 @@ export class SolendActionCore {
587
600
588
601
static async buildRedeemReserveCollateralTxns (
589
602
pool : InputPoolType ,
590
- reserve : ReserveType ,
603
+ reserve : InputReserveType ,
591
604
connection : Connection ,
592
605
amount : string ,
593
606
wallet : SaveWallet ,
@@ -609,7 +622,7 @@ export class SolendActionCore {
609
622
610
623
static async buildDepositObligationCollateralTxns (
611
624
pool : InputPoolType ,
612
- reserve : ReserveType ,
625
+ reserve : InputReserveType ,
613
626
connection : Connection ,
614
627
amount : string ,
615
628
wallet : SaveWallet ,
@@ -631,7 +644,7 @@ export class SolendActionCore {
631
644
632
645
static async buildWithdrawCollateralTxns (
633
646
pool : InputPoolType ,
634
- reserve : ReserveType ,
647
+ reserve : InputReserveType ,
635
648
connection : Connection ,
636
649
amount : string ,
637
650
wallet : SaveWallet ,
@@ -655,7 +668,7 @@ export class SolendActionCore {
655
668
656
669
static async buildWithdrawTxns (
657
670
pool : InputPoolType ,
658
- reserve : ReserveType ,
671
+ reserve : InputReserveType ,
659
672
connection : Connection ,
660
673
amount : string ,
661
674
wallet : SaveWallet ,
@@ -679,7 +692,7 @@ export class SolendActionCore {
679
692
680
693
static async buildRepayTxns (
681
694
pool : InputPoolType ,
682
- reserve : ReserveType ,
695
+ reserve : InputReserveType ,
683
696
connection : Connection ,
684
697
amount : string ,
685
698
wallet : SaveWallet ,
@@ -703,7 +716,7 @@ export class SolendActionCore {
703
716
704
717
static async buildLiquidateTxns (
705
718
pool : InputPoolType ,
706
- withdrawReserve : ReserveType ,
719
+ withdrawReserve : InputReserveType ,
707
720
connection : Connection ,
708
721
amount : string ,
709
722
wallet : SaveWallet ,
@@ -1106,7 +1119,7 @@ export class SolendActionCore {
1106
1119
) ;
1107
1120
}
1108
1121
1109
- async addLiquidateIx ( repayReserve : ReserveType ) {
1122
+ async addLiquidateIx ( repayReserve : InputReserveType ) {
1110
1123
if ( this . debug ) console . log ( "adding liquidate ix to lending txn" ) ;
1111
1124
if (
1112
1125
! this . repayInfo ?. userRepayCollateralAccountAddress ||
@@ -1128,7 +1141,7 @@ export class SolendActionCore {
1128
1141
new PublicKey ( this . reserve . cTokenMint ) ,
1129
1142
new PublicKey ( this . reserve . cTokenLiquidityAddress ) ,
1130
1143
new PublicKey ( this . reserve . liquidityAddress ) ,
1131
- new PublicKey ( this . reserve . feeReceiverAddress ) ,
1144
+ new PublicKey ( this . reserve . liquidityFeeReceiverAddress ) ,
1132
1145
this . obligationAddress ,
1133
1146
new PublicKey ( this . pool . address ) ,
1134
1147
new PublicKey ( this . pool . authorityAddress ) ,
@@ -1286,7 +1299,11 @@ export class SolendActionCore {
1286
1299
"processed"
1287
1300
) ;
1288
1301
1289
- const provider = new AnchorProvider ( this . connection , this . wallet , { } ) ;
1302
+ const provider = new AnchorProvider ( this . connection , {
1303
+ publicKey : this . wallet . publicKey ,
1304
+ signTransaction : < T extends Transaction | VersionedTransaction > ( tx : T ) => Promise . resolve ( tx ) ,
1305
+ signAllTransactions : < T extends Transaction | VersionedTransaction > ( txs : T [ ] ) => Promise . resolve ( txs as T [ ] ) ,
1306
+ } , { } ) ;
1290
1307
const idl = ( await Program . fetchIdl ( ON_DEMAND_MAINNET_PID , provider ) ) ! ;
1291
1308
1292
1309
if ( this . environment === "production" || this . environment === "beta" ) {
@@ -1477,7 +1494,7 @@ export class SolendActionCore {
1477
1494
const reserveMap = this . pool . reserves . reduce ( ( acc , reserve ) => {
1478
1495
acc [ reserve . address ] = reserve ;
1479
1496
return acc ;
1480
- } , { } as Record < string , ReserveType > ) ;
1497
+ } , { } as Record < string , InputPoolReserveType > ) ;
1481
1498
1482
1499
const allReserveAddresses = Array . from (
1483
1500
new Set ( singleReserve ? [ this . reserve . address ] : [
0 commit comments