UNPKG

@orca-so/whirlpool-sdk

Version:

Whirlpool SDK for the Orca protocol.

21 lines (20 loc) 1.12 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WhirlpoolInstance = void 0; const anchor_1 = require("@project-serum/anchor"); const whirlpool_client_sdk_1 = require("@orca-so/whirlpool-client-sdk"); const whirlpool_impl_1 = require("./impl/whirlpool-impl"); const address_1 = require("./utils/address"); const pool_util_1 = require("./utils/whirlpool/pool-util"); class WhirlpoolInstance { static fromAddress(ctx, address) { return new whirlpool_impl_1.WhirlpoolImpl(ctx, (0, anchor_1.translateAddress)(address)); } static fromTokens(ctx, tokenMintA, tokenMintB, tickSpacing) { // TODO: Ordering should be done by client-sdk const [_tokenMintA, _tokenMintB] = pool_util_1.PoolUtil.orderMints(tokenMintA, tokenMintB); const address = (0, whirlpool_client_sdk_1.getWhirlpoolPda)(ctx.program.programId, ctx.configAddress, (0, address_1.toPubKey)(_tokenMintA), (0, address_1.toPubKey)(_tokenMintB), tickSpacing).publicKey; return new whirlpool_impl_1.WhirlpoolImpl(ctx, address); } } exports.WhirlpoolInstance = WhirlpoolInstance;