fbonds-core
Version:
Banx protocol sdk
32 lines (31 loc) • 2.03 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.getPerpetualLinstings = void 0;
const helpers_1 = require("../../helpers");
const getAllPerpetualProgramAccounts_1 = require("./getAllPerpetualProgramAccounts");
const getPerpetualLinstings = (programId, connection) => __awaiter(void 0, void 0, void 0, function* () {
const program = yield (0, helpers_1.returnAnchorProgram)(connection);
const fraktBondsOffset = 8;
const bondOfferOffset = 32 + 8;
const bondTradeTxnOffset = 8;
const [fraktBondsRaw, bondTradeTxnRawV3, bondOffersV3Raw] = yield Promise.all([
(0, getAllPerpetualProgramAccounts_1.getFilteredAccounts)(program, 'fraktBond', fraktBondsOffset, [0]),
(0, getAllPerpetualProgramAccounts_1.getFilteredAccounts)(program, 'bondTradeTransactionV3', bondTradeTxnOffset, [11, 12]),
(0, getAllPerpetualProgramAccounts_1.getFilteredAccounts)(program, 'bondOfferV3', bondOfferOffset, [10]),
]);
return {
bondTradeTransactionsV3: bondTradeTxnRawV3.map(helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings),
fraktBonds: fraktBondsRaw.map(helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings),
bondOffersV3: bondOffersV3Raw.map(helpers_1.anchorRawBNsAndPubkeysToNumsAndStrings)
};
});
exports.getPerpetualLinstings = getPerpetualLinstings;