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
4
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.2.2 to 0.2.3

2

dist/impl/whirlpool-impl.d.ts

@@ -31,3 +31,3 @@ import { Percentage, TransactionBuilder } from "@orca-so/common-sdk";

}>;
initTickArrayForTicks(ticks: number[], funder?: Address): TransactionBuilder;
initTickArrayForTicks(ticks: number[], funder?: Address, refresh?: boolean): Promise<TransactionBuilder | null>;
closePosition(positionAddress: Address, slippageTolerance: Percentage, destinationWallet?: Address, positionWallet?: Address, payer?: Address): Promise<TransactionBuilder>;

@@ -34,0 +34,0 @@ swap(quote: SwapQuote, sourceWallet?: Address): Promise<TransactionBuilder>;

@@ -75,20 +75,19 @@ "use strict";

}
initTickArrayForTicks(ticks, funder) {
const startTicks = ticks.map((tick) => public_2.TickUtil.getStartTickIndex(tick, this.data.tickSpacing));
const tx = new common_sdk_1.TransactionBuilder(this.ctx.provider);
const initializedArrayTicks = [];
startTicks.forEach((startTick) => {
if (initializedArrayTicks.includes(startTick)) {
return;
initTickArrayForTicks(ticks, funder, refresh = true) {
return __awaiter(this, void 0, void 0, function* () {
const initTickArrayStartPdas = yield public_2.TickArrayUtil.getUninitializedArraysPDAs(ticks, this.ctx.program.programId, this.address, this.data.tickSpacing, this.fetcher, refresh);
if (!initTickArrayStartPdas.length) {
return null;
}
initializedArrayTicks.push(startTick);
const tickArrayPda = public_2.PDAUtil.getTickArray(this.ctx.program.programId, this.address, startTick);
tx.addInstruction((0, instructions_1.initTickArrayIx)(this.ctx.program, {
startTick,
tickArrayPda,
whirlpool: this.address,
funder: !!funder ? common_sdk_1.AddressUtil.toPubKey(funder) : this.ctx.wallet.publicKey,
}));
const txBuilder = new common_sdk_1.TransactionBuilder(this.ctx.provider);
initTickArrayStartPdas.forEach((initTickArrayInfo) => {
txBuilder.addInstruction((0, instructions_1.initTickArrayIx)(this.ctx.program, {
startTick: initTickArrayInfo.startIndex,
tickArrayPda: initTickArrayInfo.pda,
whirlpool: this.address,
funder: !!funder ? common_sdk_1.AddressUtil.toPubKey(funder) : this.ctx.provider.wallet.publicKey,
}));
});
return txBuilder;
});
return tx;
}

@@ -158,5 +157,2 @@ closePosition(positionAddress, slippageTolerance, destinationWallet, positionWallet, payer) {

const tickArrayUpperPda = public_2.PDAUtil.getTickArrayFromTickIndex(tickUpper, this.data.tickSpacing, this.address, this.ctx.program.programId);
const [tickArrayLower, tickArrayUpper] = yield this.fetcher.listTickArrays([tickArrayLowerPda.publicKey, tickArrayUpperPda.publicKey], true);
(0, tiny_invariant_1.default)(!!tickArrayLower, "tickArray for the tickLower has not been initialized");
(0, tiny_invariant_1.default)(!!tickArrayUpper, "tickArray for the tickUpper has not been initialized");
const liquidityIx = (0, instructions_1.increaseLiquidityIx)(this.ctx.program, {

@@ -163,0 +159,0 @@ liquidityAmount: liquidity,

import { PublicKey } from "@solana/web3.js";
import { TickArrayData, TickData } from "../../types/public";
import { AccountFetcher } from "../../network/public";
/**

@@ -65,2 +66,6 @@ * A collection of utility functions when interacting with Ticks.

static getAdjacentTickArrays(tickLowerIndex: number, tickUpperIndex: number, tickSpacing: number, whirlpool: PublicKey, programId: PublicKey): [PublicKey, PublicKey];
static getUninitializedArraysPDAs(ticks: number[], programId: PublicKey, whirlpoolAddress: PublicKey, tickSpacing: number, fetcher: AccountFetcher, refresh: boolean): Promise<{
startIndex: number;
pda: import("@orca-so/common-sdk").PDA;
}[]>;
/**

@@ -67,0 +72,0 @@ * Evaluate a list of tick-array data and return the array of indices which the tick-arrays are not initialized.

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -127,2 +136,17 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

}
static getUninitializedArraysPDAs(ticks, programId, whirlpoolAddress, tickSpacing, fetcher, refresh) {
return __awaiter(this, void 0, void 0, function* () {
const startTicks = ticks.map((tick) => TickUtil.getStartTickIndex(tick, tickSpacing));
const removeDupeTicks = [...new Set(startTicks)];
const tickArrayPDAs = removeDupeTicks.map((tick) => pda_utils_1.PDAUtil.getTickArray(programId, whirlpoolAddress, tick));
const fetchedArrays = yield fetcher.listTickArrays(tickArrayPDAs.map((pda) => pda.publicKey), refresh);
const uninitializedIndices = TickArrayUtil.getUninitializedArrays(fetchedArrays);
return uninitializedIndices.map((index) => {
return {
startIndex: removeDupeTicks[index],
pda: tickArrayPDAs[index],
};
});
});
}
/**

@@ -129,0 +153,0 @@ * Evaluate a list of tick-array data and return the array of indices which the tick-arrays are not initialized.

@@ -73,13 +73,12 @@ import { Percentage, TransactionBuilder } from "@orca-so/common-sdk";

/**
* Initialize a set of tick-arrays to support the provided ticks.
* Initialize a set of tick-arrays that encompasses the provided ticks.
*
* This function does not ensure the provided tick index are within range and not initialized.
*
* If `funder` is provided, the funder wallet has to sign this transaction.
*
* @param ticks - A group of ticks that define the desired tick-arrays to initialize
* @param ticks - A group of ticks that define the desired tick-arrays to initialize. If the tick's array has been initialized, it will be ignored.
* @param funder - optional - the wallet that will fund the cost needed to initialize the position. If null, the WhirlpoolContext wallet is used.
* @return a transaction that will initialize the defined tick-arrays if executed.
* @param refresh - optional - whether this operation will fetch for the latest accounts if a cache version is available.
* @return a transaction that will initialize the defined tick-arrays if executed. Return null if all of the tick's arrays are initialized.
*/
initTickArrayForTicks: (ticks: number[], funder?: Address) => TransactionBuilder;
initTickArrayForTicks: (ticks: number[], funder?: Address, refresh?: boolean) => Promise<TransactionBuilder | null>;
/**

@@ -86,0 +85,0 @@ * Open and fund a position on this Whirlpool.

{
"name": "@orca-so/whirlpools-sdk",
"version": "0.2.2",
"version": "0.2.3",
"description": "Typescript SDK to interact with Orca's Whirlpool program.",

@@ -10,3 +10,3 @@ "license": "Apache-2.0",

"@metaplex-foundation/mpl-token-metadata": "1.2.5",
"@orca-so/common-sdk": "^0.0.6",
"@orca-so/common-sdk": "^0.0.7",
"@project-serum/anchor": "^0.20.1",

@@ -13,0 +13,0 @@ "@solana/spl-token": "^0.1.8",

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