UNPKG

@orca-so/whirlpools-sdk

Version:

Typescript SDK to interact with Orca's Whirlpool program.

34 lines 1.36 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.swapIx = swapIx; const spl_token_1 = require("@solana/spl-token"); const tiny_invariant_1 = __importDefault(require("tiny-invariant")); function swapIx(program, params) { const { amount, otherAmountThreshold, sqrtPriceLimit, amountSpecifiedIsInput, aToB, whirlpool, tokenAuthority, tokenOwnerAccountA, tokenVaultA, tokenOwnerAccountB, tokenVaultB, tickArray0, tickArray1, tickArray2, oracle, } = params; const ix = program.instruction.swap(amount, otherAmountThreshold, sqrtPriceLimit, amountSpecifiedIsInput, aToB, { accounts: { tokenProgram: spl_token_1.TOKEN_PROGRAM_ID, tokenAuthority: tokenAuthority, whirlpool, tokenOwnerAccountA, tokenVaultA, tokenOwnerAccountB, tokenVaultB, tickArray0, tickArray1, tickArray2, oracle, }, }); (0, tiny_invariant_1.default)(ix.keys[10].pubkey.equals(oracle)); ix.keys[10].isWritable = true; return { instructions: [ix], cleanupInstructions: [], signers: [], }; } //# sourceMappingURL=swap-ix.js.map