@frakt-protocol/frakt-sdk
Version:
Frakt SDK for interacting with frakt.xyz protocols
60 lines (59 loc) • 4.34 kB
JavaScript
;
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.fetchAndParseCollectionInfo = exports.fetchAndParsePriceBasedLiquidityPool = exports.fetchAndParseTimeBasedLiquidityPool = exports.fetchAndParseLoan = exports.fetchAndParseDeposit = exports.fetchAndParseLiquidationLot = void 0;
const helpers_1 = require("../helpers");
const fetchAndParseLiquidationLot = ({ liquidationLotPubkey, programId, connection, }) => __awaiter(void 0, void 0, void 0, function* () {
const nftLendingProgram = (0, helpers_1.returnAnchorProgram)(programId, connection);
const liquidationLotRaw = yield nftLendingProgram.account.liquidationLot.fetch(liquidationLotPubkey, 'confirmed');
const liquidationLot = (0, helpers_1.objectBNsAndPubkeysToNums)({
account: liquidationLotRaw,
publicKey: liquidationLotPubkey,
});
return liquidationLot;
});
exports.fetchAndParseLiquidationLot = fetchAndParseLiquidationLot;
const fetchAndParseDeposit = ({ depositPubkey, programId, connection, }) => __awaiter(void 0, void 0, void 0, function* () {
const nftLendingProgram = (0, helpers_1.returnAnchorProgram)(programId, connection);
const depositRaw = yield nftLendingProgram.account.deposit.fetch(depositPubkey, 'confirmed');
const deposit = (0, helpers_1.decodedDeposit)(depositRaw, depositPubkey);
return deposit;
});
exports.fetchAndParseDeposit = fetchAndParseDeposit;
const fetchAndParseLoan = ({ loanPubkey, programId, connection, }) => __awaiter(void 0, void 0, void 0, function* () {
const nftLendingProgram = (0, helpers_1.returnAnchorProgram)(programId, connection);
const loanRaw = yield nftLendingProgram.account.loan.fetch(loanPubkey, 'confirmed');
const loan = (0, helpers_1.decodedLoan)(loanRaw, loanPubkey);
return loan;
});
exports.fetchAndParseLoan = fetchAndParseLoan;
const fetchAndParseTimeBasedLiquidityPool = ({ timeBasedLiquidityPoolPubkey, programId, connection, }) => __awaiter(void 0, void 0, void 0, function* () {
const nftLendingProgram = (0, helpers_1.returnAnchorProgram)(programId, connection);
const liquidityPoolRaw = yield nftLendingProgram.account.liquidityPool.fetch(timeBasedLiquidityPoolPubkey, 'confirmed');
const liquidityPool = (0, helpers_1.decodedTimeBasedLiquidityPool)(liquidityPoolRaw, timeBasedLiquidityPoolPubkey);
return liquidityPool;
});
exports.fetchAndParseTimeBasedLiquidityPool = fetchAndParseTimeBasedLiquidityPool;
const fetchAndParsePriceBasedLiquidityPool = ({ priceBasedLiquidityPoolPubkey, programId, connection, }) => __awaiter(void 0, void 0, void 0, function* () {
const nftLendingProgram = (0, helpers_1.returnAnchorProgram)(programId, connection);
const liquidityPoolRaw = yield nftLendingProgram.account.priceBasedLiquidityPool.fetch(priceBasedLiquidityPoolPubkey, 'confirmed');
const liquidityPool = (0, helpers_1.decodedPriceBasedLiquidityPool)(liquidityPoolRaw, priceBasedLiquidityPoolPubkey);
return liquidityPool;
});
exports.fetchAndParsePriceBasedLiquidityPool = fetchAndParsePriceBasedLiquidityPool;
const fetchAndParseCollectionInfo = ({ collectionInfoPubkey, programId, connection, }) => __awaiter(void 0, void 0, void 0, function* () {
const nftLendingProgram = (0, helpers_1.returnAnchorProgram)(programId, connection);
// should be confirmed everywhere
const collectionInfoRaw = yield nftLendingProgram.account.collectionInfo.fetch(collectionInfoPubkey, 'confirmed');
const collectionInfo = (0, helpers_1.decodedCollectionInfo)(collectionInfoRaw, collectionInfoPubkey);
return collectionInfo;
});
exports.fetchAndParseCollectionInfo = fetchAndParseCollectionInfo;