@@ -59,12 +59,23 @@ import {
59
59
PullFeed ,
60
60
ON_DEMAND_MAINNET_PID ,
61
61
} from "@switchboard-xyz/on-demand" ;
62
- import { Wallet } from "@coral-xyz/anchor" ;
63
62
import {
64
63
createDepositAndMintWrapperTokensInstruction ,
65
64
createWithdrawAndBurnWrapperTokensInstruction ,
66
65
} from "@solendprotocol/token2022-wrapper-sdk" ;
67
66
import { ReserveType } from "./utils" ;
67
+ import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet" ;
68
+
69
+ export type SaveWallet = {
70
+ publicKey : PublicKey ;
71
+ name : string ;
72
+ signTransaction < T extends Transaction | VersionedTransaction > (
73
+ tx : T
74
+ ) : Promise < T > ;
75
+ signAllTransactions < T extends Transaction | VersionedTransaction > (
76
+ txs : T [ ]
77
+ ) : Promise < T [ ] > ;
78
+ } ;
68
79
69
80
const SOL_PADDING_FOR_INTEREST = "1000000" ;
70
81
@@ -153,6 +164,9 @@ type InputPoolType = {
153
164
reserves : Array < ReserveType > ;
154
165
} ;
155
166
167
+ export const CROSSBAR_URL1 = "https://crossbar.save.finance" ;
168
+ export const CROSSBAR_URL2 = "https://crossbar.switchboard.xyz" ;
169
+
156
170
export class SolendActionCore {
157
171
programId : PublicKey ;
158
172
@@ -201,7 +215,7 @@ export class SolendActionCore {
201
215
202
216
jitoTipAmount : number ;
203
217
204
- wallet : Wallet ;
218
+ wallet : SaveWallet ;
205
219
206
220
debug : boolean ;
207
221
@@ -224,12 +238,14 @@ export class SolendActionCore {
224
238
225
239
computeUnitLimit ?: number ;
226
240
241
+ errors : Array < any > = [ ] ;
242
+
227
243
private constructor (
228
244
programId : PublicKey ,
229
245
connection : Connection ,
230
246
reserve : ReserveType ,
231
247
pool : InputPoolType ,
232
- wallet : Wallet ,
248
+ wallet : SaveWallet ,
233
249
obligationAddress : PublicKey ,
234
250
obligationAccountInfo : Obligation | null ,
235
251
userTokenAccountAddress : PublicKey ,
@@ -298,7 +314,7 @@ export class SolendActionCore {
298
314
reserve : ReserveType ,
299
315
action : ActionType ,
300
316
amount : BN ,
301
- wallet : Wallet ,
317
+ wallet : SaveWallet ,
302
318
connection : Connection ,
303
319
config : ActionConfigType
304
320
) {
@@ -348,7 +364,10 @@ export class SolendActionCore {
348
364
] )
349
365
) . length ;
350
366
351
- if ( distinctReserveCount > POSITION_LIMIT ) {
367
+ if (
368
+ distinctReserveCount > POSITION_LIMIT &&
369
+ [ "deposit" , "borrow" ] . includes ( action )
370
+ ) {
352
371
throw Error (
353
372
`Obligation already has max number of positions: ${ POSITION_LIMIT } `
354
373
) ;
@@ -448,7 +467,7 @@ export class SolendActionCore {
448
467
reserve : ReserveType ,
449
468
connection : Connection ,
450
469
amount : string ,
451
- wallet : Wallet ,
470
+ wallet : SaveWallet ,
452
471
obligationAddress : PublicKey ,
453
472
config : ActionConfigType
454
473
) {
@@ -476,7 +495,7 @@ export class SolendActionCore {
476
495
reserve : ReserveType ,
477
496
connection : Connection ,
478
497
amount : string ,
479
- wallet : Wallet ,
498
+ wallet : SaveWallet ,
480
499
config : ActionConfigType
481
500
) {
482
501
const axn = await SolendActionCore . initialize (
@@ -500,7 +519,7 @@ export class SolendActionCore {
500
519
reserve : ReserveType ,
501
520
connection : Connection ,
502
521
amount : string ,
503
- wallet : Wallet ,
522
+ wallet : SaveWallet ,
504
523
config : ActionConfigType
505
524
) {
506
525
const axn = await SolendActionCore . initialize (
@@ -523,7 +542,7 @@ export class SolendActionCore {
523
542
reserve : ReserveType ,
524
543
connection : Connection ,
525
544
amount : string ,
526
- wallet : Wallet ,
545
+ wallet : SaveWallet ,
527
546
config : ActionConfigType
528
547
) {
529
548
const axn = await SolendActionCore . initialize (
@@ -545,7 +564,7 @@ export class SolendActionCore {
545
564
reserve : ReserveType ,
546
565
connection : Connection ,
547
566
amount : string ,
548
- wallet : Wallet ,
567
+ wallet : SaveWallet ,
549
568
config : ActionConfigType
550
569
) {
551
570
const axn = await SolendActionCore . initialize (
@@ -567,7 +586,7 @@ export class SolendActionCore {
567
586
reserve : ReserveType ,
568
587
connection : Connection ,
569
588
amount : string ,
570
- wallet : Wallet ,
589
+ wallet : SaveWallet ,
571
590
config : ActionConfigType
572
591
) {
573
592
const axn = await SolendActionCore . initialize (
@@ -589,7 +608,7 @@ export class SolendActionCore {
589
608
reserve : ReserveType ,
590
609
connection : Connection ,
591
610
amount : string ,
592
- wallet : Wallet ,
611
+ wallet : SaveWallet ,
593
612
config : ActionConfigType
594
613
) {
595
614
const axn = await SolendActionCore . initialize (
@@ -613,7 +632,7 @@ export class SolendActionCore {
613
632
reserve : ReserveType ,
614
633
connection : Connection ,
615
634
amount : string ,
616
- wallet : Wallet ,
635
+ wallet : SaveWallet ,
617
636
config : ActionConfigType
618
637
) {
619
638
const axn = await SolendActionCore . initialize (
@@ -637,7 +656,7 @@ export class SolendActionCore {
637
656
reserve : ReserveType ,
638
657
connection : Connection ,
639
658
amount : string ,
640
- wallet : Wallet ,
659
+ wallet : SaveWallet ,
641
660
config : ActionConfigType
642
661
) {
643
662
const axn = await SolendActionCore . initialize (
@@ -661,7 +680,7 @@ export class SolendActionCore {
661
680
withdrawReserve : ReserveType ,
662
681
connection : Connection ,
663
682
amount : string ,
664
- wallet : Wallet ,
683
+ wallet : SaveWallet ,
665
684
config : ActionConfigType
666
685
) {
667
686
const axn = await SolendActionCore . initialize (
@@ -1220,9 +1239,7 @@ export class SolendActionCore {
1220
1239
1
1221
1240
) ;
1222
1241
1223
- const crossbar = new CrossbarClient (
1224
- "https://crossbar.switchboard.xyz/"
1225
- ) ;
1242
+ const crossbar = new CrossbarClient ( "https://crossbar.save.finance" ) ;
1226
1243
1227
1244
const res = sbPulledOracles . reduce ( ( acc , _curr , i ) => {
1228
1245
if ( ! ( i % 3 ) ) {
@@ -1282,7 +1299,7 @@ export class SolendActionCore {
1282
1299
) ;
1283
1300
const pythSolanaReceiver = new PythSolanaReceiver ( {
1284
1301
connection : this . connection ,
1285
- wallet : this . wallet ,
1302
+ wallet : this . wallet as any as NodeWallet ,
1286
1303
} ) ;
1287
1304
const transactionBuilder = pythSolanaReceiver . newTransactionBuilder ( {
1288
1305
closeUpdateAccounts : true ,
0 commit comments