Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@orca-so/whirlpools-sdk

Package Overview
Dependencies
Maintainers
5
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orca-so/whirlpools-sdk - npm Package Compare versions

Comparing version 0.9.0-alpha.7 to 0.10.0-beta.1

dist/client/position-impl.d.ts

17

dist/context.d.ts

@@ -1,7 +0,8 @@

import { AnchorProvider, Program } from "@project-serum/anchor";
import { Wallet } from "@project-serum/anchor/dist/cjs/provider";
import { ConfirmOptions, Connection, PublicKey } from "@solana/web3.js";
import { AnchorProvider, Program } from "@coral-xyz/anchor";
import { LookupTableFetcher, Wallet } from "@orca-so/common-sdk";
import { Connection, PublicKey } from "@solana/web3.js";
import { Whirlpool } from "./artifacts/whirlpool";
import { AccountFetcher } from "./network/public";
/**
* Context for storing environment classes and objects for usage throughout the SDK
* @category Core

@@ -12,10 +13,10 @@ */

readonly wallet: Wallet;
readonly opts: ConfirmOptions;
readonly program: Program<Whirlpool>;
readonly provider: AnchorProvider;
readonly fetcher: AccountFetcher;
static from(connection: Connection, wallet: Wallet, programId: PublicKey, fetcher?: AccountFetcher, opts?: ConfirmOptions): WhirlpoolContext;
static fromWorkspace(provider: AnchorProvider, program: Program, fetcher?: AccountFetcher, opts?: ConfirmOptions): WhirlpoolContext;
static withProvider(provider: AnchorProvider, programId: PublicKey, fetcher?: AccountFetcher, opts?: ConfirmOptions): WhirlpoolContext;
constructor(provider: AnchorProvider, wallet: Wallet, program: Program, fetcher: AccountFetcher, opts: ConfirmOptions);
readonly lookupTableFetcher: LookupTableFetcher | undefined;
static from(connection: Connection, wallet: Wallet, programId: PublicKey, fetcher?: AccountFetcher, lookupTableFetcher?: LookupTableFetcher): WhirlpoolContext;
static fromWorkspace(provider: AnchorProvider, program: Program, fetcher?: AccountFetcher, lookupTableFetcher?: LookupTableFetcher): WhirlpoolContext;
static withProvider(provider: AnchorProvider, programId: PublicKey, fetcher?: AccountFetcher, lookupTableFetcher?: LookupTableFetcher): WhirlpoolContext;
constructor(provider: AnchorProvider, wallet: Wallet, program: Program, fetcher: AccountFetcher, lookupTableFetcher?: LookupTableFetcher);
}

@@ -7,25 +7,25 @@ "use strict";

