UNPKG

@frakt-protocol/frakt-sdk

Version:

Frakt SDK for interacting with frakt.xyz protocols

41 lines (40 loc) 2.6 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAllProgramAccounts = void 0; const helpers_1 = require("../../helpers"); const getAllProgramAccounts = (programId, connection) => __awaiter(void 0, void 0, void 0, function* () { let program = (0, helpers_1.returnAnchorProgram)(programId, connection); const collectionInfoRaws = yield program.account.collectionInfo.all(); const depositRaws = yield program.account.deposit.all(); const liquidityPoolRaws = yield program.account.liquidityPool.all(); const priceBasedLiquidityPoolRaws = yield program.account.priceBasedLiquidityPool.all(); const loanRaws = yield program.account.loan.all(); const liquidationLotRaws = yield program.account.liquidationLot.all(); const stakesRaw = yield program.account.lendingStake.all(); const collectionInfos = collectionInfoRaws.map((raw) => (0, helpers_1.decodedCollectionInfo)(raw.account, raw.publicKey)); const deposits = depositRaws.map((raw) => (0, helpers_1.decodedDeposit)(raw.account, raw.publicKey)); const timeBasedLiquidityPools = liquidityPoolRaws.map((raw) => (0, helpers_1.decodedTimeBasedLiquidityPool)(raw.account, raw.publicKey)); const priceBasedLiquidityPools = priceBasedLiquidityPoolRaws.map((raw) => (0, helpers_1.decodedPriceBasedLiquidityPool)(raw.account, raw.publicKey)); const loans = loanRaws.map((raw) => (0, helpers_1.decodedLoan)(raw.account, raw.publicKey)); const lendingStakes = stakesRaw.map((raw) => (0, helpers_1.decodedLendingStake)(raw.account, raw.publicKey)); const liquidationLots = liquidationLotRaws.map(helpers_1.objectBNsAndPubkeysToNums); return { collectionInfos, deposits, timeBasedLiquidityPools, priceBasedLiquidityPools, loans, lendingStakes, liquidationLots, }; }); exports.getAllProgramAccounts = getAllProgramAccounts;