@saberhq/stableswap-sdk
Advanced tools
Comparing version 1.0.0-alpha.29 to 1.0.0-alpha.30
@@ -34,3 +34,3 @@ "use strict"; | ||
const calculateEstimatedSwapOutputAmount = (exchange, fromAmount) => { | ||
const [fromReserves, toReserves] = spl_token_1.tokensEqual(fromAmount.token, exchange.reserves[0].amount.token) | ||
const [fromReserves, toReserves] = fromAmount.token === exchange.reserves[0].amount.token | ||
? [exchange.reserves[0], exchange.reserves[1]] | ||
@@ -37,0 +37,0 @@ : [exchange.reserves[1], exchange.reserves[0]]; |
@@ -16,2 +16,4 @@ "use strict"; | ||
}; | ||
// maximum iterations of newton's method approximation | ||
const MAX_ITERS = 20; | ||
/** | ||
@@ -32,3 +34,3 @@ * Compute the StableSwap invariant | ||
let d = S; | ||
while (jsbi_1.default.greaterThan(abs(jsbi_1.default.subtract(d, dPrev)), spl_token_1.ONE)) { | ||
for (let i = 0; jsbi_1.default.greaterThan(abs(jsbi_1.default.subtract(d, dPrev)), spl_token_1.ONE) && i < MAX_ITERS; i++) { | ||
dPrev = d; | ||
@@ -60,3 +62,3 @@ let dP = d; | ||
let y = d; | ||
while (jsbi_1.default.greaterThan(abs(jsbi_1.default.subtract(y, yPrev)), spl_token_1.ONE)) { | ||
for (let i = 0; i < MAX_ITERS && jsbi_1.default.greaterThan(abs(jsbi_1.default.subtract(y, yPrev)), spl_token_1.ONE); i++) { | ||
yPrev = y; | ||
@@ -63,0 +65,0 @@ y = jsbi_1.default.divide(jsbi_1.default.add(jsbi_1.default.multiply(y, y), c), jsbi_1.default.add(jsbi_1.default.multiply(N_COINS, y), b)); |
{ | ||
"name": "@saberhq/stableswap-sdk", | ||
"version": "1.0.0-alpha.29", | ||
"version": "1.0.0-alpha.30", | ||
"main": "lib/index.js", | ||
@@ -51,3 +51,3 @@ "types": "lib/index.d.ts", | ||
"dependencies": { | ||
"@saberhq/spl-token": "^0.1.0-beta.8", | ||
"@saberhq/spl-token": "^0.1.0-beta.7", | ||
"@types/bn.js": "^5.1.0", | ||
@@ -54,0 +54,0 @@ "@types/yargs": "^17.0.0", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
299921
2899