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

@dahlia-labs/stableswap-sdk

Package Overview
Dependencies
Maintainers
3
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dahlia-labs/stableswap-sdk - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

8

dist/cjs/calculator/amounts.d.ts

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

import JSBI from 'jsbi';
import type { Token } from '@dahlia-labs/token-utils';
import { Fraction, TokenAmount } from '@dahlia-labs/token-utils';
import { Fees, IExchangeInfo } from '../entities';
import type { Token } from "@dahlia-labs/token-utils";
import { Fraction, TokenAmount } from "@dahlia-labs/token-utils";
import JSBI from "jsbi";
import type { Fees, IExchangeInfo } from "../entities";
/**

@@ -6,0 +6,0 @@ * Calculates the current virtual price of the exchange.

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

const tslib_1 = require("tslib");
const token_utils_1 = require("@dahlia-labs/token-utils");
const jsbi_1 = (0, tslib_1.__importDefault)(require("jsbi"));
const token_utils_1 = require("@dahlia-labs/token-utils");
const lodash_mapvalues_1 = (0, tslib_1.__importDefault)(require("lodash.mapvalues"));

@@ -176,6 +176,9 @@ const curve_1 = require("./curve");

if (jsbi_1.default.lessThan(d1, d0)) {
throw new Error('New D cannot be less than previous D');
throw new Error("New D cannot be less than previous D");
}
const oldBalances = exchange.reserves.map((r) => r.raw);
const newBalances = [jsbi_1.default.add(reserveA.raw, depositAmountA), jsbi_1.default.add(reserveB.raw, depositAmountB)];
const newBalances = [
jsbi_1.default.add(reserveA.raw, depositAmountA),
jsbi_1.default.add(reserveB.raw, depositAmountB),
];
const adjustedBalances = newBalances.map((newBalance, i) => {

@@ -185,3 +188,5 @@ const oldBalance = oldBalances[i];

const difference = idealBalance.subtract(newBalance);
const diffAbs = difference.greaterThan(0) ? difference : difference.multiply(-1);
const diffAbs = difference.greaterThan(0)
? difference
: difference.multiply(-1);
const fee = (0, exports.normalizedTradeFee)(exchange.fees, N_COINS, jsbi_1.default.BigInt(diffAbs.toFixed(0)));

@@ -188,0 +193,0 @@ return jsbi_1.default.subtract(newBalance, jsbi_1.default.BigInt(fee.toFixed(0)));

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

import JSBI from 'jsbi';
import JSBI from "jsbi";
/**

@@ -3,0 +3,0 @@ * Compute the StableSwap invariant

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

const tslib_1 = require("tslib");
const token_utils_1 = require("@dahlia-labs/token-utils");
const jsbi_1 = (0, tslib_1.__importDefault)(require("jsbi"));
const token_utils_1 = require("@dahlia-labs/token-utils");
const N_COINS = jsbi_1.default.BigInt(2); // n

@@ -9,0 +9,0 @@ const abs = (a) => {

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

export * from './amounts';
export * from './curve';
export * from './price';
export * from "./amounts";
export * from "./curve";
export * from "./price";
//# sourceMappingURL=index.d.ts.map

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

import type { IExchangeInfo } from '../entities';
import { Price } from '@dahlia-labs/token-utils';
import { Price } from "@dahlia-labs/token-utils";
import type { IExchangeInfo } from "../entities";
/**

@@ -4,0 +4,0 @@ * Gets the price of the second token in the swap, i.e. "Token 1", with respect to "Token 0".

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

const tslib_1 = require("tslib");
const token_utils_1 = require("@dahlia-labs/token-utils");
const jsbi_1 = (0, tslib_1.__importDefault)(require("jsbi"));
const token_utils_1 = require("@dahlia-labs/token-utils");
const _1 = require("./");

@@ -9,0 +9,0 @@ function min(a, b) {

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

import { Percent, Token, TokenAmount } from "@dahlia-labs/token-utils";
import type { Token, TokenAmount } from "@dahlia-labs/token-utils";
import { Percent } from "@dahlia-labs/token-utils";
import JSBI from "jsbi";

@@ -3,0 +4,0 @@ export declare type Fees = {

@@ -8,10 +8,10 @@ "use strict";

const recommendedFeesRaw = {
adminFeeNumerator: '50',
adminFeeDenominator: '100',
depositFeeNumerator: '50',
depositFeeDenominator: '100',
tradeFeeNumerator: '20',
tradeFeeDenominator: '10000',
withdrawFeeNumerator: '50',
withdrawFeeDenominator: '10000',
adminFeeNumerator: "50",
adminFeeDenominator: "100",
depositFeeNumerator: "50",
depositFeeDenominator: "100",
tradeFeeNumerator: "20",
tradeFeeDenominator: "10000",
withdrawFeeNumerator: "50",
withdrawFeeDenominator: "10000",
};

@@ -24,3 +24,3 @@ exports.RECOMMENDED_FEES = {

};
exports.RECOMMENDED_AMP = jsbi_1.default.BigInt('100');
exports.RECOMMENDED_AMP = jsbi_1.default.BigInt("100");
//# sourceMappingURL=exchange.js.map

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

import JSBI from 'jsbi';
import type { Token } from '@dahlia-labs/token-utils';
import { Fraction, TokenAmount } from '@dahlia-labs/token-utils';
import { Fees, IExchangeInfo } from '../entities';
import type { Token } from "@dahlia-labs/token-utils";
import { Fraction, TokenAmount } from "@dahlia-labs/token-utils";
import JSBI from "jsbi";
import type { Fees, IExchangeInfo } from "../entities";
/**

@@ -6,0 +6,0 @@ * Calculates the current virtual price of the exchange.

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

import JSBI from 'jsbi';
import { Fraction, ONE, TokenAmount, ZERO } from '@dahlia-labs/token-utils';
import mapValues from 'lodash.mapvalues';
import { computeD, computeY } from './curve';
import { Fraction, ONE, TokenAmount, ZERO } from "@dahlia-labs/token-utils";
import JSBI from "jsbi";
import mapValues from "lodash.mapvalues";
import { computeD, computeY } from "./curve";
/**

@@ -166,6 +166,9 @@ * Calculates the current virtual price of the exchange.

if (JSBI.lessThan(d1, d0)) {
throw new Error('New D cannot be less than previous D');
throw new Error("New D cannot be less than previous D");
}
const oldBalances = exchange.reserves.map((r) => r.raw);
const newBalances = [JSBI.add(reserveA.raw, depositAmountA), JSBI.add(reserveB.raw, depositAmountB)];
const newBalances = [
JSBI.add(reserveA.raw, depositAmountA),
JSBI.add(reserveB.raw, depositAmountB),
];
const adjustedBalances = newBalances.map((newBalance, i) => {

@@ -175,3 +178,5 @@ const oldBalance = oldBalances[i];

const difference = idealBalance.subtract(newBalance);
const diffAbs = difference.greaterThan(0) ? difference : difference.multiply(-1);
const diffAbs = difference.greaterThan(0)
? difference
: difference.multiply(-1);
const fee = normalizedTradeFee(exchange.fees, N_COINS, JSBI.BigInt(diffAbs.toFixed(0)));

@@ -178,0 +183,0 @@ return JSBI.subtract(newBalance, JSBI.BigInt(fee.toFixed(0)));

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

import JSBI from 'jsbi';
import JSBI from "jsbi";
/**

@@ -3,0 +3,0 @@ * Compute the StableSwap invariant

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

import JSBI from 'jsbi';
import { ONE, ZERO } from '@dahlia-labs/token-utils';
import { ONE, ZERO } from "@dahlia-labs/token-utils";
import JSBI from "jsbi";
const N_COINS = JSBI.BigInt(2); // n

@@ -4,0 +4,0 @@ const abs = (a) => {

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

export * from './amounts';
export * from './curve';
export * from './price';
export * from "./amounts";
export * from "./curve";
export * from "./price";
//# sourceMappingURL=index.d.ts.map

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

export * from './amounts';
export * from './curve';
export * from './price';
export * from "./amounts";
export * from "./curve";
export * from "./price";
//# sourceMappingURL=index.js.map

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

import type { IExchangeInfo } from '../entities';
import { Price } from '@dahlia-labs/token-utils';
import { Price } from "@dahlia-labs/token-utils";
import type { IExchangeInfo } from "../entities";
/**

@@ -4,0 +4,0 @@ * Gets the price of the second token in the swap, i.e. "Token 1", with respect to "Token 0".

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

import JSBI from 'jsbi';
import { Price, TEN, TokenAmount } from '@dahlia-labs/token-utils';
import { calculateEstimatedSwapOutputAmount } from './';
import { Price, TEN, TokenAmount } from "@dahlia-labs/token-utils";
import JSBI from "jsbi";
import { calculateEstimatedSwapOutputAmount } from "./";
function min(a, b) {

@@ -5,0 +5,0 @@ return JSBI.greaterThanOrEqual(a, b) ? b : a;

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

import { Percent, Token, TokenAmount } from "@dahlia-labs/token-utils";
import type { Token, TokenAmount } from "@dahlia-labs/token-utils";
import { Percent } from "@dahlia-labs/token-utils";
import JSBI from "jsbi";

@@ -3,0 +4,0 @@ export declare type Fees = {

@@ -1,12 +0,12 @@

import { Percent, } from "@dahlia-labs/token-utils";
import { Percent } from "@dahlia-labs/token-utils";
import JSBI from "jsbi";
const recommendedFeesRaw = {
adminFeeNumerator: '50',
adminFeeDenominator: '100',
depositFeeNumerator: '50',
depositFeeDenominator: '100',
tradeFeeNumerator: '20',
tradeFeeDenominator: '10000',
withdrawFeeNumerator: '50',
withdrawFeeDenominator: '10000',
adminFeeNumerator: "50",
adminFeeDenominator: "100",
depositFeeNumerator: "50",
depositFeeDenominator: "100",
tradeFeeNumerator: "20",
tradeFeeDenominator: "10000",
withdrawFeeNumerator: "50",
withdrawFeeDenominator: "10000",
};

@@ -19,3 +19,3 @@ export const RECOMMENDED_FEES = {

};
export const RECOMMENDED_AMP = JSBI.BigInt('100');
export const RECOMMENDED_AMP = JSBI.BigInt("100");
//# sourceMappingURL=exchange.js.map

@@ -10,3 +10,3 @@ {

],
"version": "0.1.0",
"version": "0.1.2",
"repository": {

@@ -40,3 +40,3 @@ "type": "git",

"dependencies": {
"@dahlia-labs/token-utils": "^0.1.0",
"@dahlia-labs/token-utils": "^0.1.2",
"@saberhq/tsconfig": "^1.12.59",

@@ -62,3 +62,3 @@ "lodash.mapvalues": "^4.6.0",

},
"gitHead": "e5e7575a6d93fae2c2d8454cea35c8de3164090c"
"gitHead": "c3eb9be3fb18c8f48d0654fe0f429ae5e2e23ed8"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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