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

crosslightning-sdk-base

Package Overview
Dependencies
Maintainers
1
Versions
318
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crosslightning-sdk-base - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

5

dist/prices/CoinGeckoSwapPrice.d.ts

@@ -10,4 +10,8 @@ import { ISwapPrice } from "../swaps/ISwapPrice";

};
export type CoinAddresses = {
[token in "USDC" | "USDT" | "WBTC" | "ETH"]?: string;
};
export declare class CoinGeckoSwapPrice extends ISwapPrice {
static createCoinsMap(wbtcAdress?: string, usdcAddress?: string, usdtAddress?: string): CoinsMapType;
static createCoinsMapFromTokens(tokens: CoinAddresses, nativeTokenCoinGeckoId?: string): CoinsMapType;
url: string;

@@ -24,2 +28,3 @@ COINS_MAP: CoinsMapType;

getToBtcSwapAmount(fromAmount: BN, fromToken: TokenAddress): Promise<BN>;
shouldIgnore(tokenAddress: TokenAddress): boolean;
}

@@ -41,2 +41,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

}
static createCoinsMapFromTokens(tokens, nativeTokenCoinGeckoId) {
const coinMap = {};
if (tokens.WBTC != null) {
coinMap[tokens.WBTC] = {
coinId: "wrapped-bitcoin",
decimals: 8
};
}
if (tokens.USDC != null) {
coinMap[tokens.USDC] = {
coinId: "usd-coin",
decimals: 6
};
}
if (tokens.USDT != null) {
coinMap[tokens.USDT] = {
coinId: "tether",
decimals: 6
};
}
if (tokens.ETH != null || nativeTokenCoinGeckoId != null) {
coinMap[tokens.ETH] = {
coinId: nativeTokenCoinGeckoId,
decimals: 18
};
}
return coinMap;
}
constructor(maxAllowedFeeDiffPPM, coinsMap, url) {

@@ -124,2 +152,8 @@ super(maxAllowedFeeDiffPPM);

}
shouldIgnore(tokenAddress) {
const coin = this.COINS_MAP[tokenAddress];
if (coin == null)
throw new Error("Token not found");
return coin.coinId === "$ignore";
}
}

1

dist/swaps/ISwapPrice.d.ts

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

abstract getFromBtcSwapAmount(fromAmount: BN, toToken: TokenAddress): Promise<BN>;
abstract shouldIgnore(tokenAddress: TokenAddress): boolean;
}

@@ -17,2 +17,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __awaiter(this, void 0, void 0, function* () {
if (this.shouldIgnore(token))
return true;
const totalSats = amountSats.mul(new BN(1000000).add(feePPM)).div(new BN(1000000))

@@ -32,2 +34,4 @@ .add(satsBaseFee);

return __awaiter(this, void 0, void 0, function* () {
if (this.shouldIgnore(token))
return true;
const totalSats = amountSats.mul(new BN(1000000).sub(feePPM)).div(new BN(1000000))

@@ -34,0 +38,0 @@ .sub(satsBaseFee);

2

package.json
{
"name": "crosslightning-sdk-base",
"version": "2.0.4",
"version": "2.0.5",
"description": "CrossLightning SDK chain-agnostic base",

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

@@ -14,2 +14,6 @@ import {ISwapPrice} from "../swaps/ISwapPrice";

export type CoinAddresses = {
[token in "USDC" | "USDT" | "WBTC" | "ETH"]?: string;
};
export class CoinGeckoSwapPrice extends ISwapPrice {

@@ -49,2 +53,35 @@

static createCoinsMapFromTokens(tokens: CoinAddresses, nativeTokenCoinGeckoId?: string): CoinsMapType {
const coinMap = {};
if(tokens.WBTC!=null) {
coinMap[tokens.WBTC] = {
coinId: "wrapped-bitcoin",
decimals: 8
};
}
if(tokens.USDC!=null) {
coinMap[tokens.USDC] = {
coinId: "usd-coin",
decimals: 6
};
}
if(tokens.USDT!=null) {
coinMap[tokens.USDT] = {
coinId: "tether",
decimals: 6
};
}
if(tokens.ETH!=null || nativeTokenCoinGeckoId!=null) {
coinMap[tokens.ETH] = {
coinId: nativeTokenCoinGeckoId,
decimals: 18
};
}
return coinMap;
}
url: string;

@@ -145,2 +182,10 @@ COINS_MAP: CoinsMapType = {

shouldIgnore(tokenAddress: TokenAddress): boolean {
const coin = this.COINS_MAP[tokenAddress];
if(coin==null) throw new Error("Token not found");
return coin.coinId==="$ignore";
}
}

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

async isValidAmountSend(amountSats: BN,satsBaseFee: BN, feePPM: BN, paidToken: BN, token: TokenAddress): Promise<boolean> {
if(this.shouldIgnore(token)) return true;
const totalSats = amountSats.mul(new BN(1000000).add(feePPM)).div(new BN(1000000))

@@ -33,2 +35,4 @@ .add(satsBaseFee);

async isValidAmountReceive(amountSats: BN,satsBaseFee: BN, feePPM: BN, receiveToken: BN, token: TokenAddress): Promise<boolean> {
if(this.shouldIgnore(token)) return true;
const totalSats = amountSats.mul(new BN(1000000).sub(feePPM)).div(new BN(1000000))

@@ -68,2 +72,4 @@ .sub(satsBaseFee);

abstract shouldIgnore(tokenAddress: TokenAddress): boolean;
}
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