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

@orca-so/sdk

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orca-so/sdk - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

7

dist/constants/orca-defaults.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultSlippagePercentage = void 0;
const spl_token_1 = require("@solana/spl-token");
exports.defaultSlippagePercentage = {
numerator: new spl_token_1.u64(1),
denominator: new spl_token_1.u64(1000),
}; // 0.1%
const percentage_1 = require("../public/utils/models/percentage");
exports.defaultSlippagePercentage = percentage_1.Percentage.fromFraction(1, 1000); // 0.1%

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

const config_1 = require("../public/pools/config");
const percentage_utils_1 = require("../public/utils/percentage-utils");
const percentage_1 = require("../public/utils/models/percentage");
/**

@@ -57,4 +57,4 @@ * Constants

feeStructure: {
traderFee: percentage_utils_1.PercentageUtils.fromFraction(2, 1000),
ownerFee: percentage_utils_1.PercentageUtils.fromFraction(1, 1000),
traderFee: percentage_1.Percentage.fromFraction(2, 1000),
ownerFee: percentage_1.Percentage.fromFraction(1, 1000),
},

@@ -76,4 +76,4 @@ });

feeStructure: {
traderFee: percentage_utils_1.PercentageUtils.fromFraction(2, 1000),
ownerFee: percentage_utils_1.PercentageUtils.fromFraction(1, 1000),
traderFee: percentage_1.Percentage.fromFraction(2, 1000),
ownerFee: percentage_1.Percentage.fromFraction(1, 1000),
},

@@ -95,4 +95,4 @@ });

feeStructure: {
traderFee: percentage_utils_1.PercentageUtils.fromFraction(2, 1000),
ownerFee: percentage_utils_1.PercentageUtils.fromFraction(1, 1000),
traderFee: percentage_1.Percentage.fromFraction(2, 1000),
ownerFee: percentage_1.Percentage.fromFraction(1, 1000),
},

@@ -114,4 +114,4 @@ });

feeStructure: {
traderFee: percentage_utils_1.PercentageUtils.fromFraction(2, 1000),
ownerFee: percentage_utils_1.PercentageUtils.fromFraction(1, 1000),
traderFee: percentage_1.Percentage.fromFraction(2, 1000),
ownerFee: percentage_1.Percentage.fromFraction(1, 1000),
},

@@ -133,4 +133,4 @@ });

feeStructure: {
traderFee: percentage_utils_1.PercentageUtils.fromFraction(2, 1000),
ownerFee: percentage_utils_1.PercentageUtils.fromFraction(1, 1000),
traderFee: percentage_1.Percentage.fromFraction(2, 1000),
ownerFee: percentage_1.Percentage.fromFraction(1, 1000),
},

@@ -137,0 +137,0 @@ });

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

const orca_defaults_1 = require("../../../constants/orca-defaults");
const percentage_utils_1 = require("../../../public/utils/percentage-utils");
const public_1 = require("../../../public");

@@ -68,3 +67,3 @@ const pool_instructions_1 = require("../../../public/utils/web3/instructions/pool-instructions");

return __awaiter(this, void 0, void 0, function* () {
const slippageTolerance = slippage === undefined ? orca_defaults_1.defaultSlippagePercentage : percentage_utils_1.PercentageUtils.fromDecimal(slippage);
const slippageTolerance = slippage === undefined ? orca_defaults_1.defaultSlippagePercentage : public_1.Percentage.fromDecimal(slippage);
const feeStructure = this.poolParams.feeStructure;

@@ -71,0 +70,0 @@ const { inputPoolToken, outputPoolToken } = public_1.getTokens(this.poolParams, inputToken.mint.toString());

@@ -7,2 +7,1 @@ export * from "./constants";

export * from "./web3";
export * from "./percentage-utils";

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

__exportStar(require("./web3"), exports);
__exportStar(require("./percentage-utils"), exports);
import { u64 } from "@solana/spl-token";
export declare type Percentage = {
numerator: u64;
denominator: u64;
};
import Decimal from "decimal.js";
export declare class Percentage {
readonly numerator: u64;
readonly denominator: u64;
constructor(numerator: u64, denominator: u64);
static fromDecimal(number: Decimal): Percentage;
static fromFraction(numerator: u64 | number, denominator: u64 | number): Percentage;
toString: () => string;
toDecimal(): Decimal;
add(p2: Percentage): Percentage;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Percentage = void 0;
const spl_token_1 = require("@solana/spl-token");
const decimal_js_1 = __importDefault(require("decimal.js"));
const __1 = require("..");
class Percentage {
constructor(numerator, denominator) {
this.toString = () => {
return `${this.numerator.toString()}/${this.denominator.toString()}`;
};
this.numerator = numerator;
this.denominator = denominator;
}
static fromDecimal(number) {
return Percentage.fromFraction(number.toDecimalPlaces(1).mul(10).toNumber(), 1000);
}
static fromFraction(numerator, denominator) {
const num = typeof numerator === "number" ? new spl_token_1.u64(numerator.toString()) : numerator;
const denom = typeof denominator === "number" ? new spl_token_1.u64(denominator.toString()) : denominator;
return new Percentage(num, denom);
}
toDecimal() {
if (this.denominator.eq(__1.ZERO)) {
return new decimal_js_1.default(0);
}
return new decimal_js_1.default(this.numerator.toString()).div(new decimal_js_1.default(this.denominator.toString()));
}
add(p2) {
const denomGcd = this.denominator.gcd(p2.denominator);
const denomLcm = this.denominator.div(denomGcd).mul(p2.denominator);
const p1DenomAdjustment = denomLcm.div(this.denominator);
const p2DenomAdjustment = denomLcm.div(p2.denominator);
const p1NumeratorAdjusted = this.numerator.mul(p1DenomAdjustment);
const p2NumeratorAdjusted = p2.numerator.mul(p2DenomAdjustment);
const newNumerator = p1NumeratorAdjusted.add(p2NumeratorAdjusted);
return new Percentage(new spl_token_1.u64(newNumerator.toString()), new spl_token_1.u64(denomLcm.toString()));
}
}
exports.Percentage = Percentage;
{
"name": "@orca-so/sdk",
"version": "1.0.3",
"version": "1.0.4",
"description": "Typescript SDK for the Orca protocol.",

@@ -10,3 +10,3 @@ "main": "dist/index.js",

"@solana/spl-token": "^0.1.5",
"@solana/spl-token-swap": "0.1.0",
"@solana/spl-token-swap": "^0.1.2",
"@solana/web3.js": "^1.17.0",

@@ -13,0 +13,0 @@ "decimal.js": "^10.3.1"

@@ -61,3 +61,3 @@ # Orca Typescript SDK

// Perform a swap for 1USDC to the quoted minimum amount of ETH
const txId = await pool.swap(owner, usdcToken, tradeValue, quote.getMinOutputAmount());
const txId = await pool.swap(owner, usdcToken, tradeValue, quote.getMinOutputAmount()).execute();
} catch (err) {

@@ -71,7 +71,13 @@ // Handle errors

**Decimals & OrcaU64**
The SDK relies on the use of [Decimal](https://github.com/MikeMcl/decimal.js/) for number inputs and Decimal/[OrcaU64](https://github.com/orca-so/typescript-sdk/blob/main/src/public/utils/orca-u64.ts) for token-value inputs. If a Decimal instance is provided for a token-value input, it will be automatically transformed to the token's scale.
**Funding Associated Token Addresses**
The swap() function assumes the owner keypair address has already created & initialized the [associated token addresses](https://spl.solana.com/associated-token-account) for the trading pair tokens. The swap will fail if this is not the case.
**Stability of the Public Util Functions**
We hope you find the tools we used to build our API useful in the public/utils folder. Due to our on-going development of the Orca platform, we cannot guarrantee the stability of the util APIs. The trading APIs can only be upgraded on major version updates.
# Support

@@ -78,0 +84,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