@symmetry-hq/baskets-v2-sdk
Version:
Symmetry Baskets V2 SDK
35 lines (34 loc) • 1.89 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.WITHDRAW_STATE_SIZE = void 0;
exports.fetchWithdrawState = fetchWithdrawState;
exports.parseWithdrawState = parseWithdrawState;
exports.WITHDRAW_STATE_SIZE = 8155;
function fetchWithdrawState(program, basket) {
return __awaiter(this, void 0, void 0, function* () {
return yield program.account.withdrawStateV200.fetch(basket);
});
}
function parseWithdrawState(withdrawState) {
return {
ownAddress: withdrawState.ownAddress.toBase58(),
withdrawStateSeed: withdrawState.withdrawStateSeed,
basket: withdrawState.basket.toBase58(),
owner: withdrawState.owner.toBase58(),
numTokens: withdrawState.numTokens,
compositionMints: withdrawState.compositionMints.map(mint => mint.toBase58()).slice(0, withdrawState.numTokens),
compositionAmounts: withdrawState.compositionAmounts.map(amount => parseInt(amount.toString())).slice(0, withdrawState.numTokens),
rebalance: withdrawState.rebalance,
destinationMint: withdrawState.destinationMint.toBase58(),
destinationAmount: parseInt(withdrawState.destinationAmount.toString()),
};
}