exports.WhirlpoolContext = void 0;
const anchor_1 = require("@project-serum/anchor");
const anchor_1 = require("@coral-xyz/anchor");
const whirlpool_json_1 = __importDefault(require("./artifacts/whirlpool.json"));
const public_1 = require("./network/public");
/**
* Context for storing environment classes and objects for usage throughout the SDK
* @category Core
*/
class WhirlpoolContext {
static from(connection, wallet, programId, fetcher = new public_1.AccountFetcher(connection), opts = anchor_1.AnchorProvider.defaultOptions()) {
const anchorProvider = new anchor_1.AnchorProvider(connection, wallet, opts);
static from(connection, wallet, programId, fetcher = new public_1.AccountFetcher(connection), lookupTableFetcher) {
const anchorProvider = new anchor_1.AnchorProvider(connection, wallet, anchor_1.AnchorProvider.defaultOptions());
const program = new anchor_1.Program(whirlpool_json_1.default, programId, anchorProvider);
return new WhirlpoolContext(anchorProvider, anchorProvider.wallet, program, fetcher, opts);
return new WhirlpoolContext(anchorProvider, anchorProvider.wallet, program, fetcher, lookupTableFetcher);
}
static fromWorkspace(provider, program, fetcher = new public_1.AccountFetcher(provider.connection), opts = anchor_1.AnchorProvider.defaultOptions()) {
return new WhirlpoolContext(provider, provider.wallet, program, fetcher, opts);
static fromWorkspace(provider, program, fetcher = new public_1.AccountFetcher(provider.connection), lookupTableFetcher) {
return new WhirlpoolContext(provider, provider.wallet, program, fetcher, lookupTableFetcher);
}
static withProvider(provider, programId, fetcher = new public_1.AccountFetcher(provider.connection), opts = anchor_1.AnchorProvider.defaultOptions()) {
static withProvider(provider, programId, fetcher = new public_1.AccountFetcher(provider.connection), lookupTableFetcher) {
const program = new anchor_1.Program(whirlpool_json_1.default, programId, provider);
return new WhirlpoolContext(provider, provider.wallet, program, fetcher, opts);
return new WhirlpoolContext(provider, provider.wallet, program, fetcher, lookupTableFetcher);
}
constructor(provider, wallet, program, fetcher, opts) {
constructor(provider, wallet, program, fetcher, lookupTableFetcher) {
this.connection = provider.connection;
this.wallet = wallet;
this.opts = opts;
// It's a hack but it works on Anchor workspace *shrug*

@@ -35,4 +35,5 @@ this.program = program;

this.fetcher = fetcher;
this.lookupTableFetcher = lookupTableFetcher;
}
}
exports.WhirlpoolContext = WhirlpoolContext;

@@ -0,3 +1,3 @@

import { Address } from "@coral-xyz/anchor";
import { TransactionBuilder } from "@orca-so/common-sdk";
import { Address } from "@project-serum/anchor";
import { PublicKey } from "@solana/web3.js";

@@ -4,0 +4,0 @@ import { WhirlpoolContext } from "../context";

@@ -21,7 +21,8 @@ "use strict";

const mintA = data.tokenMintA;
const mintB = data.tokenMintB;
const [infoA, infoB] = yield fetcher.listMintInfos([mintA, mintB], refresh);
const infoA = yield fetcher.getMintInfo(mintA, refresh);
if (!infoA) {
throw new Error(`Unable to fetch MintInfo for mint - ${mintA}`);
}
const mintB = data.tokenMintB;
const infoB = yield fetcher.getMintInfo(mintB, refresh);
if (!infoB) {

@@ -40,37 +41,32 @@ throw new Error(`Unable to fetch MintInfo for mint - ${mintB}`);

const rewardInfos = [];
const fetchIndices = [];
const fetchVaults = [];
for (let i = 0; i < data.rewardInfos.length; i++) {
const rewardInfo = data.rewardInfos[i];
if (!__1.PoolUtil.isRewardInitialized(rewardInfo)) {
rewardInfos.push(Object.assign(Object.assign({}, rewardInfo), { initialized: false, vaultAmount: new bn_js_1.default(0) }));
}
else {
rewardInfos.push(undefined);
fetchIndices.push(i);
fetchVaults.push(rewardInfo.vault);
}
for (const rewardInfo of data.rewardInfos) {
rewardInfos.push(yield getRewardInfo(fetcher, rewardInfo, refresh));
}
const vaults = yield fetcher.listTokenInfos(fetchVaults, refresh);
for (let i = 0; i < vaults.length; i++) {
const vault = vaults[i];
const actualIndex = fetchIndices[i];
const rewardInfo = data.rewardInfos[actualIndex];
if (!vault) {
throw new Error(`Unable to fetch TokenAccountInfo for vault - ${rewardInfo.vault}`);
return rewardInfos;
});
}
exports.getRewardInfos = getRewardInfos;
function getRewardInfo(fetcher, data, refresh) {
return __awaiter(this, void 0, void 0, function* () {
const rewardInfo = Object.assign(Object.assign({}, data), { initialized: false, vaultAmount: new bn_js_1.default(0) });
if (__1.PoolUtil.isRewardInitialized(data)) {
const vaultInfo = yield fetcher.getTokenInfo(data.vault, refresh);
if (!vaultInfo) {
throw new Error(`Unable to fetch TokenAccountInfo for vault - ${data.vault}`);
}
rewardInfos[actualIndex] = Object.assign(Object.assign({}, rewardInfo), { initialized: true, vaultAmount: vault.amount });
rewardInfo.initialized = true;
rewardInfo.vaultAmount = vaultInfo.amount;
}
return rewardInfos;
return rewardInfo;
});
}
exports.getRewardInfos = getRewardInfos;
function getTokenVaultAccountInfos(fetcher, data, refresh) {
return __awaiter(this, void 0, void 0, function* () {
const vaultA = data.tokenVaultA;
const vaultB = data.tokenVaultB;
const [vaultInfoA, vaultInfoB] = yield fetcher.listTokenInfos([vaultA, vaultB], refresh);
const vaultInfoA = yield fetcher.getTokenInfo(vaultA, refresh);
if (!vaultInfoA) {
throw new Error(`Unable to fetch TokenAccountInfo for vault - ${vaultA}`);
}
const vaultB = data.tokenVaultB;
const vaultInfoB = yield fetcher.getTokenInfo(vaultB, refresh);
if (!vaultInfoB) {

@@ -77,0 +73,0 @@ throw new Error(`Unable to fetch TokenAccountInfo for vault - ${vaultB}`);

@@ -1,8 +0,7 @@

import { Percentage, TransactionBuilder } from "@orca-so/common-sdk";
import { Address } from "@project-serum/anchor";
import { AccountInfo } from "@solana/spl-token";
import { Address } from "@coral-xyz/anchor";
import { TransactionBuilder } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { WhirlpoolContext } from "../context";
import { AccountFetcher } from "../network/public";
import { WhirlpoolRoute } from "../quotes/public";
import { WhirlpoolRouter } from "../router/public";
import { Position, Whirlpool, WhirlpoolClient } from "../whirlpool-client";

@@ -14,2 +13,3 @@ export declare class WhirlpoolClientImpl implements WhirlpoolClient {

getFetcher(): AccountFetcher;
getRouter(poolAddresses: Address[]): Promise<WhirlpoolRouter>;
getPool(poolAddress: Address, refresh?: boolean): Promise<Whirlpool>;

@@ -25,3 +25,2 @@ getPools(poolAddresses: Address[], refresh?: boolean): Promise<Whirlpool[]>;

collectProtocolFeesForPools(poolAddresses: Address[]): Promise<TransactionBuilder>;
swapWithRoute(route: WhirlpoolRoute, slippage: Percentage, atas: AccountInfo[] | null, wallet: PublicKey, payer?: PublicKey | undefined): Promise<TransactionBuilder>;
}

@@ -22,4 +22,5 @@ "use strict";

const ix_1 = require("../ix");
const public_1 = require("../router/public");
const position_builder_util_1 = require("../utils/builder/position-builder-util");
const public_1 = require("../utils/public");
const public_2 = require("../utils/public");
const position_impl_1 = require("./position-impl");

@@ -38,2 +39,5 @@ const util_1 = require("./util");

}
getRouter(poolAddresses) {
return public_1.WhirlpoolRouterBuilder.buildWithPools(this.ctx, poolAddresses);
}
getPool(poolAddress, refresh = false) {

@@ -45,7 +49,5 @@ return __awaiter(this, void 0, void 0, function* () {

}
const [tokenInfos, vaultInfos, rewardInfos] = yield Promise.all([
(0, util_1.getTokenMintInfos)(this.ctx.fetcher, account, refresh),
(0, util_1.getTokenVaultAccountInfos)(this.ctx.fetcher, account, refresh),
(0, util_1.getRewardInfos)(this.ctx.fetcher, account, refresh),
]);
const tokenInfos = yield (0, util_1.getTokenMintInfos)(this.ctx.fetcher, account, refresh);
const vaultInfos = yield (0, util_1.getTokenVaultAccountInfos)(this.ctx.fetcher, account, refresh);
const rewardInfos = yield (0, util_1.getRewardInfos)(this.ctx.fetcher, account, refresh);
return new whirlpool_impl_1.WhirlpoolImpl(this.ctx, common_sdk_1.AddressUtil.toPubKey(poolAddress), tokenInfos[0], tokenInfos[1], vaultInfos[0], vaultInfos[1], rewardInfos, account);

@@ -68,3 +70,3 @@ });

account.rewardInfos.forEach((rewardInfo) => {
if (public_1.PoolUtil.isRewardInitialized(rewardInfo)) {
if (public_2.PoolUtil.isRewardInitialized(rewardInfo)) {
tokenAccounts.add(rewardInfo.vault.toBase58());

@@ -118,4 +120,4 @@ }

if (pool) {
const lowerTickArrayPda = public_1.PDAUtil.getTickArrayFromTickIndex(pos.tickLowerIndex, pool.tickSpacing, pos.whirlpool, this.ctx.program.programId).publicKey;
const upperTickArrayPda = public_1.PDAUtil.getTickArrayFromTickIndex(pos.tickUpperIndex, pool.tickSpacing, pos.whirlpool, this.ctx.program.programId).publicKey;
const lowerTickArrayPda = public_2.PDAUtil.getTickArrayFromTickIndex(pos.tickLowerIndex, pool.tickSpacing, pos.whirlpool, this.ctx.program.programId).publicKey;
const upperTickArrayPda = public_2.PDAUtil.getTickArrayFromTickIndex(pos.tickUpperIndex, pool.tickSpacing, pos.whirlpool, this.ctx.program.programId).publicKey;
tickArrayAddresses.add(lowerTickArrayPda.toBase58());

@@ -142,12 +144,12 @@ tickArrayAddresses.add(upperTickArrayPda.toBase58());

return __awaiter(this, void 0, void 0, function* () {
(0, tiny_invariant_1.default)(public_1.TickUtil.checkTickInBounds(initialTick), "initialTick is out of bounds.");
(0, tiny_invariant_1.default)(public_1.TickUtil.isTickInitializable(initialTick, tickSpacing), `initial tick ${initialTick} is not an initializable tick for tick-spacing ${tickSpacing}`);
const correctTokenOrder = public_1.PoolUtil.orderMints(tokenMintA, tokenMintB).map((addr) => addr.toString());
(0, tiny_invariant_1.default)(public_2.TickUtil.checkTickInBounds(initialTick), "initialTick is out of bounds.");
(0, tiny_invariant_1.default)(public_2.TickUtil.isTickInitializable(initialTick, tickSpacing), `initial tick ${initialTick} is not an initializable tick for tick-spacing ${tickSpacing}`);
const correctTokenOrder = public_2.PoolUtil.orderMints(tokenMintA, tokenMintB).map((addr) => addr.toString());
(0, tiny_invariant_1.default)(correctTokenOrder[0] === tokenMintA.toString(), "Token order needs to be flipped to match the canonical ordering (i.e. sorted on the byte repr. of the mint pubkeys)");
whirlpoolsConfig = common_sdk_1.AddressUtil.toPubKey(whirlpoolsConfig);
const feeTierKey = public_1.PDAUtil.getFeeTier(this.ctx.program.programId, whirlpoolsConfig, tickSpacing).publicKey;
const initSqrtPrice = public_1.PriceMath.tickIndexToSqrtPriceX64(initialTick);
const feeTierKey = public_2.PDAUtil.getFeeTier(this.ctx.program.programId, whirlpoolsConfig, tickSpacing).publicKey;
const initSqrtPrice = public_2.PriceMath.tickIndexToSqrtPriceX64(initialTick);
const tokenVaultAKeypair = web3_js_1.Keypair.generate();
const tokenVaultBKeypair = web3_js_1.Keypair.generate();
const whirlpoolPda = public_1.PDAUtil.getWhirlpool(this.ctx.program.programId, whirlpoolsConfig, new web3_js_1.PublicKey(tokenMintA), new web3_js_1.PublicKey(tokenMintB), tickSpacing);
const whirlpoolPda = public_2.PDAUtil.getWhirlpool(this.ctx.program.programId, whirlpoolsConfig, new web3_js_1.PublicKey(tokenMintA), new web3_js_1.PublicKey(tokenMintB), tickSpacing);
const feeTier = yield this.ctx.fetcher.getFeeTier(feeTierKey, refresh);

@@ -168,4 +170,4 @@ (0, tiny_invariant_1.default)(!!feeTier, `Fee tier for ${tickSpacing} doesn't exist`);

});
const initialTickArrayStartTick = public_1.TickUtil.getStartTickIndex(initialTick, tickSpacing);
const initialTickArrayPda = public_1.PDAUtil.getTickArray(this.ctx.program.programId, whirlpoolPda.publicKey, initialTickArrayStartTick);
const initialTickArrayStartTick = public_2.TickUtil.getStartTickIndex(initialTick, tickSpacing);
const initialTickArrayPda = public_2.PDAUtil.getTickArray(this.ctx.program.programId, whirlpoolPda.publicKey, initialTickArrayStartTick);
txBuilder.addInstruction(initPoolIx);

@@ -201,13 +203,3 @@ txBuilder.addInstruction((0, instructions_1.initTickArrayIx)(this.ctx.program, {

}
swapWithRoute(route, slippage, atas, wallet, payer) {
return __awaiter(this, void 0, void 0, function* () {
return (0, composites_1.getSwapFromRoute)(this.ctx, {
route,
slippage,
atas,
wallet,
});
});
}
}
exports.WhirlpoolClientImpl = WhirlpoolClientImpl;

@@ -0,3 +1,3 @@

import { Address } from "@coral-xyz/anchor";
import { Percentage, TransactionBuilder } from "@orca-so/common-sdk";
import { Address } from "@project-serum/anchor";
import { PublicKey } from "@solana/web3.js";

@@ -4,0 +4,0 @@ import { WhirlpoolContext } from "../context";

@@ -27,4 +27,4 @@ "use strict";

exports.WhirlpoolImpl = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const common_sdk_1 = require("@orca-so/common-sdk");
const anchor_1 = require("@project-serum/anchor");
const spl_token_1 = require("@solana/spl-token");

@@ -31,0 +31,0 @@ const web3_js_1 = require("@solana/web3.js");

@@ -5,3 +5,5 @@ export * from "./context";

export * from "./network/public";
export * from "./prices";
export * from "./quotes/public";
export * from "./router/public";
export * from "./types/public";

@@ -11,2 +13,1 @@ export * from "./types/public/anchor-types";

export * from "./whirlpool-client";
export * from "./prices";

@@ -25,3 +25,5 @@ "use strict";

__exportStar(require("./network/public"), exports);
__exportStar(require("./prices"), exports);
__exportStar(require("./quotes/public"), exports);
__exportStar(require("./router/public"), exports);
__exportStar(require("./types/public"), exports);

@@ -31,3 +33,2 @@ __exportStar(require("./types/public/anchor-types"), exports);

__exportStar(require("./whirlpool-client"), exports);
__exportStar(require("./prices"), exports);
// Global rules for Decimals

@@ -34,0 +35,0 @@ // - 40 digits of precision for the largest number

@@ -0,4 +1,4 @@

import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";

@@ -5,0 +5,0 @@ /**

@@ -1,4 +0,4 @@

import { Program } from "@project-serum/anchor";
import { Program } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { PublicKey } from "@solana/web3.js";
import { Instruction } from "@orca-so/common-sdk";

@@ -5,0 +5,0 @@ /**

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to collect protocol fees for a Whirlpool

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to collect rewards from a reward index in a position.

@@ -0,3 +1,3 @@

import { Address } from "@coral-xyz/anchor";
import { TransactionBuilder } from "@orca-so/common-sdk";
import { Address } from "@project-serum/anchor";
import { PublicKey } from "@solana/web3.js";

@@ -4,0 +4,0 @@ import { PositionData, WhirlpoolContext } from "../..";

@@ -0,4 +1,4 @@

import { Address } from "@coral-xyz/anchor";
import { TransactionBuilder } from "@orca-so/common-sdk";
import { Address } from "@project-serum/anchor";
import { WhirlpoolContext } from "../..";
export declare function collectProtocolFees(ctx: WhirlpoolContext, poolAddresses: Address[]): Promise<TransactionBuilder>;
export * from "./collect-all-txn";
export * from "./collect-protocol-fees";
export * from "./swap-async";
export * from "./swap-from-routes";

@@ -20,2 +20,1 @@ "use strict";

__exportStar(require("./swap-async"), exports);
__exportStar(require("./swap-from-routes"), exports);
import { TransactionBuilder } from "@orca-so/common-sdk";
import { AccountInfo } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";

@@ -18,3 +17,2 @@ import { Whirlpool, WhirlpoolContext } from "../..";

*/
export declare function swapAsync(ctx: WhirlpoolContext, params: SwapAsyncParams, refresh: boolean, txBuilder?: TransactionBuilder): Promise<TransactionBuilder>;
export declare function swapAsyncFromKeys(ctx: WhirlpoolContext, wallet: PublicKey, swapInput: SwapInput, whirlpool: PublicKey, tokenMintA: PublicKey, tokenMintB: PublicKey, tokenVaultA: PublicKey, tokenVaultB: PublicKey, atas: AccountInfo[] | null, refresh: boolean, txBuilder?: TransactionBuilder): Promise<TransactionBuilder>;
export declare function swapAsync(ctx: WhirlpoolContext, params: SwapAsyncParams, refresh: boolean): Promise<TransactionBuilder>;

@@ -23,6 +23,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.swapAsyncFromKeys = exports.swapAsync = void 0;
exports.swapAsync = void 0;
const common_sdk_1 = require("@orca-so/common-sdk");
const __1 = require("../..");
const ata_ix_util_1 = require("../../utils/ata-ix-util");
const swap_ix_1 = require("../swap-ix");

@@ -36,13 +35,7 @@ /**

*/
function swapAsync(ctx, params, refresh, txBuilder = new common_sdk_1.TransactionBuilder(ctx.connection, ctx.wallet)) {
function swapAsync(ctx, params, refresh) {
return __awaiter(this, void 0, void 0, function* () {
const { wallet, whirlpool, swapInput } = params;
const data = whirlpool.getData();
return swapAsyncFromKeys(ctx, wallet, swapInput, whirlpool.getAddress(), data.tokenMintA, data.tokenMintB, data.tokenVaultA, data.tokenVaultB, null, refresh, txBuilder);
});
}
exports.swapAsync = swapAsync;
function swapAsyncFromKeys(ctx, wallet, swapInput, whirlpool, tokenMintA, tokenMintB, tokenVaultA, tokenVaultB, atas, refresh, txBuilder = new common_sdk_1.TransactionBuilder(ctx.connection, ctx.wallet)) {
return __awaiter(this, void 0, void 0, function* () {
const { aToB, amount } = swapInput;
const txBuilder = new common_sdk_1.TransactionBuilder(ctx.connection, ctx.wallet);
const tickArrayAddresses = [swapInput.tickArray0, swapInput.tickArray1, swapInput.tickArray2];

@@ -53,13 +46,7 @@ let uninitializedArrays = yield __1.TickArrayUtil.getUninitializedArraysString(tickArrayAddresses, ctx.fetcher, refresh);

}
const [resolvedAtaA, resolvedAtaB] = yield (0, ata_ix_util_1.cachedResolveOrCreateATAs)(wallet, [
{ tokenMint: tokenMintA, wrappedSolAmountIn: aToB ? amount : common_sdk_1.ZERO },
{ tokenMint: tokenMintB, wrappedSolAmountIn: !aToB ? amount : common_sdk_1.ZERO },
], () => ctx.fetcher.getAccountRentExempt(), (keys) => {
if (atas != null) {
return Promise.resolve(keys.map((key) => atas.find((ata) => { var _a; return ((_a = ata.address) === null || _a === void 0 ? void 0 : _a.toBase58()) === key.toBase58(); })));
}
else {
return ctx.fetcher.listTokenInfos(keys, false);
}
});
const data = whirlpool.getData();
const [resolvedAtaA, resolvedAtaB] = yield (0, common_sdk_1.resolveOrCreateATAs)(ctx.connection, wallet, [
{ tokenMint: data.tokenMintA, wrappedSolAmountIn: aToB ? amount : common_sdk_1.ZERO },
{ tokenMint: data.tokenMintB, wrappedSolAmountIn: !aToB ? amount : common_sdk_1.ZERO },
], () => ctx.fetcher.getAccountRentExempt());
const { address: ataAKey } = resolvedAtaA, tokenOwnerAccountAIx = __rest(resolvedAtaA, ["address"]);

@@ -70,5 +57,5 @@ const { address: ataBKey } = resolvedAtaB, tokenOwnerAccountBIx = __rest(resolvedAtaB, ["address"]);

const outputTokenAccount = aToB ? ataBKey : ataAKey;
return txBuilder.addInstruction((0, swap_ix_1.swapIx)(ctx.program, __1.SwapUtils.getSwapParamsFromQuoteKeys(swapInput, ctx, whirlpool, tokenVaultA, tokenVaultB, inputTokenAccount, outputTokenAccount, wallet)));
return txBuilder.addInstruction((0, swap_ix_1.swapIx)(ctx.program, __1.SwapUtils.getSwapParamsFromQuote(swapInput, ctx, whirlpool, inputTokenAccount, outputTokenAccount, wallet)));
});
}
exports.swapAsyncFromKeys = swapAsyncFromKeys;
exports.swapAsync = swapAsync;
/// <reference types="bn.js" />
import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { BN, Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { BN } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -8,0 +7,0 @@ * Parameters to remove liquidity from a position.

/// <reference types="bn.js" />
import { Program, BN } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { BN, Program } from "@coral-xyz/anchor";
import { u64 } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { Instruction } from "@orca-so/common-sdk";

@@ -7,0 +7,0 @@ /**

@@ -0,1 +1,2 @@

export * from "./close-bundled-position-ix";
export * from "./close-position-ix";

@@ -6,4 +7,4 @@ export * from "./collect-fees-ix";

export * from "./composites";
export * from "./composites/swap-from-routes";
export * from "./decrease-liquidity-ix";
export * from "./delete-position-bundle-ix";
export * from "./increase-liquidity-ix";

@@ -13,4 +14,6 @@ export * from "./initialize-config-ix";

export * from "./initialize-pool-ix";
export * from "./initialize-position-bundle-ix";
export * from "./initialize-reward-ix";
export * from "./initialize-tick-array-ix";
export * from "./open-bundled-position-ix";
export * from "./open-position-ix";

@@ -17,0 +20,0 @@ export * from "./set-collect-protocol-fees-authority-ix";

@@ -17,2 +17,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./close-bundled-position-ix"), exports);
__exportStar(require("./close-position-ix"), exports);

@@ -23,4 +24,4 @@ __exportStar(require("./collect-fees-ix"), exports);

__exportStar(require("./composites"), exports);
__exportStar(require("./composites/swap-from-routes"), exports);
__exportStar(require("./decrease-liquidity-ix"), exports);
__exportStar(require("./delete-position-bundle-ix"), exports);
__exportStar(require("./increase-liquidity-ix"), exports);

@@ -30,4 +31,6 @@ __exportStar(require("./initialize-config-ix"), exports);

__exportStar(require("./initialize-pool-ix"), exports);
__exportStar(require("./initialize-position-bundle-ix"), exports);
__exportStar(require("./initialize-reward-ix"), exports);
__exportStar(require("./initialize-tick-array-ix"), exports);
__exportStar(require("./open-bundled-position-ix"), exports);
__exportStar(require("./open-position-ix"), exports);

@@ -34,0 +37,0 @@ __exportStar(require("./set-collect-protocol-fees-authority-ix"), exports);

@@ -0,3 +1,3 @@

import { Program } from "@coral-xyz/anchor";
import { Keypair, PublicKey } from "@solana/web3.js";
import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";

@@ -4,0 +4,0 @@ import { Instruction } from "@orca-so/common-sdk";

@@ -0,5 +1,5 @@

import { Program } from "@coral-xyz/anchor";
import { PDA } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { PDA } from "@orca-so/common-sdk";
import { Instruction } from "@orca-so/common-sdk";

@@ -6,0 +6,0 @@ /**

/// <reference types="bn.js" />
import { Program } from "@project-serum/anchor";
import { BN, Program } from "@coral-xyz/anchor";
import { Instruction, PDA } from "@orca-so/common-sdk";
import { Keypair, PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { PublicKey, Keypair } from "@solana/web3.js";
import { Instruction } from "@orca-so/common-sdk";
import { BN } from "@project-serum/anchor";
import { PDA } from "@orca-so/common-sdk";
/**

@@ -9,0 +7,0 @@ * Parameters to initialize a Whirlpool account.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initializePoolIx = void 0;
const spl_token_1 = require("@solana/spl-token");
const web3_js_1 = require("@solana/web3.js");
const spl_token_1 = require("@solana/spl-token");
/**

@@ -7,0 +7,0 @@ * Initializes a tick_array account to represent a tick-range in a Whirlpool.

@@ -0,3 +1,3 @@

import { Program } from "@coral-xyz/anchor";
import { Keypair, PublicKey } from "@solana/web3.js";
import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";

@@ -4,0 +4,0 @@ import { Instruction } from "@orca-so/common-sdk";

@@ -27,3 +27,3 @@ "use strict";

exports.initializeRewardIx = void 0;
const anchor = __importStar(require("@project-serum/anchor"));
const anchor = __importStar(require("@coral-xyz/anchor"));
const spl_token_1 = require("@solana/spl-token");

@@ -30,0 +30,0 @@ const web3_js_1 = require("@solana/web3.js");

@@ -1,6 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Program } from "@coral-xyz/anchor";
import { Instruction, PDA } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { PDA } from "@orca-so/common-sdk";
/**

@@ -7,0 +6,0 @@ * Parameters to initialize a TickArray account.

@@ -27,3 +27,3 @@ "use strict";

exports.initTickArrayIx = void 0;
const anchor = __importStar(require("@project-serum/anchor"));
const anchor = __importStar(require("@coral-xyz/anchor"));
/**

@@ -30,0 +30,0 @@ * Initializes a TickArray account.

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction, PDA } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { PDA, Instruction } from "@orca-so/common-sdk";
import { Whirlpool } from ".././artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to open a position in a Whirlpool.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.openPositionWithMetadataIx = exports.openPositionIx = void 0;
const web3_js_1 = require("@solana/web3.js");
const __1 = require("..");

@@ -55,3 +54,3 @@ const instructions_util_1 = require("../utils/instructions-util");

const ix = program.instruction.openPositionWithMetadata(bumps, tickLowerIndex, tickUpperIndex, {
accounts: Object.assign(Object.assign({}, (0, instructions_util_1.openPositionAccounts)(params)), { positionMetadataAccount: metadataPda.publicKey, metadataProgram: __1.METADATA_PROGRAM_ADDRESS, metadataUpdateAuth: new web3_js_1.PublicKey("3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr") }),
accounts: Object.assign(Object.assign({}, (0, instructions_util_1.openPositionAccounts)(params)), { positionMetadataAccount: metadataPda.publicKey, metadataProgram: __1.METADATA_PROGRAM_ADDRESS, metadataUpdateAuth: __1.WHIRLPOOL_NFT_UPDATE_AUTH }),
});

@@ -58,0 +57,0 @@ // TODO: Require Keypair and auto sign this ix

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to set the collect fee authority in a WhirlpoolsConfig

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to set the default fee rate for a FeeTier.

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to set the default fee rate for a FeeTier.

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to set the fee authority in a WhirlpoolsConfig

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to set fee rate for a Whirlpool.

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to set fee rate for a Whirlpool.

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to update the reward authority at a particular rewardIndex on a Whirlpool.

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to update the reward authority at a particular rewardIndex on a Whirlpool.

/// <reference types="bn.js" />
import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { BN, Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { BN } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -8,0 +7,0 @@ * Parameters to set rewards emissions for a reward in a Whirlpool

@@ -1,5 +0,5 @@

import { Program } from "@project-serum/anchor";
import { Whirlpool } from "../artifacts/whirlpool";
import { Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
/**

@@ -6,0 +6,0 @@ * Parameters to set rewards emissions for a reward in a Whirlpool

/// <reference types="bn.js" />
import { BN, Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { BN, Program } from "@project-serum/anchor";
import { u64 } from "@solana/spl-token";

@@ -5,0 +5,0 @@ import { PublicKey } from "@solana/web3.js";

/// <reference types="bn.js" />
import { BN, Program } from "@coral-xyz/anchor";
import { Instruction } from "@orca-so/common-sdk";
import { BN, Program } from "@project-serum/anchor";
import { u64 } from "@solana/spl-token";

@@ -5,0 +5,0 @@ import { PublicKey } from "@solana/web3.js";

@@ -1,4 +0,4 @@

import { Program } from "@project-serum/anchor";
import { Program } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";
import { Whirlpool } from "../artifacts/whirlpool";
import { PublicKey } from "@solana/web3.js";
import { Instruction } from "@orca-so/common-sdk";

@@ -5,0 +5,0 @@ /**

@@ -0,3 +1,3 @@

import { Program } from "@coral-xyz/anchor";
import { PDA } from "@orca-so/common-sdk";
import { Program } from "@project-serum/anchor";
import { WhirlpoolContext } from ".";

@@ -75,3 +75,2 @@ import { Whirlpool } from "./artifacts/whirlpool";

*
* @param program - program object containing services required to generate the instruction

@@ -90,3 +89,2 @@ * @param params - OpenPositionParams object

*
* @param program - program object containing services required to generate the instruction

@@ -128,3 +126,2 @@ * @param params - OpenPositionParams object and a derived PDA that hosts the position's metadata.

*
* @param program - program object containing services required to generate the instruction

@@ -208,3 +205,2 @@ * @param params - ClosePositionParams object

*
* @param program - program object containing services required to generate the instruction

@@ -333,2 +329,58 @@ * @param params - CollectRewardParams object

/**
* Initializes a PositionBundle account.
*
* @param program - program object containing services required to generate the instruction
* @param params - InitializePositionBundleParams object
* @returns - Instruction to perform the action.
*/
static initializePositionBundleIx(program: Program<Whirlpool>, params: ix.InitializePositionBundleParams): import("@orca-so/common-sdk").Instruction;
/**
* Initializes a PositionBundle account.
* Additional Metaplex metadata is appended to identify the token.
*
* @param program - program object containing services required to generate the instruction
* @param params - InitializePositionBundleParams object
* @returns - Instruction to perform the action.
*/
static initializePositionBundleWithMetadataIx(program: Program<Whirlpool>, params: ix.InitializePositionBundleParams & {
positionBundleMetadataPda: PDA;
}): import("@orca-so/common-sdk").Instruction;
/**
* Deletes a PositionBundle account.
*
* #### Special Errors
* `PositionBundleNotDeletable` - The provided position bundle has open positions.
*
* @param program - program object containing services required to generate the instruction
* @param params - DeletePositionBundleParams object
* @returns - Instruction to perform the action.
*/
static deletePositionBundleIx(program: Program<Whirlpool>, params: ix.DeletePositionBundleParams): import("@orca-so/common-sdk").Instruction;
/**
* Open a bundled position in a Whirlpool.
* No new tokens are issued because the owner of the position bundle becomes the owner of the position.
* The position will start off with 0 liquidity.
*
* #### Special Errors
* `InvalidBundleIndex` - If the provided bundle index is out of bounds.
* `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool.
*
* @param program - program object containing services required to generate the instruction
* @param params - OpenBundledPositionParams object
* @returns - Instruction to perform the action.
*/
static openBundledPositionIx(program: Program<Whirlpool>, params: ix.OpenBundledPositionParams): import("@orca-so/common-sdk").Instruction;
/**
* Close a bundled position in a Whirlpool.
*
* #### Special Errors
* `InvalidBundleIndex` - If the provided bundle index is out of bounds.
* `ClosePositionNotEmpty` - The provided position account is not empty.
*
* @param program - program object containing services required to generate the instruction
* @param params - CloseBundledPositionParams object
* @returns - Instruction to perform the action.
*/
static closeBundledPositionIx(program: Program<Whirlpool>, params: ix.CloseBundledPositionParams): import("@orca-so/common-sdk").Instruction;
/**
* DEPRECATED - use ${@link WhirlpoolClient} collectFeesAndRewardsForPositions function

@@ -335,0 +387,0 @@ * A set of transactions to collect all fees and rewards from a list of positions.

@@ -116,3 +116,2 @@ "use strict";

*
* @param program - program object containing services required to generate the instruction

@@ -133,3 +132,2 @@ * @param params - OpenPositionParams object

*
* @param program - program object containing services required to generate the instruction

@@ -175,3 +173,2 @@ * @param params - OpenPositionParams object and a derived PDA that hosts the position's metadata.

*
* @param program - program object containing services required to generate the instruction

@@ -267,3 +264,2 @@ * @param params - ClosePositionParams object

*
* @param program - program object containing services required to generate the instruction

@@ -414,2 +410,66 @@ * @param params - CollectRewardParams object

/**
* Initializes a PositionBundle account.
*
* @param program - program object containing services required to generate the instruction
* @param params - InitializePositionBundleParams object
* @returns - Instruction to perform the action.
*/
static initializePositionBundleIx(program, params) {
return ix.initializePositionBundleIx(program, params);
}
/**
* Initializes a PositionBundle account.
* Additional Metaplex metadata is appended to identify the token.
*
* @param program - program object containing services required to generate the instruction
* @param params - InitializePositionBundleParams object
* @returns - Instruction to perform the action.
*/
static initializePositionBundleWithMetadataIx(program, params) {
return ix.initializePositionBundleWithMetadataIx(program, params);
}
/**
* Deletes a PositionBundle account.
*
* #### Special Errors
* `PositionBundleNotDeletable` - The provided position bundle has open positions.
*
* @param program - program object containing services required to generate the instruction
* @param params - DeletePositionBundleParams object
* @returns - Instruction to perform the action.
*/
static deletePositionBundleIx(program, params) {
return ix.deletePositionBundleIx(program, params);
}
/**
* Open a bundled position in a Whirlpool.
* No new tokens are issued because the owner of the position bundle becomes the owner of the position.
* The position will start off with 0 liquidity.
*
* #### Special Errors
* `InvalidBundleIndex` - If the provided bundle index is out of bounds.
* `InvalidTickIndex` - If a provided tick is out of bounds, out of order or not a multiple of the tick-spacing in this pool.
*
* @param program - program object containing services required to generate the instruction
* @param params - OpenBundledPositionParams object
* @returns - Instruction to perform the action.
*/
static openBundledPositionIx(program, params) {
return ix.openBundledPositionIx(program, params);
}
/**
* Close a bundled position in a Whirlpool.
*
* #### Special Errors
* `InvalidBundleIndex` - If the provided bundle index is out of bounds.
* `ClosePositionNotEmpty` - The provided position account is not empty.
*
* @param program - program object containing services required to generate the instruction
* @param params - CloseBundledPositionParams object
* @returns - Instruction to perform the action.
*/
static closeBundledPositionIx(program, params) {
return ix.closeBundledPositionIx(program, params);
}
/**
* DEPRECATED - use ${@link WhirlpoolClient} collectFeesAndRewardsForPositions function

@@ -416,0 +476,0 @@ * A set of transactions to collect all fees and rewards from a list of positions.

@@ -1,5 +0,5 @@

import { Address } from "@project-serum/anchor";
import { Address } from "@coral-xyz/anchor";
import { AccountInfo, MintInfo } from "@solana/spl-token";
import { Connection } from "@solana/web3.js";
import { PositionData, TickArrayData, WhirlpoolData, WhirlpoolsConfigData } from "../..";
import { PositionBundleData, PositionData, TickArrayData, WhirlpoolData, WhirlpoolsConfigData } from "../..";
import { FeeTierData } from "../../types/public";

@@ -10,3 +10,3 @@ import { ParsableEntity } from "./parsing";

*/
type CachedValue = WhirlpoolsConfigData | WhirlpoolData | PositionData | TickArrayData | FeeTierData | AccountInfo | MintInfo;
type CachedValue = WhirlpoolsConfigData | WhirlpoolData | PositionData | TickArrayData | FeeTierData | PositionBundleData | AccountInfo | MintInfo;
/**

@@ -108,2 +108,10 @@ * Include both the entity (i.e. type) of the stored value, and the value itself

/**
* Retrieve a cached position bundle account. Fetch from rpc on cache miss.
*
* @param address position bundle address
* @param refresh force cache refresh
* @returns position bundle account
*/
getPositionBundle(address: Address, refresh?: boolean): Promise<PositionBundleData | null>;
/**
* Retrieve a list of cached whirlpool accounts. Fetch from rpc for cache misses.

@@ -157,2 +165,10 @@ *

/**
* Retrieve a list of cached position bundle accounts. Fetch from rpc for cache misses.
*
* @param addresses position bundle addresses
* @param refresh force cache refresh
* @returns position bundle accounts
*/
listPositionBundles(addresses: Address[], refresh: boolean): Promise<(PositionBundleData | null)[]>;
/**
* Update the cached value of all entities currently in the cache.

@@ -159,0 +175,0 @@ * Uses batched rpc request for network efficient fetch.

@@ -135,2 +135,14 @@ "use strict";

/**
* Retrieve a cached position bundle account. Fetch from rpc on cache miss.
*
* @param address position bundle address
* @param refresh force cache refresh
* @returns position bundle account
*/
getPositionBundle(address, refresh = false) {
return __awaiter(this, void 0, void 0, function* () {
return this.get(common_sdk_1.AddressUtil.toPubKey(address), parsing_1.ParsablePositionBundle, refresh);
});
}
/**
* Retrieve a list of cached whirlpool accounts. Fetch from rpc for cache misses.

@@ -224,2 +236,14 @@ *

/**
* Retrieve a list of cached position bundle accounts. Fetch from rpc for cache misses.
*
* @param addresses position bundle addresses
* @param refresh force cache refresh
* @returns position bundle accounts
*/
listPositionBundles(addresses, refresh) {
return __awaiter(this, void 0, void 0, function* () {
return this.list(common_sdk_1.AddressUtil.toPubKeys(addresses), parsing_1.ParsablePositionBundle, refresh);
});
}
/**
* Update the cached value of all entities currently in the cache.

@@ -226,0 +250,0 @@ * Uses batched rpc request for network efficient fetch.

/// <reference types="node" />
import { AccountInfo, MintInfo } from "@solana/spl-token";
import { WhirlpoolsConfigData, WhirlpoolData, PositionData, TickArrayData, FeeTierData } from "../../types/public";
import { FeeTierData, PositionBundleData, PositionData, TickArrayData, WhirlpoolData, WhirlpoolsConfigData } from "../../types/public";
/**

@@ -55,2 +55,9 @@ * Static abstract class definition to parse entities.

*/
export declare class ParsablePositionBundle {
private constructor();
static parse(data: Buffer | undefined | null): PositionBundleData | null;
}
/**
* @category Parsables
*/
export declare class ParsableTokenInfo {

@@ -57,0 +64,0 @@ private constructor();

@@ -32,9 +32,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.ParsableMintInfo = exports.ParsableTokenInfo = exports.ParsableFeeTier = exports.ParsableTickArray = exports.ParsablePosition = exports.ParsableWhirlpool = exports.ParsableWhirlpoolsConfig = void 0;
exports.ParsableMintInfo = exports.ParsableTokenInfo = exports.ParsablePositionBundle = exports.ParsableFeeTier = exports.ParsableTickArray = exports.ParsablePosition = exports.ParsableWhirlpool = exports.ParsableWhirlpoolsConfig = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const common_sdk_1 = require("@orca-so/common-sdk");
const spl_token_1 = require("@solana/spl-token");
const web3_js_1 = require("@solana/web3.js");
const WhirlpoolIDL = __importStar(require("../../artifacts/whirlpool.json"));
const public_1 = require("../../types/public");
const anchor_1 = require("@project-serum/anchor");
const WhirlpoolIDL = __importStar(require("../../artifacts/whirlpool.json"));
const common_sdk_1 = require("@orca-so/common-sdk");
/**

@@ -153,2 +153,24 @@ * @category Parsables

*/
let ParsablePositionBundle = class ParsablePositionBundle {
constructor() { }
static parse(data) {
if (!data) {
return null;
}
try {
return parseAnchorAccount(public_1.AccountName.PositionBundle, data);
}
catch (e) {
console.error(`error while parsing PositionBundle: ${e}`);
return null;
}
}
};
ParsablePositionBundle = __decorate([
staticImplements()
], ParsablePositionBundle);
exports.ParsablePositionBundle = ParsablePositionBundle;
/**
* @category Parsables
*/
let ParsableTokenInfo = class ParsableTokenInfo {

@@ -189,3 +211,3 @@ constructor() { }

isInitialized: buffer.isInitialized !== 0,
freezeAuthority: buffer.freezeAuthority === 0 ? null : new web3_js_1.PublicKey(buffer.freezeAuthority),
freezeAuthority: buffer.freezeAuthorityOption === 0 ? null : new web3_js_1.PublicKey(buffer.freezeAuthority),
};

@@ -192,0 +214,0 @@ return mintInfo;

@@ -1,2 +0,2 @@

import { Address } from "@project-serum/anchor";
import { Address } from "@coral-xyz/anchor";
import { u64 } from "@solana/spl-token";

@@ -3,0 +3,0 @@ import { PublicKey } from "@solana/web3.js";

@@ -1,2 +0,2 @@

import { Address } from "@project-serum/anchor";
import { Address } from "@coral-xyz/anchor";
import { DecimalsMap, PoolMap, PriceCalculationData, PriceMap, TickArrayMap } from ".";

@@ -3,0 +3,0 @@ import { WhirlpoolContext } from "../context";

/// <reference types="bn.js" />
import { BN } from "@project-serum/anchor";
import { BN } from "@coral-xyz/anchor";
import { PositionData, TickData, WhirlpoolData } from "../../types/public";

@@ -4,0 +4,0 @@ /**

/// <reference types="bn.js" />
import { BN } from "@project-serum/anchor";
import { BN } from "@coral-xyz/anchor";
import { PositionData, TickData, WhirlpoolData } from "../../types/public";

@@ -4,0 +4,0 @@ /**

@@ -7,4 +7,4 @@ "use strict";

exports.collectRewardsQuote = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const common_sdk_1 = require("@orca-so/common-sdk");
const anchor_1 = require("@project-serum/anchor");
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));

@@ -11,0 +11,0 @@ const public_1 = require("../../types/public");

/// <reference types="bn.js" />
import { BN } from "@coral-xyz/anchor";
import { Percentage } from "@orca-so/common-sdk";
import { BN } from "@project-serum/anchor";
import { DecreaseLiquidityInput } from "../../instructions";

@@ -5,0 +5,0 @@ import { Position, Whirlpool } from "../../whirlpool-client";

@@ -0,3 +1,3 @@

import { Address } from "@coral-xyz/anchor";
import { Percentage } from "@orca-so/common-sdk";
import { Address } from "@project-serum/anchor";
import { u64 } from "@solana/spl-token";

@@ -4,0 +4,0 @@ import { AccountFetcher } from "../..";

/// <reference types="bn.js" />
import { Address, BN } from "@coral-xyz/anchor";
import { Percentage } from "@orca-so/common-sdk";
import { Address, BN } from "@project-serum/anchor";
import { u64 } from "@solana/spl-token";

@@ -5,0 +5,0 @@ import { PublicKey } from "@solana/web3.js";

@@ -0,10 +1,7 @@

export * from "./increase-liquidity-quote";
export * from "./decrease-liquidity-quote";
export * from "./collect-fees-quote";
export * from "./collect-rewards-quote";
export * from "./decrease-liquidity-quote";
export * from "./swap-quote";
export * from "./dev-fee-swap-quote";
export * from "./increase-liquidity-quote";
export * from "./pool-graph";
export * from "./smart-swap";
export * from "./smart-swap-types";
export * from "./swap-quote";
export * from "./two-hop-swap-quote";

@@ -17,11 +17,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./increase-liquidity-quote"), exports);
__exportStar(require("./decrease-liquidity-quote"), exports);
__exportStar(require("./collect-fees-quote"), exports);
__exportStar(require("./collect-rewards-quote"), exports);
__exportStar(require("./decrease-liquidity-quote"), exports);
__exportStar(require("./swap-quote"), exports);
__exportStar(require("./dev-fee-swap-quote"), exports);
__exportStar(require("./increase-liquidity-quote"), exports);
__exportStar(require("./pool-graph"), exports);
__exportStar(require("./smart-swap"), exports);
__exportStar(require("./smart-swap-types"), exports);
__exportStar(require("./swap-quote"), exports);
__exportStar(require("./two-hop-swap-quote"), exports);

@@ -1,30 +0,2 @@

import { Address } from "@project-serum/anchor";
import { u64 } from "@solana/spl-token";
import { SwapQuote } from "./swap-quote";
export interface RouteQuote {
route: string[];
percent: number;
amountIn: u64;
amountOut: u64;
calculatedHops: RouteHop[];
}
export interface RouteHop {
percent: number;
amountIn: u64;
amountOut: u64;
whirlpool: Address;
inputMint: Address;
outputMint: Address;
mintA: Address;
mintB: Address;
vaultA: Address;
vaultB: Address;
quote: SwapQuote;
}
export interface RouteSet {
quotes: RouteQuote[];
percent: number;
totalIn: u64;
totalOut: u64;
}
import { RouteQuote, Routes } from "./smart-swap-types";
export interface QuotePercentMap {

@@ -34,5 +6,5 @@ [key: number]: RouteQuote[];

export declare function getRouteSetCompare(amountSpecifiedIsInput: boolean): typeof routeSetCompareForInputAmount;
declare function routeSetCompareForInputAmount(a: RouteSet, b: RouteSet): 0 | 1 | -1;
export declare function getRankedRouteSets(percentMap: QuotePercentMap, amountSpecifiedIsInput: boolean, topN: number, maxSplits: number): RouteSet[];
export declare function generateRouteSets(percentMap: QuotePercentMap, maxSplits: number): RouteSet[];
declare function routeSetCompareForInputAmount(a: Routes, b: Routes): 0 | 1 | -1;
export declare function getRankedRouteSets(percentMap: QuotePercentMap, amountSpecifiedIsInput: boolean, topN: number, maxSplits: number): Routes[];
export declare function generateRouteSets(percentMap: QuotePercentMap, maxSplits: number): Routes[];
export {};
/// <reference types="bn.js" />
import { Address, BN } from "@coral-xyz/anchor";
import { Percentage } from "@orca-so/common-sdk";
import { Address, BN } from "@project-serum/anchor";
import { u64 } from "@solana/spl-token";
import { SwapInput } from "../../instructions";
import { AccountFetcher } from "../../network/public";
import { SwapInput, TickArray, WhirlpoolData } from "../../types/public";
import { TickArray, WhirlpoolData } from "../../types/public";
import { Whirlpool } from "../../whirlpool-client";

@@ -8,0 +9,0 @@ import { DevFeeSwapQuote } from "./dev-fee-swap-quote";

import { TwoHopSwapInput } from "../../instructions";
import { SwapEstimates, SwapQuote } from "./swap-quote";
import { SwapEstimates, SwapQuote } from "../public/swap-quote";
/**

@@ -4,0 +4,0 @@ * A collection of estimated values from quoting a swap.

@@ -1,2 +0,2 @@

import { SwapQuoteParam, SwapQuote } from "../public";
import { SwapQuote, SwapQuoteParam } from "../public";
/**

@@ -3,0 +3,0 @@ * Figure out the quote parameters needed to successfully complete this trade on chain

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.simulateSwap = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const common_sdk_1 = require("@orca-so/common-sdk");
const anchor_1 = require("@project-serum/anchor");
const errors_1 = require("../../errors/errors");
const public_1 = require("../../types/public");
const swap_manager_1 = require("./swap-manager");
const tick_array_sequence_1 = require("./tick-array-sequence");
const swap_manager_1 = require("./swap-manager");
const public_1 = require("../../types/public");
const errors_1 = require("../../errors/errors");
/**

@@ -11,0 +11,0 @@ * Figure out the quote parameters needed to successfully complete this trade on chain

/// <reference types="bn.js" />
import { BN, BorshAccountsCoder } from "@project-serum/anchor";
import { BN, BorshAccountsCoder } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";

@@ -20,3 +20,4 @@ /**

Whirlpool = "Whirlpool",
FeeTier = "FeeTier"
FeeTier = "FeeTier",
PositionBundle = "PositionBundle"
}

@@ -144,1 +145,8 @@ /**

};
/**
* @category Solana Accounts
*/
export type PositionBundleData = {
positionBundleMint: PublicKey;
positionBitmap: number[];
};

@@ -7,3 +7,3 @@ "use strict";

exports.WHIRLPOOL_ACCOUNT_SIZE = exports.WHIRLPOOL_CODER = exports.AccountName = void 0;
const anchor_1 = require("@project-serum/anchor");
const anchor_1 = require("@coral-xyz/anchor");
const whirlpool_json_1 = __importDefault(require("../../artifacts/whirlpool.json"));

@@ -28,2 +28,3 @@ /**

AccountName["FeeTier"] = "FeeTier";
AccountName["PositionBundle"] = "PositionBundle";
})(AccountName = exports.AccountName || (exports.AccountName = {}));

@@ -30,0 +31,0 @@ const IDL = whirlpool_json_1.default;

/// <reference types="bn.js" />
import { BN } from "@project-serum/anchor";
import { BN } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";

@@ -50,4 +50,9 @@ /**

/**
* The number of bundled positions that a position-bundle account can hold.
* @category Constants
*/
export declare const POSITION_BUNDLE_SIZE = 256;
/**
* @category Constants
*/
export declare const METADATA_PROGRAM_ADDRESS: PublicKey;

@@ -69,1 +74,6 @@ /**

export declare const FEE_RATE_MUL_VALUE: BN;
/**
* The public key that is allowed to update the metadata of Whirlpool NFTs.
* @category Constants
*/
export declare const WHIRLPOOL_NFT_UPDATE_AUTH: PublicKey;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FEE_RATE_MUL_VALUE = exports.PROTOCOL_FEE_RATE_MUL_VALUE = exports.MAX_SWAP_TICK_ARRAYS = exports.METADATA_PROGRAM_ADDRESS = exports.TICK_ARRAY_SIZE = exports.MIN_SQRT_PRICE = exports.MAX_SQRT_PRICE = exports.MIN_TICK_INDEX = exports.MAX_TICK_INDEX = exports.NUM_REWARDS = exports.ORCA_SUPPORTED_TICK_SPACINGS = exports.ORCA_WHIRLPOOLS_CONFIG = exports.ORCA_WHIRLPOOL_PROGRAM_ID = void 0;
const anchor_1 = require("@project-serum/anchor");
exports.WHIRLPOOL_NFT_UPDATE_AUTH = exports.FEE_RATE_MUL_VALUE = exports.PROTOCOL_FEE_RATE_MUL_VALUE = exports.MAX_SWAP_TICK_ARRAYS = exports.METADATA_PROGRAM_ADDRESS = exports.POSITION_BUNDLE_SIZE = exports.TICK_ARRAY_SIZE = exports.MIN_SQRT_PRICE = exports.MAX_SQRT_PRICE = exports.MIN_TICK_INDEX = exports.MAX_TICK_INDEX = exports.NUM_REWARDS = exports.ORCA_SUPPORTED_TICK_SPACINGS = exports.ORCA_WHIRLPOOLS_CONFIG = exports.ORCA_WHIRLPOOL_PROGRAM_ID = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const web3_js_1 = require("@solana/web3.js");

@@ -52,4 +52,9 @@ /**

/**
* The number of bundled positions that a position-bundle account can hold.
* @category Constants
*/
exports.POSITION_BUNDLE_SIZE = 256;
/**
* @category Constants
*/
exports.METADATA_PROGRAM_ADDRESS = new web3_js_1.PublicKey("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");

@@ -71,1 +76,6 @@ /**

exports.FEE_RATE_MUL_VALUE = new anchor_1.BN(1000000);
/**
* The public key that is allowed to update the metadata of Whirlpool NFTs.
* @category Constants
*/
exports.WHIRLPOOL_NFT_UPDATE_AUTH = new web3_js_1.PublicKey("3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr");

@@ -0,4 +1,4 @@

export * from "./anchor-types";
export * from "./client-types";
export * from "./constants";
export * from "./anchor-types";
export * from "./ix-types";
export * from "./client-types";

@@ -17,5 +17,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./anchor-types"), exports);
__exportStar(require("./client-types"), exports);
__exportStar(require("./constants"), exports);
__exportStar(require("./anchor-types"), exports);
__exportStar(require("./ix-types"), exports);
__exportStar(require("./client-types"), exports);

@@ -1,2 +0,2 @@

export { ClosePositionParams, CollectFeesParams, CollectProtocolFeesParams, CollectRewardParams, DecreaseLiquidityInput, DecreaseLiquidityParams, DevFeeSwapInput, IncreaseLiquidityInput, IncreaseLiquidityParams, InitConfigParams, InitFeeTierParams, InitializeRewardParams, InitPoolParams, InitTickArrayParams, OpenPositionParams, SetCollectProtocolFeesAuthorityParams, SetDefaultFeeRateParams, SetDefaultProtocolFeeRateParams, SetFeeAuthorityParams, SetFeeRateParams, SetProtocolFeeRateParams, SetRewardAuthorityBySuperAuthorityParams, SetRewardAuthorityParams, SetRewardEmissionsParams, SetRewardEmissionsSuperAuthorityParams, SwapInput, SwapParams, TwoHopSwapInput, TwoHopSwapParams, UpdateFeesAndRewardsParams, } from "../../instructions/";
export { ClosePositionParams, CollectFeesParams, CollectProtocolFeesParams, CollectRewardParams, DecreaseLiquidityInput, DecreaseLiquidityParams, DevFeeSwapInput, IncreaseLiquidityInput, IncreaseLiquidityParams, InitConfigParams, InitFeeTierParams, InitializeRewardParams, InitPoolParams, InitTickArrayParams, OpenPositionParams, SetCollectProtocolFeesAuthorityParams, SetDefaultFeeRateParams, SetDefaultProtocolFeeRateParams, SetFeeAuthorityParams, SetFeeRateParams, SetProtocolFeeRateParams, SetRewardAuthorityBySuperAuthorityParams, SetRewardAuthorityParams, SetRewardEmissionsParams, SetRewardEmissionsSuperAuthorityParams, SwapInput, SwapParams, UpdateFeesAndRewardsParams, InitializePositionBundleParams, DeletePositionBundleParams, OpenBundledPositionParams, CloseBundledPositionParams, } from "../../instructions/";
export { CollectAllParams, CollectAllPositionAddressParams, CollectAllPositionParams, } from "../../instructions/composites";

@@ -1,3 +0,4 @@

import { Address } from "@project-serum/anchor";
import { PoolGraph, PoolTokenPair, Route, RouteSearchEntries, RouteSearchOptions } from "./public/pool-graph";
import { Address } from "@coral-xyz/anchor";
import "lodash.combinations";
import { Path, PathSearchEntries, PathSearchOptions, PoolGraph, PoolTokenPair } from "./public/pool-graph";
/**

@@ -9,11 +10,13 @@ * A pool graph implementation using an adjacency list.

*
* TODO: This implementation does not support 2-hop routes between identical tokens.
* TODO: This implementation does not support 2-edge paths between identical tokens.
*/
export declare class AdjacencyListPoolGraph implements PoolGraph {
readonly graph: Readonly<AdjacencyPoolGraphMap>;
readonly tokens: Readonly<Address[]>;
constructor(pools: PoolTokenPair[]);
getRoute(startMint: Address, endMint: Address, options?: RouteSearchOptions): Route[];
getRoutesForPairs(searchTokenPairs: [Address, Address][], options?: RouteSearchOptions): RouteSearchEntries;
getPath(startMint: Address, endMint: Address, options?: PathSearchOptions): Path[];
getPathsForPairs(searchTokenPairs: [Address, Address][], options?: PathSearchOptions): PathSearchEntries;
getAllPaths(options?: PathSearchOptions | undefined): PathSearchEntries;
}
type AdjacencyPoolGraphMap = Record<string, PoolGraphEdge[]>;
type AdjacencyPoolGraphMap = Record<string, readonly PoolGraphEdge[]>;
type PoolGraphEdge = {

@@ -20,0 +23,0 @@ address: string;

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AdjacencyListPoolGraph = void 0;
const common_sdk_1 = require("@orca-so/common-sdk");
const web3_js_1 = require("@solana/web3.js");
const lodash_1 = __importDefault(require("lodash"));
require("lodash.combinations");
const pool_graph_utils_1 = require("./public/pool-graph-utils");

@@ -13,30 +17,34 @@ /**

*
* TODO: This implementation does not support 2-hop routes between identical tokens.
* TODO: This implementation does not support 2-edge paths between identical tokens.
*/
class AdjacencyListPoolGraph {
constructor(pools) {
this.graph = buildPoolGraph(pools);
const [adjacencyListGraphMap, insertedTokens] = buildPoolGraph(pools);
this.graph = adjacencyListGraphMap;
this.tokens = Array.from(insertedTokens);
}
getRoute(startMint, endMint, options) {
const results = this.getRoutesForPairs([[startMint, endMint]], options);
getPath(startMint, endMint, options) {
const results = this.getPathsForPairs([[startMint, endMint]], options);
return results[0][1];
}
getRoutesForPairs(searchTokenPairs, options) {
const searchTokenPairsToFind = searchTokenPairs.filter(([startMint, endMint]) => {
return common_sdk_1.AddressUtil.toString(startMint) !== common_sdk_1.AddressUtil.toString(endMint);
});
const searchTokenPairsToFindAddrs = searchTokenPairsToFind.map(([startMint, endMint]) => {
getPathsForPairs(searchTokenPairs, options) {
const searchTokenPairsInString = searchTokenPairs.map(([startMint, endMint]) => {
return [common_sdk_1.AddressUtil.toString(startMint), common_sdk_1.AddressUtil.toString(endMint)];
});
const walkMap = findWalks(searchTokenPairsToFindAddrs, this.graph, options === null || options === void 0 ? void 0 : options.intermediateTokens.map((token) => common_sdk_1.AddressUtil.toString(token)));
const results = searchTokenPairs.map(([startMint, endMint]) => {
const searchRouteId = pool_graph_utils_1.PoolGraphUtils.getSearchRouteId(startMint, endMint);
const internalRouteId = getInternalRouteId(startMint, endMint);
const routesForSearchPair = walkMap[internalRouteId];
const paths = routesForSearchPair
? routesForSearchPair.map((route) => {
const searchTokenPairsToFind = searchTokenPairsInString.filter(([startMint, endMint]) => {
return startMint !== endMint;
});
const walkMap = findWalks(searchTokenPairsToFind, this.graph, options === null || options === void 0 ? void 0 : options.intermediateTokens.map((token) => common_sdk_1.AddressUtil.toString(token)));
const results = searchTokenPairsInString.map(([startMint, endMint]) => {
const searchRouteId = pool_graph_utils_1.PoolGraphUtils.getSearchPathId(startMint, endMint);
const [internalStartMint, internalEndMint] = [startMint, endMint].sort();
const internalRouteId = getInternalRouteId(internalStartMint, internalEndMint, false);
const reversed = internalStartMint !== startMint;
const pathsForSearchPair = walkMap[internalRouteId];
const paths = pathsForSearchPair
? pathsForSearchPair.map((path) => {
return {
startTokenMint: common_sdk_1.AddressUtil.toString(startMint),
endTokenMint: common_sdk_1.AddressUtil.toString(endMint),
hops: getHopsFromRoute(internalRouteId, searchRouteId, route),
startTokenMint: startMint,
endTokenMint: endMint,
edges: getHopsFromRoute(path, reversed),
};

@@ -49,11 +57,50 @@ })

}
getAllPaths(options) {
const tokenPairCombinations = lodash_1.default.combinations(this.tokens, 2);
const searchTokenPairsInString = tokenPairCombinations.map(([startMint, endMint]) => {
return [common_sdk_1.AddressUtil.toString(startMint), common_sdk_1.AddressUtil.toString(endMint)];
});
const searchTokenPairsToFind = searchTokenPairsInString.filter(([startMint, endMint]) => {
return startMint !== endMint;
});
const walkMap = findWalks(searchTokenPairsToFind, this.graph, options === null || options === void 0 ? void 0 : options.intermediateTokens.map((token) => common_sdk_1.AddressUtil.toString(token)));
// TODO: The token pairs are is in 1 direction only, we have to reverse them to get the other direction.
// this is actually pretty slow.consider removing reversal optimization in findWalks
const results = searchTokenPairsInString.reduce((acc, [startMint, endMint]) => {
const searchRouteId = pool_graph_utils_1.PoolGraphUtils.getSearchPathId(startMint, endMint);
const [internalStartMint, internalEndMint] = [startMint, endMint].sort();
const internalRouteId = getInternalRouteId(internalStartMint, internalEndMint, false);
const reversed = internalStartMint !== startMint;
const pathsForSearchPair = walkMap[internalRouteId];
const paths = pathsForSearchPair
? pathsForSearchPair.map((path) => {
return {
startTokenMint: startMint,
endTokenMint: endMint,
edges: getHopsFromRoute(path, reversed),
};
})
: [];
acc.push([searchRouteId, paths]);
const reversedSearchRouteId = pool_graph_utils_1.PoolGraphUtils.getSearchPathId(endMint, startMint);
const reversedPaths = pathsForSearchPair
? pathsForSearchPair.map((path) => {
return {
startTokenMint: endMint,
endTokenMint: startMint,
edges: getHopsFromRoute(path, !reversed),
};
})
: [];
acc.push([reversedSearchRouteId, reversedPaths]);
return acc;
}, []);
return results;
}
}
exports.AdjacencyListPoolGraph = AdjacencyListPoolGraph;
function getHopsFromRoute(internalRouteId, searchRouteId, route) {
const [intStartA] = pool_graph_utils_1.PoolGraphUtils.deconstructRouteId(internalRouteId);
const [searchStartA] = pool_graph_utils_1.PoolGraphUtils.deconstructRouteId(searchRouteId);
const shouldReverseRoute = searchStartA !== intStartA;
const finalRoutes = shouldReverseRoute ? route.slice().reverse() : route;
function getHopsFromRoute(path, reversed) {
const finalRoutes = reversed ? path.slice().reverse() : path;
return finalRoutes.map((hopStr) => {
return { poolAddress: new web3_js_1.PublicKey(hopStr) };
return { poolAddress: hopStr };
});

@@ -63,5 +110,8 @@ }

const insertedPoolCache = {};
const insertedTokens = new Set();
const poolGraphSet = pools.reduce((poolGraph, pool) => {
const { address, tokenMintA, tokenMintB } = pool;
const [addr, mintA, mintB] = common_sdk_1.AddressUtil.toStrings([address, tokenMintA, tokenMintB]);
insertedTokens.add(mintA);
insertedTokens.add(mintB);
if (poolGraph[mintA] === undefined) {

@@ -89,3 +139,3 @@ poolGraph[mintA] = [];

}, {});
return poolGraphSet;
return [poolGraphSet, insertedTokens];
}

@@ -98,21 +148,21 @@ // This is currently hardcoded to find walks of max length 2, generalizing to longer walks

tokenPairs.forEach(([tokenMintFrom, tokenMintTo]) => {
let routes = [];
// Adjust walk's from & to token based of of internal route id.
const internalRouteId = getInternalRouteId(tokenMintFrom, tokenMintTo);
let paths = [];
// Adjust walk's from & to token based of of internal path id.
const [internalTokenMintFrom, internalTokenMintTo] = [tokenMintFrom, tokenMintTo].sort();
const internalPathId = getInternalRouteId(internalTokenMintFrom, internalTokenMintTo, false);
const poolsForTokenFrom = poolGraph[internalTokenMintFrom] || [];
const poolsForTokenTo = poolGraph[internalTokenMintTo] || [];
// If the internal route id has already been created, then there is no need to re-search the route.
// Possible that the route was searched in reverse.
if (!!walks[internalRouteId]) {
// If the internal path id has already been created, then there is no need to re-search the path.
// Possible that the path was searched in reverse.
if (!!walks[internalPathId]) {
return;
}
// Find all direct pool routes, i.e. all edges shared between tokenA and tokenB
// Find all direct pool paths, i.e. all edges shared between tokenA and tokenB
const singleHop = poolsForTokenFrom
.filter(({ address }) => poolsForTokenTo.some((p) => p.address === address))
.map((op) => [op.address]);
routes.push(...singleHop);
paths.push(...singleHop);
// Remove all direct edges from poolA to poolB
const firstHop = poolsForTokenFrom.filter(({ address }) => !poolsForTokenTo.some((p) => p.address === address));
// Find all edges/nodes from neighbors of A that connect to B to create routes of length 2
// Find all edges/nodes from neighbors of A that connect to B to create paths of length 2
// tokenA --> tokenX --> tokenB

@@ -125,7 +175,7 @@ firstHop.forEach((firstPool) => {

.map((secondPool) => [firstPool.address, secondPool.address]);
routes.push(...secondHops);
paths.push(...secondHops);
}
});
if (routes.length > 0) {
walks[internalRouteId] = routes;
if (paths.length > 0) {
walks[internalPathId] = paths;
}

@@ -135,6 +185,6 @@ });

}
function getInternalRouteId(tokenA, tokenB) {
function getInternalRouteId(tokenA, tokenB, sort = true) {
const mints = [common_sdk_1.AddressUtil.toString(tokenA), common_sdk_1.AddressUtil.toString(tokenB)];
const sortedMints = mints.sort();
return `${sortedMints[0]}${pool_graph_utils_1.PoolGraphUtils.ROUTE_ID_DELIMITER}${sortedMints[1]} `;
const sortedMints = sort ? mints.sort() : mints;
return `${sortedMints[0]}${pool_graph_utils_1.PoolGraphUtils.PATH_ID_DELIMITER}${sortedMints[1]}`;
}

@@ -1,2 +0,2 @@

import { Address } from "@project-serum/anchor";
import { Address } from "@coral-xyz/anchor";
import { AccountFetcher } from "../../../network/public";

@@ -3,0 +3,0 @@ import { PoolGraph, PoolTokenPair } from "./pool-graph";

@@ -1,2 +0,2 @@

import { Address } from "@project-serum/anchor";
import { Address } from "@coral-xyz/anchor";
/**

@@ -7,16 +7,16 @@ * A utility class for working with pool graphs

export declare class PoolGraphUtils {
static readonly ROUTE_ID_DELIMITER = "-";
static readonly PATH_ID_DELIMITER = "-";
/**
* Get a search route id from two tokens. The id can be used to identify a route between the two tokens in {@link RouteSearchEntires}.
* @param tokenA The first token in the route
* @param tokenB The second token in the route
* @returns A route id that can be used to identify a route between the two tokens in {@link RouteSearchEntires}.
* Get a search path id from two tokens. The id can be used to identify a path between the two tokens in {@link PathSearchEntries}.
* @param tokenA The first token in the path
* @param tokenB The second token in the path
* @returns A path id that can be used to identify a path between the two tokens in {@link PathSearchEntries}.
*/
static getSearchRouteId(tokenA: Address, tokenB: Address): string;
static getSearchPathId(tokenA: Address, tokenB: Address): string;
/**
* Deconstruct a route id into the two tokens it represents
* @param routeId - The route id to deconstruct
* @returns A tuple of the two tokens in the route id. Returns undefined if the provided routeId is invalid.
* Deconstruct a path id into the two tokens it represents
* @param pathId - The path id to deconstruct
* @returns A tuple of the two tokens in the path id. Returns undefined if the provided pathId is invalid.
*/
static deconstructRouteId(routeId: string): [string, string];
static deconstructPathId(pathId: string): readonly [string, string];
}

@@ -11,19 +11,19 @@ "use strict";

/**
* Get a search route id from two tokens. The id can be used to identify a route between the two tokens in {@link RouteSearchEntires}.
* @param tokenA The first token in the route
* @param tokenB The second token in the route
* @returns A route id that can be used to identify a route between the two tokens in {@link RouteSearchEntires}.
* Get a search path id from two tokens. The id can be used to identify a path between the two tokens in {@link PathSearchEntries}.
* @param tokenA The first token in the path
* @param tokenB The second token in the path
* @returns A path id that can be used to identify a path between the two tokens in {@link PathSearchEntries}.
*/
static getSearchRouteId(tokenA, tokenB) {
return `${common_sdk_1.AddressUtil.toString(tokenA)}${PoolGraphUtils.ROUTE_ID_DELIMITER}${common_sdk_1.AddressUtil.toString(tokenB)}`;
static getSearchPathId(tokenA, tokenB) {
return `${common_sdk_1.AddressUtil.toString(tokenA)}${PoolGraphUtils.PATH_ID_DELIMITER}${common_sdk_1.AddressUtil.toString(tokenB)}`;
}
/**
* Deconstruct a route id into the two tokens it represents
* @param routeId - The route id to deconstruct
* @returns A tuple of the two tokens in the route id. Returns undefined if the provided routeId is invalid.
* Deconstruct a path id into the two tokens it represents
* @param pathId - The path id to deconstruct
* @returns A tuple of the two tokens in the path id. Returns undefined if the provided pathId is invalid.
*/
static deconstructRouteId(routeId) {
const split = routeId.split(PoolGraphUtils.ROUTE_ID_DELIMITER);
static deconstructPathId(pathId) {
const split = pathId.split(PoolGraphUtils.PATH_ID_DELIMITER);
if (split.length !== 2) {
throw new Error(`Invalid route id: ${routeId}`);
throw new Error(`Invalid path id: ${pathId}`);
}

@@ -35,2 +35,2 @@ const [tokenA, tokenB] = split;

exports.PoolGraphUtils = PoolGraphUtils;
PoolGraphUtils.ROUTE_ID_DELIMITER = "-";
PoolGraphUtils.PATH_ID_DELIMITER = "-";

@@ -1,2 +0,2 @@

import { Address } from "@project-serum/anchor";
import { Address } from "@coral-xyz/anchor";
/**

@@ -12,22 +12,22 @@ * An object containing the token pairs of a Whirlpool.

/**
* Route search results for a series of graph search queries between two tokens.
* Results for a series of graph search queries between two tokens.
* The search id for each entry can be obtained from {@link PoolGraphUtils.getSearchRouteId}
* If routes exist for that search id exists, it will be an array of routes.
* If routes do not exist, it will be an empty array.
* If a path exist between tokens for that search id, it will be an array of paths.
* If paths do not exist, it will be an empty array.
*
* @category PoolGraph
*/
export type RouteSearchEntries = (readonly [string, Route[]])[];
export type PathSearchEntries = (readonly [string, Path[]])[];
/**
* A route to trade from start token mint to end token mint.
* A path to trade from start token mint to end token mint.
*
* @category PoolGraph
* @param startMint - The token the route starts with
* @param endMint - The token the route ends with
* @param edges - An ordered list of pool addresses that make up the route
* @param startMint - The token the path starts with
* @param endMint - The token the path ends with
* @param edges - An ordered list of edges (pool addresses) that make up the path
*/
export type Route = {
export type Path = {
startTokenMint: string;
endTokenMint: string;
hops: Hop[];
edges: Edge[];
};

@@ -39,7 +39,7 @@ /**

*/
export type Hop = {
export type Edge = {
poolAddress: Address;
};
/**
* Options for finding a route between two tokens
* Options for finding a path between two tokens
*

@@ -49,7 +49,8 @@ * @category PoolGraph

*/
export type RouteSearchOptions = {
export type PathSearchOptions = {
intermediateTokens: Address[];
};
/**
* A type representing a graph of pools that can be used to find routes between two tokens.
* A type representing an undirected graph of pools that can be used to find paths between two tokens.
* In this graph, nodes are token mints, and edges are pools
*

@@ -60,26 +61,32 @@ * @category PoolGraph

/**
* Get a list of routes between two tokens for this pool graph.
* Get a list of paths between two tokens for this pool graph.
*
* Notes:
* - Only support routes with up to 2 hops
* - Routes between two identical token mints are not supported.
* - Only support paths with up to 2 edges
* - Paths searching between two identical token mints are not supported.
*
* @param startMint The token the route starts from
* @param endMint The token the route ends in
* @param options Options for finding a route
* @returns A list of routes between the two tokens. If no routes are found, it will be an empty array.
* @param startMint The token the path starts from
* @param endMint The token the path ends in
* @param options Options for finding a path
* @returns A list of path between the two tokens. If no path are found, it will be an empty array.
*/
getRoute: (startMint: Address, endMint: Address, options?: RouteSearchOptions) => Route[];
getPath: (startMint: Address, endMint: Address, options?: PathSearchOptions) => Path[];
/**
* Get a map of routes from a list of token pairs for this pool graph.
* Get a map of paths from a list of token pairs for this pool graph.
*
* Notes:
* - Only support routes with up to 2 hops
* - Routes between two identical token mints are not supported.
* - Only support paths with up to 2 edges
* - Paths searching between two identical token mints are not supported.
*
* @param searchTokenPairs A list of token pairs to find routes for. The first token in the pair is the start token, and the second token is the end token.
* @param options Options for finding a route
* @param searchTokenPairs A list of token pairs to find paths for. The first token in the pair is the start token, and the second token is the end token.
* @param options Options for finding a path
* @return An array of search result entires in the same order as the searchTokenPairs.
*/
getRoutesForPairs(searchTokenPairs: [Address, Address][], options?: RouteSearchOptions): RouteSearchEntries;
getPathsForPairs(searchTokenPairs: [Address, Address][], options?: PathSearchOptions): PathSearchEntries;
/**
* Get a list of all paths for this pool graph.
* @param options Options for finding a path
* @return An array of all permutations of token-pairs to the paths for each pair.
*/
getAllPaths(options?: PathSearchOptions): PathSearchEntries;
};

@@ -0,3 +1,3 @@

import * as anchor from "@coral-xyz/anchor";
import { OpenPositionParams } from "../instructions";
import * as anchor from "@project-serum/anchor";
export declare function openPositionAccounts(params: OpenPositionParams): {

@@ -4,0 +4,0 @@ funder: anchor.web3.PublicKey;

@@ -27,4 +27,4 @@ "use strict";

exports.openPositionAccounts = void 0;
const anchor = __importStar(require("@coral-xyz/anchor"));
const spl_token_1 = require("@solana/spl-token");
const anchor = __importStar(require("@project-serum/anchor"));
const web3_js_1 = require("@solana/web3.js");

@@ -31,0 +31,0 @@ function openPositionAccounts(params) {

/// <reference types="bn.js" />
import { BN } from "@project-serum/anchor";
import { BN } from "@coral-xyz/anchor";
export declare class BitMath {

@@ -4,0 +4,0 @@ static mul(n0: BN, n1: BN, limit: number): BN;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BitMath = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const common_sdk_1 = require("@orca-so/common-sdk");
const anchor_1 = require("@project-serum/anchor");
const errors_1 = require("../../errors/errors");

@@ -7,0 +7,0 @@ class BitMath {

/// <reference types="bn.js" />
import { BN } from "@coral-xyz/anchor";
import { u64 } from "@solana/spl-token";
import { BN } from "@project-serum/anchor";
export type SwapStep = {

@@ -5,0 +5,0 @@ amountIn: BN;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.computeSwapStep = void 0;
const anchor_1 = require("@project-serum/anchor");
const anchor_1 = require("@coral-xyz/anchor");
const public_1 = require("../../types/public");
const bit_math_1 = require("./bit-math");
const token_math_1 = require("./token-math");
const bit_math_1 = require("./bit-math");
const public_1 = require("../../types/public");
function computeSwapStep(amountRemaining, feeRate, currLiquidity, currSqrtPrice, targetSqrtPrice, amountSpecifiedIsInput, aToB) {

@@ -9,0 +9,0 @@ let amountFixedDelta = getAmountFixedDelta(currSqrtPrice, targetSqrtPrice, currLiquidity, amountSpecifiedIsInput, aToB);

/// <reference types="bn.js" />
import { BN } from "@coral-xyz/anchor";
import { Percentage } from "@orca-so/common-sdk";
import { BN } from "@project-serum/anchor";
import { u64 } from "@solana/spl-token";

@@ -5,0 +5,0 @@ export declare function getAmountDeltaA(currSqrtPrice: BN, targetSqrtPrice: BN, currLiquidity: BN, roundUp: boolean): BN;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.adjustForSlippage = exports.getNextSqrtPrice = exports.getAmountDeltaB = exports.getAmountDeltaA = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const common_sdk_1 = require("@orca-so/common-sdk");
const anchor_1 = require("@project-serum/anchor");
const errors_1 = require("../../errors/errors");

@@ -7,0 +7,0 @@ const public_1 = require("../../types/public");

/// <reference types="bn.js" />
import { BN } from "@coral-xyz/anchor";
import { Percentage } from "@orca-so/common-sdk";
import { BN } from "@project-serum/anchor";
export declare enum SwapDirection {

@@ -5,0 +5,0 @@ AtoB = "Swap A to B",

@@ -0,4 +1,6 @@

export * from "../graphs/public";
export * from "./ix-utils";
export * from "./pda-utils";
export * from "./pool-utils";
export * from "./position-bundle-util";
export * from "./price-math";

@@ -5,0 +7,0 @@ export * from "./swap-utils";

@@ -17,7 +17,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
// TODO: Temp do not export new PoolGraph to avoid duplicate export.
// export * from "../graphs/public";
__exportStar(require("../graphs/public"), exports);
__exportStar(require("./ix-utils"), exports);
__exportStar(require("./pda-utils"), exports);
__exportStar(require("./pool-utils"), exports);
__exportStar(require("./position-bundle-util"), exports);
__exportStar(require("./price-math"), exports);

@@ -24,0 +24,0 @@ __exportStar(require("./swap-utils"), exports);

/// <reference types="bn.js" />
import { BN } from "@project-serum/anchor";
import { BN } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";

@@ -8,4 +8,2 @@ /**

export declare class PDAUtil {
private static TICK_ARRAY_CACHE;
private static ORACLE_CACHE;
/**

@@ -41,3 +39,3 @@ *

*/
static getTickArray(programId: PublicKey, whirlpoolAddress: PublicKey, startTick: number): any;
static getTickArray(programId: PublicKey, whirlpoolAddress: PublicKey, startTick: number): import("@orca-so/common-sdk").PDA;
/**

@@ -54,4 +52,4 @@ * Get the PDA of the tick array containing tickIndex.

*/
static getTickArrayFromTickIndex(tickIndex: number, tickSpacing: number, whirlpool: PublicKey, programId: PublicKey, tickArrayOffset?: number): any;
static getTickArrayFromSqrtPrice(sqrtPriceX64: BN, tickSpacing: number, whirlpool: PublicKey, programId: PublicKey, tickArrayOffset?: number): any;
static getTickArrayFromTickIndex(tickIndex: number, tickSpacing: number, whirlpool: PublicKey, programId: PublicKey, tickArrayOffset?: number): import("@orca-so/common-sdk").PDA;
static getTickArrayFromSqrtPrice(sqrtPriceX64: BN, tickSpacing: number, whirlpool: PublicKey, programId: PublicKey, tickArrayOffset?: number): import("@orca-so/common-sdk").PDA;
/**

@@ -71,3 +69,24 @@ * @category Program Derived Addresses

*/
static getOracle(programId: PublicKey, whirlpoolAddress: PublicKey): any;
static getOracle(programId: PublicKey, whirlpoolAddress: PublicKey): import("@orca-so/common-sdk").PDA;
/**
* @category Program Derived Addresses
* @param programId
* @param positionBundleMintKey
* @param bundleIndex
* @returns
*/
static getBundledPosition(programId: PublicKey, positionBundleMintKey: PublicKey, bundleIndex: number): import("@orca-so/common-sdk").PDA;
/**
* @category Program Derived Addresses
* @param programId
* @param positionBundleMintKey
* @returns
*/
static getPositionBundle(programId: PublicKey, positionBundleMintKey: PublicKey): import("@orca-so/common-sdk").PDA;
/**
* @category Program Derived Addresses
* @param positionBundleMintKey
* @returns
*/
static getPositionBundleMetadata(positionBundleMintKey: PublicKey): import("@orca-so/common-sdk").PDA;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PDAUtil = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const common_sdk_1 = require("@orca-so/common-sdk");
const anchor_1 = require("@project-serum/anchor");
const public_1 = require("../../types/public");

@@ -15,2 +15,4 @@ const price_math_1 = require("./price-math");

const PDA_ORACLE_SEED = "oracle";
const PDA_POSITION_BUNDLE_SEED = "position_bundle";
const PDA_BUNDLED_POSITION_SEED = "bundled_position";
/**

@@ -67,12 +69,3 @@ * @category Whirlpool Utils

static getTickArray(programId, whirlpoolAddress, startTick) {
const wpStr = whirlpoolAddress.toBase58();
let tas = this.TICK_ARRAY_CACHE[wpStr];
if (!tas) {
this.TICK_ARRAY_CACHE[wpStr] = {};
}
tas = this.TICK_ARRAY_CACHE[wpStr];
if (tas[startTick]) {
return tas[startTick];
}
const pda = common_sdk_1.AddressUtil.findProgramAddress([
return common_sdk_1.AddressUtil.findProgramAddress([
Buffer.from(PDA_TICK_ARRAY_SEED),

@@ -82,4 +75,2 @@ whirlpoolAddress.toBuffer(),

], programId);
this.TICK_ARRAY_CACHE[wpStr][startTick] = pda;
return pda;
}

@@ -126,14 +117,40 @@ /**

static getOracle(programId, whirlpoolAddress) {
const wpStr = whirlpoolAddress.toBase58();
let oc = this.ORACLE_CACHE[wpStr];
if (oc) {
return oc;
}
const pda = common_sdk_1.AddressUtil.findProgramAddress([Buffer.from(PDA_ORACLE_SEED), whirlpoolAddress.toBuffer()], programId);
this.ORACLE_CACHE[wpStr] = pda;
return pda;
return common_sdk_1.AddressUtil.findProgramAddress([Buffer.from(PDA_ORACLE_SEED), whirlpoolAddress.toBuffer()], programId);
}
/**
* @category Program Derived Addresses
* @param programId
* @param positionBundleMintKey
* @param bundleIndex
* @returns
*/
static getBundledPosition(programId, positionBundleMintKey, bundleIndex) {
return common_sdk_1.AddressUtil.findProgramAddress([
Buffer.from(PDA_BUNDLED_POSITION_SEED),
positionBundleMintKey.toBuffer(),
Buffer.from(bundleIndex.toString()),
], programId);
}
/**
* @category Program Derived Addresses
* @param programId
* @param positionBundleMintKey
* @returns
*/
static getPositionBundle(programId, positionBundleMintKey) {
return common_sdk_1.AddressUtil.findProgramAddress([Buffer.from(PDA_POSITION_BUNDLE_SEED), positionBundleMintKey.toBuffer()], programId);
}
/**
* @category Program Derived Addresses
* @param positionBundleMintKey
* @returns
*/
static getPositionBundleMetadata(positionBundleMintKey) {
return common_sdk_1.AddressUtil.findProgramAddress([
Buffer.from(PDA_METADATA_SEED),
public_1.METADATA_PROGRAM_ADDRESS.toBuffer(),
positionBundleMintKey.toBuffer(),
], public_1.METADATA_PROGRAM_ADDRESS);
}
}
exports.PDAUtil = PDAUtil;
PDAUtil.TICK_ARRAY_CACHE = {};
PDAUtil.ORACLE_CACHE = {};
/// <reference types="bn.js" />
import { Address, BN } from "@coral-xyz/anchor";
import { Percentage } from "@orca-so/common-sdk";
import { Address, BN } from "@project-serum/anchor";
import { u64 } from "@solana/spl-token";

@@ -5,0 +5,0 @@ import { PublicKey } from "@solana/web3.js";

@@ -7,4 +7,4 @@ "use strict";

exports.toTokenAmount = exports.PoolUtil = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const common_sdk_1 = require("@orca-so/common-sdk");
const anchor_1 = require("@project-serum/anchor");
const spl_token_1 = require("@solana/spl-token");

@@ -11,0 +11,0 @@ const web3_js_1 = require("@solana/web3.js");

/// <reference types="bn.js" />
import { BN } from "@project-serum/anchor";
import { BN } from "@coral-xyz/anchor";
import Decimal from "decimal.js";

@@ -4,0 +4,0 @@ /**

@@ -7,4 +7,4 @@ "use strict";

exports.PriceMath = void 0;
const anchor_1 = require("@coral-xyz/anchor");
const common_sdk_1 = require("@orca-so/common-sdk");
const anchor_1 = require("@project-serum/anchor");
const decimal_js_1 = __importDefault(require("decimal.js"));

@@ -11,0 +11,0 @@ const public_1 = require("../../types/public");

@@ -0,3 +1,3 @@

import { Address } from "@coral-xyz/anchor";
import { Percentage } from "@orca-so/common-sdk";
import { Address } from "@project-serum/anchor";
import { PublicKey } from "@solana/web3.js";

@@ -10,2 +10,6 @@ import BN from "bn.js";

import { SwapDirection } from "./types";
/**
* A request to fetch the tick-arrays that a swap may traverse across.
* @category Whirlpool Utils
*/
export interface TickArrayRequest {

@@ -12,0 +16,0 @@ whirlpoolAddress: PublicKey;

@@ -0,3 +1,3 @@

import { Address } from "@coral-xyz/anchor";
import { PDA } from "@orca-so/common-sdk";
import { Address } from "@project-serum/anchor";
import { PublicKey } from "@solana/web3.js";

@@ -98,3 +98,3 @@ import { AccountFetcher } from "../../network/public";

startIndex: number;
pda: any;
pda: PDA;
}[]>;

@@ -101,0 +101,0 @@ /**

@@ -0,9 +1,8 @@

import { Address } from "@coral-xyz/anchor";
import { Percentage, TransactionBuilder } from "@orca-so/common-sdk";
import { Address } from "@project-serum/anchor";
import { AccountInfo } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import { WhirlpoolRoute } from ".";
import { WhirlpoolContext } from "./context";
import { DevFeeSwapInput, SwapInput } from "./instructions";
import { AccountFetcher } from "./network/public";
import { WhirlpoolRouter } from "./router/public";
import { DecreaseLiquidityInput, IncreaseLiquidityInput, PositionData, TickData, WhirlpoolData } from "./types/public";

@@ -28,2 +27,8 @@ import { TokenAccountInfo, TokenInfo, WhirlpoolRewardInfo } from "./types/public/client-types";

/**
* Get a WhirlpoolRouter to help generate the best prices when transacting across a set of pools.
* @param poolAddresses the addresses of the Whirlpool account addresses to route through
* @returns a {@link WhirlpoolRouter} instance
*/
getRouter: (poolAddresses: Address[]) => Promise<WhirlpoolRouter>;
/**
* Get a Whirlpool object to interact with the Whirlpool account at the given address.

@@ -86,3 +91,2 @@ * @param poolAddress the address of the Whirlpool account

collectProtocolFeesForPools: (poolAddresses: Address[]) => Promise<TransactionBuilder>;
swapWithRoute: (route: WhirlpoolRoute, slippage: Percentage, atas: AccountInfo[] | null, wallet: PublicKey, payer?: PublicKey) => Promise<TransactionBuilder>;
}

@@ -89,0 +93,0 @@ /**

{
"name": "@orca-so/whirlpools-sdk",
"version": "0.9.0-alpha.7",
"version": "0.10.0-beta.1",
"description": "Typescript SDK to interact with Orca's Whirlpool program.",

@@ -9,8 +9,9 @@ "license": "Apache-2.0",

"dependencies": {
"@coral-xyz/anchor": "~0.27.0",
"@metaplex-foundation/mpl-token-metadata": "1.2.5",
"@orca-so/common-sdk": "^0.1.12",
"@project-serum/anchor": "~0.25.0",
"@orca-so/common-sdk": "0.2.0-beta.1",
"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "^1.66.0",
"@solana/web3.js": "~1.74.0",
"decimal.js": "^10.3.1",
"lodash.combinations": "^18.11.1",
"tiny-invariant": "^1.2.0"

@@ -28,6 +29,6 @@ },

"process": "^0.11.10",
"ts-mocha": "^9.0.0",
"ts-node": "^10.9.1",
"typedoc": "~0.22.18",
"typescript": "^4.5.5",
"ts-mocha": "^9.0.0",
"ts-node": "^10.9.1"
"typescript": "^4.5.5"
},

@@ -46,2 +47,3 @@ "scripts": {

"files": [
".yalc",
"/dist"

@@ -53,5 +55,2 @@ ],

},
"resolutions": {
"@solana/web3.js": "^1.66.2"
},
"keywords": [

@@ -58,0 +57,0 @@ "orca_so",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc