UNPKG

hadeswap-sdk-public

Version:

HadeSwap SDK for interacting with protocol

44 lines (43 loc) 2.19 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.modifyPair = void 0; const anchor_1 = require("@project-serum/anchor"); const __1 = require("../../.."); const helpers_1 = require("../../helpers"); const constants_1 = require("../../constants"); const modifyPair = ({ programId, connection, args, accounts, sendTxn }) => __awaiter(void 0, void 0, void 0, function* () { const program = (0, helpers_1.returnAnchorProgram)(programId, connection); const instructions = []; const [solFundsVault, solVaultSeed] = yield anchor_1.web3.PublicKey.findProgramAddress([constants_1.ENCODER.encode(constants_1.SOL_FUNDS_PREFIX), accounts.pair.toBuffer()], program.programId); instructions.push(yield program.methods .modifyPair({ delta: new __1.BN(args.delta), spotPrice: new __1.BN(args.spotPrice), fee: new __1.BN(args.fee), }) .accounts({ pair: accounts.pair, authorityAdapter: accounts.authorityAdapter, user: accounts.userPubkey, fundsSolVault: solFundsVault, systemProgram: anchor_1.web3.SystemProgram.programId, rent: anchor_1.web3.SYSVAR_RENT_PUBKEY, }) .instruction()); const transaction = new anchor_1.web3.Transaction(); for (let instruction of instructions) transaction.add(instruction); const signers = []; yield sendTxn(transaction, signers); return { account: null, instructions, signers }; }); exports.modifyPair = modifyPair;