Skip to content

Commit 9be5470

Browse files
committed
update input types
1 parent 48c5213 commit 9be5470

File tree

2 files changed

+43
-26
lines changed

2 files changed

+43
-26
lines changed

solend-sdk/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@solendprotocol/solend-sdk",
3-
"version": "0.13.39",
3+
"version": "0.13.42",
44
"private": true,
55
"main": "src/index.ts",
66
"module": "src/index.ts",

solend-sdk/src/core/actions.ts

+42-25
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,21 @@ import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
6969

7070
export type SaveWallet = {
7171
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[]>;
7972
};
8073

8174
const SOL_PADDING_FOR_INTEREST = "1000000";
8275

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+
8387
type ActionConfigType = {
8488
environment?: EnvironmentType;
8589
customObligationAddress?: PublicKey;
@@ -158,12 +162,21 @@ export type ActionType =
158162
| "forgive"
159163
| "liquidate";
160164

165+
type InputPoolReserveType = {
166+
address: string;
167+
pythOracle: string;
168+
switchboardOracle: string;
169+
mintAddress: string;
170+
liquidityFeeReceiverAddress: string;
171+
extraOracle?: string;
172+
};
173+
161174
type InputPoolType = {
162175
address: string;
163176
owner: string;
164177
name: string | null;
165178
authorityAddress: string;
166-
reserves: Array<ReserveType>;
179+
reserves: Array<InputPoolReserveType>;
167180
};
168181

169182
export type InstructionWithSigners = {
@@ -188,7 +201,7 @@ export class SolendActionCore {
188201

189202
connection: Connection;
190203

191-
reserve: ReserveType;
204+
reserve: InputReserveType;
192205

193206
pool: InputPoolType;
194207

@@ -263,7 +276,7 @@ export class SolendActionCore {
263276
private constructor(
264277
programId: PublicKey,
265278
connection: Connection,
266-
reserve: ReserveType,
279+
reserve: InputReserveType,
267280
pool: InputPoolType,
268281
wallet: SaveWallet,
269282
obligationAddress: PublicKey,
@@ -333,7 +346,7 @@ export class SolendActionCore {
333346

334347
static async initialize(
335348
pool: InputPoolType,
336-
reserve: ReserveType,
349+
reserve: InputReserveType,
337350
action: ActionType,
338351
amount: BN,
339352
wallet: SaveWallet,
@@ -490,7 +503,7 @@ export class SolendActionCore {
490503

491504
static async buildForgiveTxns(
492505
pool: InputPoolType,
493-
reserve: ReserveType,
506+
reserve: InputReserveType,
494507
connection: Connection,
495508
amount: string,
496509
wallet: SaveWallet,
@@ -518,7 +531,7 @@ export class SolendActionCore {
518531

519532
static async buildDepositTxns(
520533
pool: InputPoolType,
521-
reserve: ReserveType,
534+
reserve: InputReserveType,
522535
connection: Connection,
523536
amount: string,
524537
wallet: SaveWallet,
@@ -542,7 +555,7 @@ export class SolendActionCore {
542555

543556
static async buildBorrowTxns(
544557
pool: InputPoolType,
545-
reserve: ReserveType,
558+
reserve: InputReserveType,
546559
connection: Connection,
547560
amount: string,
548561
wallet: SaveWallet,
@@ -565,7 +578,7 @@ export class SolendActionCore {
565578
}
566579
static async buildDepositReserveLiquidityTxns(
567580
pool: InputPoolType,
568-
reserve: ReserveType,
581+
reserve: InputReserveType,
569582
connection: Connection,
570583
amount: string,
571584
wallet: SaveWallet,
@@ -587,7 +600,7 @@ export class SolendActionCore {
587600

588601
static async buildRedeemReserveCollateralTxns(
589602
pool: InputPoolType,
590-
reserve: ReserveType,
603+
reserve: InputReserveType,
591604
connection: Connection,
592605
amount: string,
593606
wallet: SaveWallet,
@@ -609,7 +622,7 @@ export class SolendActionCore {
609622

610623
static async buildDepositObligationCollateralTxns(
611624
pool: InputPoolType,
612-
reserve: ReserveType,
625+
reserve: InputReserveType,
613626
connection: Connection,
614627
amount: string,
615628
wallet: SaveWallet,
@@ -631,7 +644,7 @@ export class SolendActionCore {
631644

632645
static async buildWithdrawCollateralTxns(
633646
pool: InputPoolType,
634-
reserve: ReserveType,
647+
reserve: InputReserveType,
635648
connection: Connection,
636649
amount: string,
637650
wallet: SaveWallet,
@@ -655,7 +668,7 @@ export class SolendActionCore {
655668

656669
static async buildWithdrawTxns(
657670
pool: InputPoolType,
658-
reserve: ReserveType,
671+
reserve: InputReserveType,
659672
connection: Connection,
660673
amount: string,
661674
wallet: SaveWallet,
@@ -679,7 +692,7 @@ export class SolendActionCore {
679692

680693
static async buildRepayTxns(
681694
pool: InputPoolType,
682-
reserve: ReserveType,
695+
reserve: InputReserveType,
683696
connection: Connection,
684697
amount: string,
685698
wallet: SaveWallet,
@@ -703,7 +716,7 @@ export class SolendActionCore {
703716

704717
static async buildLiquidateTxns(
705718
pool: InputPoolType,
706-
withdrawReserve: ReserveType,
719+
withdrawReserve: InputReserveType,
707720
connection: Connection,
708721
amount: string,
709722
wallet: SaveWallet,
@@ -1106,7 +1119,7 @@ export class SolendActionCore {
11061119
);
11071120
}
11081121

1109-
async addLiquidateIx(repayReserve: ReserveType) {
1122+
async addLiquidateIx(repayReserve: InputReserveType) {
11101123
if (this.debug) console.log("adding liquidate ix to lending txn");
11111124
if (
11121125
!this.repayInfo?.userRepayCollateralAccountAddress ||
@@ -1128,7 +1141,7 @@ export class SolendActionCore {
11281141
new PublicKey(this.reserve.cTokenMint),
11291142
new PublicKey(this.reserve.cTokenLiquidityAddress),
11301143
new PublicKey(this.reserve.liquidityAddress),
1131-
new PublicKey(this.reserve.feeReceiverAddress),
1144+
new PublicKey(this.reserve.liquidityFeeReceiverAddress),
11321145
this.obligationAddress,
11331146
new PublicKey(this.pool.address),
11341147
new PublicKey(this.pool.authorityAddress),
@@ -1286,7 +1299,11 @@ export class SolendActionCore {
12861299
"processed"
12871300
);
12881301

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+
}, {});
12901307
const idl = (await Program.fetchIdl(ON_DEMAND_MAINNET_PID, provider))!;
12911308

12921309
if (this.environment === "production" || this.environment === "beta") {
@@ -1477,7 +1494,7 @@ export class SolendActionCore {
14771494
const reserveMap = this.pool.reserves.reduce((acc, reserve) => {
14781495
acc[reserve.address] = reserve;
14791496
return acc;
1480-
}, {} as Record<string, ReserveType>);
1497+
}, {} as Record<string, InputPoolReserveType>);
14811498

14821499
const allReserveAddresses = Array.from(
14831500
new Set(singleReserve ? [this.reserve.address] : [

0 commit comments

Comments
 (0)