Skip to content

Commit

Permalink
create host fee account if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
0xodia committed Nov 22, 2024
1 parent dee4191 commit f26ba87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion solend-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solendprotocol/solend-sdk",
"version": "0.13.29",
"version": "0.13.30",
"private": true,
"main": "src/index.ts",
"module": "src/index.ts",
Expand Down
16 changes: 16 additions & 0 deletions solend-sdk/src/core/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ type ActionConfigType = {
environment?: EnvironmentType;
customObligationAddress?: PublicKey;
hostAta?: PublicKey;
hostPublicKey?: PublicKey;
customObligationSeed?: string;
lookupTableAddress?: PublicKey;
tipAmount?: number;
Expand Down Expand Up @@ -194,6 +195,8 @@ export class SolendActionCore {

hostAta?: PublicKey;

hostPublicKey?: PublicKey;

// TODO: potentially don't need to keep signers
pullPriceTxns: Array<VersionedTransaction>;

Expand Down Expand Up @@ -258,6 +261,7 @@ export class SolendActionCore {
config?: {
environment?: EnvironmentType;
hostAta?: PublicKey;
hostPublicKey?: PublicKey;
lookupTableAccount?: AddressLookupTableAccount;
tipAmount?: number;
repayInfo?: {
Expand All @@ -281,6 +285,7 @@ export class SolendActionCore {
this.amount = new BN(amount);
this.positions = positions;
this.hostAta = config?.hostAta;
this.hostPublicKey = config?.hostPublicKey;
this.obligationAccountInfo = obligationAccountInfo;
this.pool = pool;
this.seed = seed;
Expand Down Expand Up @@ -422,6 +427,7 @@ export class SolendActionCore {
{
environment: config.environment,
hostAta: config.hostAta,
hostPublicKey: config.hostPublicKey,
lookupTableAccount: lookupTableAccount ?? undefined,
tipAmount: config.tipAmount,
repayInfo: config.repayReserve
Expand Down Expand Up @@ -972,6 +978,16 @@ export class SolendActionCore {

addBorrowIx() {
if (this.debug) console.log("adding borrow ix to lending txn");
if (this.hostAta && this.hostPublicKey) {
this.preTxnIxs.push(
createAssociatedTokenAccountIdempotentInstruction(
this.publicKey,
this.hostAta,
this.hostPublicKey,
new PublicKey(this.reserve.mintAddress)
)
);
}
this.lendingIxs.push(
borrowObligationLiquidityInstruction(
this.amount,
Expand Down

0 comments on commit f26ba87

Please sign in to comment.