mirror of https://github.com/certusone/oyster.git
fix: obligation account
This commit is contained in:
parent
c9a87b3771
commit
a87a8cfcdd
|
@ -5,8 +5,8 @@ import {
|
|||
SystemProgram,
|
||||
TransactionInstruction,
|
||||
} from "@solana/web3.js";
|
||||
import { TOKEN_PROGRAM_ID, WRAPPED_SOL_MINT } from "../constants/ids";
|
||||
import { TokenAccount } from "../models";
|
||||
import { LENDING_PROGRAM_ID, TOKEN_PROGRAM_ID, WRAPPED_SOL_MINT } from "../constants/ids";
|
||||
import { LendingObligationLayout, TokenAccount } from "../models";
|
||||
import { cache, TokenAccountParser } from "./../contexts/accounts";
|
||||
|
||||
export function ensureSplAccount(
|
||||
|
@ -75,6 +75,28 @@ export function createTempMemoryAccount(
|
|||
return account.publicKey;
|
||||
}
|
||||
|
||||
export function createUninitializedObligation(
|
||||
instructions: TransactionInstruction[],
|
||||
payer: PublicKey,
|
||||
amount: number,
|
||||
signers: Account[]
|
||||
) {
|
||||
const account = new Account();
|
||||
instructions.push(
|
||||
SystemProgram.createAccount({
|
||||
fromPubkey: payer,
|
||||
newAccountPubkey: account.publicKey,
|
||||
lamports: amount,
|
||||
space: LendingObligationLayout.span,
|
||||
programId: LENDING_PROGRAM_ID,
|
||||
})
|
||||
);
|
||||
|
||||
signers.push(account);
|
||||
|
||||
return account.publicKey;
|
||||
}
|
||||
|
||||
export function createUninitializedMint(
|
||||
instructions: TransactionInstruction[],
|
||||
payer: PublicKey,
|
||||
|
|
|
@ -13,6 +13,7 @@ import {
|
|||
createTempMemoryAccount,
|
||||
createUninitializedAccount,
|
||||
createUninitializedMint,
|
||||
createUninitializedObligation,
|
||||
ensureSplAccount,
|
||||
findOrCreateAccountByMint,
|
||||
} from "./account";
|
||||
|
@ -52,7 +53,7 @@ export const borrow = async (
|
|||
AccountLayout.span
|
||||
);
|
||||
|
||||
const obligation = createUninitializedAccount(
|
||||
const obligation = createUninitializedObligation(
|
||||
instructions,
|
||||
wallet.publicKey,
|
||||
await connection.getMinimumBalanceForRentExemption(
|
||||
|
|
Loading…
Reference in New Issue