New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

crosslightning-intermediary

Package Overview
Dependencies
Maintainers
1
Versions
233
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crosslightning-intermediary - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

4

dist/prices/CoinGeckoSwapPrice.d.ts

@@ -44,4 +44,4 @@ import * as BN from "bn.js";

getPrice(coinId: string): Promise<BN>;
getFromBtcSwapAmount(fromAmount: BN, toToken: TokenAddress): Promise<BN>;
getToBtcSwapAmount(fromAmount: BN, fromToken: TokenAddress): Promise<BN>;
getFromBtcSwapAmount(fromAmount: BN, toToken: TokenAddress, roundUp?: boolean): Promise<BN>;
getToBtcSwapAmount(fromAmount: BN, fromToken: TokenAddress, roundUp?: boolean): Promise<BN>;
}

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

}
getFromBtcSwapAmount(fromAmount, toToken) {
getFromBtcSwapAmount(fromAmount, toToken, roundUp) {
return __awaiter(this, void 0, void 0, function* () {

@@ -117,7 +117,7 @@ let tokenAddress = toToken.toString();

.mul(new BN(1000)) //To msat
.add(price.sub(new BN(1)))
.add(roundUp ? price.sub(new BN(1)) : new BN(0))
.div(price);
});
}
getToBtcSwapAmount(fromAmount, fromToken) {
getToBtcSwapAmount(fromAmount, fromToken, roundUp) {
return __awaiter(this, void 0, void 0, function* () {

@@ -132,3 +132,3 @@ let tokenAddress = fromToken.toString();

.div(new BN(10).pow(new BN(coin.decimals)))
.add(new BN(999))
.add(roundUp ? new BN(999) : new BN(0))
.div(new BN(1000));

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

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

const amountInToken = yield this.swapPricing.getFromBtcSwapAmount(parsedBody.amount, useToken);
const swapFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(swapFee, useToken);
const swapFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(swapFee, useToken, true);
const balance = yield this.swapContract.getBalance(useToken, true);

@@ -271,3 +271,3 @@ if (amountInToken.sub(swapFeeInToken).gt(balance)) {

console.log("[From BTC: REST.CreateInvoice] Base security deposit: ", baseSD.toString(10));
const swapValueInNativeCurrency = yield this.swapPricing.getFromBtcSwapAmount(parsedBody.amount.sub(swapFee), this.swapContract.getNativeCurrencyAddress());
const swapValueInNativeCurrency = yield this.swapPricing.getFromBtcSwapAmount(parsedBody.amount.sub(swapFee), this.swapContract.getNativeCurrencyAddress(), true);
console.log("[From BTC: REST.CreateInvoice] Swap output value in native currency: ", swapValueInNativeCurrency.toString(10));

@@ -274,0 +274,0 @@ const apyPPM = new BN(Math.floor(this.config.securityDepositAPY * 1000000));

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

const invoiceAmountInToken = yield this.swapPricing.getFromBtcSwapAmount(invoiceAmount, useToken);
const feeInToken = yield this.swapPricing.getFromBtcSwapAmount(fee, useToken);
const feeInToken = yield this.swapPricing.getFromBtcSwapAmount(fee, useToken, true);
const sendAmount = invoiceAmountInToken.sub(feeInToken);

@@ -337,3 +337,3 @@ const cancelAndRemove = () => __awaiter(this, void 0, void 0, function* () {

const amountInToken = yield this.swapPricing.getFromBtcSwapAmount(parsedBody.amount, useToken);
const swapFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(swapFee, useToken);
const swapFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(swapFee, useToken, true);
const balance = yield this.swapContract.getBalance(useToken, true);

@@ -370,3 +370,3 @@ const totalSwapOut = amountInToken.sub(swapFeeInToken);

}
const swapValueInNativeCurrency = yield this.swapPricing.getFromBtcSwapAmount(parsedBody.amount.sub(swapFee), this.swapContract.getNativeCurrencyAddress());
const swapValueInNativeCurrency = yield this.swapPricing.getFromBtcSwapAmount(parsedBody.amount.sub(swapFee), this.swapContract.getNativeCurrencyAddress(), true);
const apyPPM = new BN(Math.floor(this.config.securityDepositAPY * 1000000));

@@ -373,0 +373,0 @@ const variableSD = swapValueInNativeCurrency.mul(apyPPM).mul(expiryTimeout).div(new BN(1000000)).div(secondsInYear);

@@ -9,4 +9,5 @@ import * as BN from "bn.js";

* @param fromToken Token
* @param roundUp Whether result should be rounded up
*/
getToBtcSwapAmount(fromAmount: BN, fromToken: TokenAddress): Promise<BN>;
getToBtcSwapAmount(fromAmount: BN, fromToken: TokenAddress, roundUp?: boolean): Promise<BN>;
/**

@@ -17,4 +18,5 @@ * Returns amount of {toToken} that are equivalent to {fromAmount} satoshis

* @param toToken Token
* @param roundUp Whether result be rounded up
*/
getFromBtcSwapAmount(fromAmount: BN, toToken: TokenAddress): Promise<BN>;
getFromBtcSwapAmount(fromAmount: BN, toToken: TokenAddress, roundUp?: boolean): Promise<BN>;
}

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

const swapFee = this.config.baseFee.add(amountBD.mul(this.config.feePPM).div(new BN(1000000)));
const networkFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(networkFeeAdjusted, useToken);
const swapFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(swapFee, useToken);
const networkFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(networkFeeAdjusted, useToken, true);
const swapFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(swapFee, useToken, true);
let amountInToken;

@@ -585,3 +585,3 @@ let total;

else {
amountInToken = yield this.swapPricing.getFromBtcSwapAmount(parsedBody.amount, useToken);
amountInToken = yield this.swapPricing.getFromBtcSwapAmount(parsedBody.amount, useToken, true);
total = amountInToken.add(swapFeeInToken).add(networkFeeInToken);

@@ -588,0 +588,0 @@ }

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

const useToken = this.swapContract.toTokenAddress(parsedBody.token);
const routingFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(actualRoutingFee, useToken);
const swapFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(swapFee, useToken);
const amountInToken = yield this.swapPricing.getFromBtcSwapAmount(amountBD, useToken);
const routingFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(actualRoutingFee, useToken, true);
const swapFeeInToken = yield this.swapPricing.getFromBtcSwapAmount(swapFee, useToken, true);
const amountInToken = yield this.swapPricing.getFromBtcSwapAmount(amountBD, useToken, true);
const total = amountInToken.add(routingFeeInToken).add(swapFeeInToken);

@@ -419,0 +419,0 @@ const payObject = yield this.swapContract.createSwapData(crosslightning_base_1.ChainSwapType.HTLC, parsedBody.offerer, this.swapContract.getAddress(), useToken, total, parsedPR.tagsObject.payment_hash, parsedBody.expiryTimestamp, new BN(0), 0, true, false, new BN(0), new BN(0));

{
"name": "crosslightning-intermediary",
"version": "3.1.2",
"version": "3.1.3",
"description": "Main functionality implementation for intermediary node, easily extensible to any chain",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

@@ -139,3 +139,3 @@ import * as BN from "bn.js";

async getFromBtcSwapAmount(fromAmount: BN, toToken: TokenAddress): Promise<BN> {
async getFromBtcSwapAmount(fromAmount: BN, toToken: TokenAddress, roundUp?: boolean): Promise<BN> {
let tokenAddress: string = toToken.toString();

@@ -152,7 +152,7 @@

.mul(new BN(1000)) //To msat
.add(price.sub(new BN(1)))
.add(roundUp ? price.sub(new BN(1)) : new BN(0))
.div(price)
}
async getToBtcSwapAmount(fromAmount: BN, fromToken: TokenAddress): Promise<BN> {
async getToBtcSwapAmount(fromAmount: BN, fromToken: TokenAddress, roundUp?: boolean): Promise<BN> {
let tokenAddress: string = fromToken.toString();

@@ -169,3 +169,3 @@

.div(new BN(10).pow(new BN(coin.decimals)))
.add(new BN(999))
.add(roundUp ? new BN(999) : new BN(0))
.div(new BN(1000));

@@ -172,0 +172,0 @@ }

@@ -310,3 +310,3 @@ import * as BN from "bn.js";

const amountInToken = await this.swapPricing.getFromBtcSwapAmount(parsedBody.amount, useToken);
const swapFeeInToken = await this.swapPricing.getFromBtcSwapAmount(swapFee, useToken);
const swapFeeInToken = await this.swapPricing.getFromBtcSwapAmount(swapFee, useToken, true);

@@ -347,3 +347,3 @@ const balance = await this.swapContract.getBalance(useToken, true);

console.log("[From BTC: REST.CreateInvoice] Base security deposit: ", baseSD.toString(10));
const swapValueInNativeCurrency = await this.swapPricing.getFromBtcSwapAmount(parsedBody.amount.sub(swapFee), this.swapContract.getNativeCurrencyAddress());
const swapValueInNativeCurrency = await this.swapPricing.getFromBtcSwapAmount(parsedBody.amount.sub(swapFee), this.swapContract.getNativeCurrencyAddress(), true);
console.log("[From BTC: REST.CreateInvoice] Swap output value in native currency: ", swapValueInNativeCurrency.toString(10));

@@ -350,0 +350,0 @@ const apyPPM = new BN(Math.floor(this.config.securityDepositAPY*1000000));

@@ -307,3 +307,3 @@ import * as BN from "bn.js";

const invoiceAmountInToken = await this.swapPricing.getFromBtcSwapAmount(invoiceAmount, useToken);
const feeInToken = await this.swapPricing.getFromBtcSwapAmount(fee, useToken);
const feeInToken = await this.swapPricing.getFromBtcSwapAmount(fee, useToken, true);

@@ -437,3 +437,3 @@ const sendAmount: BN = invoiceAmountInToken.sub(feeInToken);

const amountInToken = await this.swapPricing.getFromBtcSwapAmount(parsedBody.amount, useToken);
const swapFeeInToken = await this.swapPricing.getFromBtcSwapAmount(swapFee, useToken);
const swapFeeInToken = await this.swapPricing.getFromBtcSwapAmount(swapFee, useToken, true);

@@ -481,3 +481,3 @@ const balance = await this.swapContract.getBalance(useToken, true);

const swapValueInNativeCurrency = await this.swapPricing.getFromBtcSwapAmount(parsedBody.amount.sub(swapFee), this.swapContract.getNativeCurrencyAddress());
const swapValueInNativeCurrency = await this.swapPricing.getFromBtcSwapAmount(parsedBody.amount.sub(swapFee), this.swapContract.getNativeCurrencyAddress(), true);
const apyPPM = new BN(Math.floor(this.config.securityDepositAPY*1000000));

@@ -484,0 +484,0 @@ const variableSD = swapValueInNativeCurrency.mul(apyPPM).mul(expiryTimeout).div(new BN(1000000)).div(secondsInYear);

@@ -11,4 +11,5 @@ import * as BN from "bn.js";

* @param fromToken Token
* @param roundUp Whether result should be rounded up
*/
getToBtcSwapAmount(fromAmount:BN, fromToken: TokenAddress): Promise<BN>;
getToBtcSwapAmount(fromAmount:BN, fromToken: TokenAddress, roundUp?: boolean): Promise<BN>;

@@ -20,5 +21,6 @@ /**

* @param toToken Token
* @param roundUp Whether result be rounded up
*/
getFromBtcSwapAmount(fromAmount:BN, toToken: TokenAddress): Promise<BN>;
getFromBtcSwapAmount(fromAmount:BN, toToken: TokenAddress, roundUp?: boolean): Promise<BN>;
}

@@ -714,4 +714,4 @@ import {Express} from "express";

const networkFeeInToken = await this.swapPricing.getFromBtcSwapAmount(networkFeeAdjusted, useToken);
const swapFeeInToken = await this.swapPricing.getFromBtcSwapAmount(swapFee, useToken);
const networkFeeInToken = await this.swapPricing.getFromBtcSwapAmount(networkFeeAdjusted, useToken, true);
const swapFeeInToken = await this.swapPricing.getFromBtcSwapAmount(swapFee, useToken, true);

@@ -724,3 +724,3 @@ let amountInToken: BN;

} else {
amountInToken = await this.swapPricing.getFromBtcSwapAmount(parsedBody.amount, useToken);
amountInToken = await this.swapPricing.getFromBtcSwapAmount(parsedBody.amount, useToken, true);
total = amountInToken.add(swapFeeInToken).add(networkFeeInToken);

@@ -727,0 +727,0 @@ }

@@ -526,5 +526,5 @@ import * as BN from "bn.js";

const routingFeeInToken = await this.swapPricing.getFromBtcSwapAmount(actualRoutingFee, useToken);
const swapFeeInToken = await this.swapPricing.getFromBtcSwapAmount(swapFee, useToken);
const amountInToken = await this.swapPricing.getFromBtcSwapAmount(amountBD, useToken);
const routingFeeInToken = await this.swapPricing.getFromBtcSwapAmount(actualRoutingFee, useToken, true);
const swapFeeInToken = await this.swapPricing.getFromBtcSwapAmount(swapFee, useToken, true);
const amountInToken = await this.swapPricing.getFromBtcSwapAmount(amountBD, useToken, true);

@@ -531,0 +531,0 @@ const total = amountInToken.add(routingFeeInToken).add(swapFeeInToken);

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