UNPKG

@wuwei-labs/srsly

Version:
51 lines 2.08 kB
"use strict"; /** * @purpose Simplified closeBorrower instruction wrapper * * Thin convenience wrapper around Codama-generated closeBorrower instruction. * Closes a borrower's managed token account and BorrowerState. * Borrower-only — only the borrower may authorize the close (and pays * the transaction fee). */ Object.defineProperty(exports, "__esModule", { value: true }); exports.closeBorrower = closeBorrower; const kit_1 = require("@solana/kit"); const instructions_1 = require("../generated/codama/instructions"); const config_1 = require("../utils/config"); const signer_1 = require("../utils/signer"); const instructions_2 = require("../utils/instructions"); const config_2 = require("../accounts/config"); /** * Close a borrower's managed ATA + BorrowerState PDA, refunding rent to * the borrower wallet. Borrower-only — call `claimBorrower` first to * sweep any remaining ATLAS. * * @param params - Close borrower parameters * @param config - Optional SDK configuration overrides * @returns Kit instruction (or web3.js if PublicKey in config) * * @example * ```typescript * const ix = await closeBorrower({ borrower: borrowerWallet }); * ``` */ async function closeBorrower(params, config) { const finalConfig = (0, config_1.mergeConfig)(config); if (!params.borrower) { throw new Error('borrower is required'); } const borrowerSigner = (0, signer_1.toTransactionSigner)(params.borrower); const configAccount = await (0, config_2.fetchConfig)(finalConfig.rpcUrl); const atlasMint = configAccount.data.atlasMint; const addresses = (0, config_1.getAddresses)(config); const programAddress = (0, kit_1.address)(addresses.srsly); const kitInstruction = await (0, instructions_1.getCloseBorrowerInstructionAsync)({ borrower: borrowerSigner, mint: atlasMint, }, { programAddress }); return (0, instructions_2.prepareInstructions)(kitInstruction, { computeUnits: params.computeUnits, PublicKey: finalConfig.PublicKey, }); } //# sourceMappingURL=closeBorrower.js.map