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.1 to 0.9.0-alpha.2

10

dist/errors/errors.d.ts

@@ -22,8 +22,14 @@ export declare enum MathErrorCode {

}
export type WhirlpoolsErrorCode = TokenErrorCode | SwapErrorCode | MathErrorCode;
export declare enum RouteQueryErrorCode {
ROUTE_DOES_NOT_EXIST = "ROUTE_DOES_NOT_EXIST",
TRADE_AMOUNT_TOO_HIGH = "TRADE_AMOUNT_TOO_HIGH",
ZERO_INPUT_AMOUNT = "ZERO_INPUT_AMOUNT",
GENERAL = "GENERAL"
}
export type WhirlpoolsErrorCode = TokenErrorCode | SwapErrorCode | MathErrorCode | RouteQueryErrorCode;
export declare class WhirlpoolsError extends Error {
message: string;
errorCode?: WhirlpoolsErrorCode;
constructor(message: string, errorCode?: WhirlpoolsErrorCode);
constructor(message: string, errorCode?: WhirlpoolsErrorCode, stack?: string);
static isWhirlpoolsErrorCode(e: any, code: WhirlpoolsErrorCode): boolean;
}

12

dist/errors/errors.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WhirlpoolsError = exports.SwapErrorCode = exports.TokenErrorCode = exports.MathErrorCode = void 0;
exports.WhirlpoolsError = exports.RouteQueryErrorCode = exports.SwapErrorCode = exports.TokenErrorCode = exports.MathErrorCode = void 0;
var MathErrorCode;

@@ -28,7 +28,15 @@ (function (MathErrorCode) {

})(SwapErrorCode = exports.SwapErrorCode || (exports.SwapErrorCode = {}));
var RouteQueryErrorCode;
(function (RouteQueryErrorCode) {
RouteQueryErrorCode["ROUTE_DOES_NOT_EXIST"] = "ROUTE_DOES_NOT_EXIST";
RouteQueryErrorCode["TRADE_AMOUNT_TOO_HIGH"] = "TRADE_AMOUNT_TOO_HIGH";
RouteQueryErrorCode["ZERO_INPUT_AMOUNT"] = "ZERO_INPUT_AMOUNT";
RouteQueryErrorCode["GENERAL"] = "GENERAL";
})(RouteQueryErrorCode = exports.RouteQueryErrorCode || (exports.RouteQueryErrorCode = {}));
class WhirlpoolsError extends Error {
constructor(message, errorCode) {
constructor(message, errorCode, stack) {
super(message);
this.message = message;
this.errorCode = errorCode;
this.stack = stack;
}

@@ -35,0 +43,0 @@ static isWhirlpoolsErrorCode(e, code) {

@@ -11,18 +11,2 @@ import { Address } from "@project-serum/anchor";

};
export type BestRoutesResult = BestRoutesSuccess | BestRoutesError;
type BestRoutesSuccess = {
success: true;
bestRoutes: WhirlpoolRoute[];
};
type BestRoutesError = {
success: false;
error: RouteQueryError;
stack?: string;
};
export declare enum RouteQueryError {
ROUTE_DOES_NOT_EXIST = "ROUTE_DOES_NOT_EXIST",
TRADE_AMOUNT_TOO_HIGH = "TRADE_AMOUNT_TOO_HIGH",
ZERO_INPUT_AMOUNT = "ZERO_INPUT_AMOUNT",
GENERAL = "GENERAL"
}
export type RouteQuote = Omit<InternalRouteQuote, "calculatedHops"> & {

@@ -45,2 +29,1 @@ calculatedHops: RouteHop[];

};
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RouteQueryError = void 0;
var RouteQueryError;
(function (RouteQueryError) {
RouteQueryError["ROUTE_DOES_NOT_EXIST"] = "ROUTE_DOES_NOT_EXIST";
RouteQueryError["TRADE_AMOUNT_TOO_HIGH"] = "TRADE_AMOUNT_TOO_HIGH";
RouteQueryError["ZERO_INPUT_AMOUNT"] = "ZERO_INPUT_AMOUNT";
RouteQueryError["GENERAL"] = "GENERAL";
})(RouteQueryError = exports.RouteQueryError || (exports.RouteQueryError = {}));

@@ -5,3 +5,3 @@ import { Address } from "@project-serum/anchor";

import { PoolWalks, TokenPairPool } from "./pool-graph";
import { BestRoutesResult } from "./smart-swap-types";
import { WhirlpoolRoute } from "./smart-swap-types";
export interface RoutingOptions {

@@ -31,2 +31,2 @@ /**

};
export declare function findBestRoutes(inputTokenMint: string, outputTokenMint: string, tradeAmount: u64, amountSpecifiedIsInput: boolean, walks: PoolWalks, pools: Record<string, TokenPairPool>, programId: Address, fetcher: AccountFetcher, userRoutingOptions?: Partial<RoutingOptions>): Promise<BestRoutesResult>;
export declare function findBestRoutes(inputTokenMint: string, outputTokenMint: string, tradeAmount: u64, amountSpecifiedIsInput: boolean, walks: PoolWalks, pools: Record<string, TokenPairPool>, programId: Address, fetcher: AccountFetcher, userRoutingOptions?: Partial<RoutingOptions>): Promise<WhirlpoolRoute[]>;

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

const pool_graph_1 = require("./pool-graph");
const smart_swap_types_1 = require("./smart-swap-types");
const swap_quote_1 = require("./swap-quote");

@@ -33,12 +32,6 @@ exports.DEFAULT_ROUTING_OPTIONS = {

if (!pairRoutes) {
return Promise.reject({
success: false,
error: smart_swap_types_1.RouteQueryError.ROUTE_DOES_NOT_EXIST,
});
return Promise.reject(new errors_1.WhirlpoolsError(`findBestRoutes error - Could not find route for ${inputTokenMint} -> ${outputTokenMint}`, errors_1.RouteQueryErrorCode.ROUTE_DOES_NOT_EXIST));
}
if (tradeAmount.isZero()) {
return Promise.reject({
success: false,
error: smart_swap_types_1.RouteQueryError.ZERO_INPUT_AMOUNT,
});
return Promise.reject(new errors_1.WhirlpoolsError(`findBestRoutes error - input amount is zero.`, errors_1.RouteQueryErrorCode.ZERO_INPUT_AMOUNT));
}

@@ -68,7 +61,3 @@ const routingOptions = Object.assign(Object.assign({}, exports.DEFAULT_ROUTING_OPTIONS), userRoutingOptions);

catch (e) {
return {
success: false,
error: smart_swap_types_1.RouteQueryError.GENERAL,
stack: e.stack,
};
return Promise.reject(new errors_1.WhirlpoolsError(`findBestRoutes error - stack error received on quote generation.`, errors_1.RouteQueryErrorCode.GENERAL, e.stack));
}

@@ -85,12 +74,6 @@ const [cleanedQuoteMap, failures] = categorizeQuotes(tradeAmount, amountSpecifiedIsInput, quoteMap);

if (failures.has(errors_1.SwapErrorCode.TickArraySequenceInvalid)) {
return {
success: false,
error: smart_swap_types_1.RouteQueryError.TRADE_AMOUNT_TOO_HIGH,
};
return Promise.reject(new errors_1.WhirlpoolsError(`findBestRoutes error - all swap quote generation failed on amount too high.`, errors_1.RouteQueryErrorCode.TRADE_AMOUNT_TOO_HIGH));
}
}
return {
success: true,
bestRoutes,
};
return bestRoutes;
});

@@ -97,0 +80,0 @@ }

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

@@ -5,0 +5,0 @@ "license": "Apache-2.0",

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