Skip to content

Commit

Permalink
fix set obligation closeable
Browse files Browse the repository at this point in the history
  • Loading branch information
0xodia committed Feb 8, 2024
1 parent b6387fd commit 5762dfa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
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.8.10-beta",
"version": "0.8.11-beta",
"private": true,
"main": "src/index.ts",
"module": "src/index.ts",
Expand Down
36 changes: 10 additions & 26 deletions solend-sdk/src/instructions/setObligationCloseabilityStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,48 +10,32 @@ import { LendingInstruction } from "./instruction";
const BufferLayout = require("buffer-layout");

export const setObligationCloseabilityStatus = (
obligation: PublicKey,
lendingMarket: PublicKey,
lendingMarketOwner: PublicKey,
reserve: PublicKey,
riskAuthority: PublicKey,
closeable: boolean,
lendingProgramId: PublicKey,
marketName: string,
marketDescription: string,
marketImageUrl: string
): TransactionInstruction => {
const dataLayout = BufferLayout.struct([
BufferLayout.u8("instruction"),
BufferLayout.blob(50, "marketName"),
BufferLayout.blob(250, "marketDescription"),
BufferLayout.blob(250, "marketImageUrl"),
BufferLayout.blob(200, "padding"),
BufferLayout.u8("bumpSeed"),
BufferLayout.u8("closeable"),
]);

const [lendingMarketMetadata, _] = findProgramAddressSync(
[
lendingMarket.toBytes(),
Buffer.from(anchor.utils.bytes.utf8.encode("MetaData")),
],

lendingProgramId
);

const data = Buffer.alloc(dataLayout.span);
dataLayout.encode(
{
instruction: LendingInstruction.UpdateMetadata,
marketName,
marketDescription,
marketImageUrl,
padding: Buffer.alloc(200),
instruction: LendingInstruction.SetObligationCloseabilityStatus,
closeable: closeable ? 1 : 0,
},
data
);

const keys = [
{ pubkey: obligation, isSigner: false, isWritable: true },
{ pubkey: lendingMarket, isSigner: false, isWritable: false },
{ pubkey: lendingMarketOwner, isSigner: true, isWritable: false },
{ pubkey: lendingMarketMetadata, isSigner: false, isWritable: true },
{ pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
{ pubkey: reserve, isSigner: false, isWritable: false },
{ pubkey: riskAuthority, isSigner: true, isWritable: true },
];

return new TransactionInstruction({
Expand Down

0 comments on commit 5762dfa

Please sign in to comment.