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

@railgun-community/cookbook

Package Overview
Dependencies
Maintainers
4
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@railgun-community/cookbook - npm Package Compare versions

Comparing version 1.0.9 to 1.0.10

9

dist/recipes/swap/swap-recipe.d.ts
import { NetworkName } from '@railgun-community/shared-models';
import { RecipeERC20Amount, RecipeERC20Info, StepOutputERC20Amount, SwapQuoteData } from '../../models/export-models';
import { RecipeERC20Amount, RecipeERC20Info, RecipeOutput, StepOutputERC20Amount, SwapQuoteData } from '../../models/export-models';
import { Recipe } from '../recipe';
import { BigNumber } from 'ethers';
export declare abstract class SwapRecipe extends Recipe {

@@ -11,2 +12,8 @@ protected quote: Optional<SwapQuoteData>;

protected findFirstInputSellERC20Amount(inputERC20Amounts: StepOutputERC20Amount[]): RecipeERC20Amount;
getBuySellAmountsFromRecipeOutput(recipeOutput: RecipeOutput): Optional<{
sellERC20Fee: BigNumber;
buyERC20Amount: BigNumber;
buyERC20Minimum: BigNumber;
buyERC20Fee: BigNumber;
}>;
}

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

const recipe_1 = require("../recipe");
const cookbook_debug_1 = require("../../utils/cookbook-debug");
class SwapRecipe extends recipe_1.Recipe {

@@ -21,4 +22,41 @@ getLatestQuote() {

}
getBuySellAmountsFromRecipeOutput(recipeOutput) {
try {
const unshieldStepOutput = recipeOutput.stepOutputs[0];
const unshieldFee = unshieldStepOutput.feeERC20AmountRecipients.find(fee => {
return (0, utils_1.compareERC20Info)(fee, this.sellERC20Info);
});
if (!unshieldFee) {
throw new Error('Expected unshield fee to match sell token.');
}
const shieldStepOutput = recipeOutput.stepOutputs[recipeOutput.stepOutputs.length - 1];
const shieldFee = shieldStepOutput.feeERC20AmountRecipients.find(fee => {
return (0, utils_1.compareERC20Info)(fee, this.buyERC20Info);
});
if (!shieldFee) {
throw new Error('Expected shield fee to match buy token.');
}
const output = shieldStepOutput.outputERC20Amounts.find(outputAmount => {
return (0, utils_1.compareERC20Info)(outputAmount, this.buyERC20Info);
});
if (!output) {
throw new Error('Expected output to match buy token.');
}
return {
sellERC20Fee: unshieldFee.amount,
buyERC20Amount: output.expectedBalance,
buyERC20Minimum: output.minBalance,
buyERC20Fee: shieldFee.amount,
};
}
catch (err) {
if (!(err instanceof Error)) {
throw err;
}
cookbook_debug_1.CookbookDebug.error(err);
return undefined;
}
}
}
exports.SwapRecipe = SwapRecipe;
//# sourceMappingURL=swap-recipe.js.map

@@ -49,2 +49,6 @@ "use strict";

const shieldedAmount = erc20Amount.expectedBalance.sub(shieldFeeAmount);
const shieldFeeAmountMinimum = erc20Amount.minBalance
.mul(shieldFeeBasisPoints)
.div(10000);
const shieldedAmountMinimum = erc20Amount.minBalance.sub(shieldFeeAmountMinimum);
outputERC20Amounts.push({

@@ -55,3 +59,3 @@ tokenAddress: erc20Amount.tokenAddress,

expectedBalance: shieldedAmount,
minBalance: shieldedAmount,
minBalance: shieldedAmountMinimum,
});

@@ -58,0 +62,0 @@ feeERC20AmountRecipients.push({

5

dist/utils/token.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isApprovedForSpender = exports.compareERC20Info = void 0;
const compareTokenAddress = (a, b) => {
return a.toLowerCase() === b.toLowerCase();
};
const compareERC20Info = (tokenA, tokenB) => {
return (tokenA.tokenAddress.toLowerCase() === tokenB.tokenAddress.toLowerCase() &&
return (compareTokenAddress(tokenA.tokenAddress, tokenB.tokenAddress) &&
!!tokenA.isBaseToken === !!tokenB.isBaseToken);

@@ -7,0 +10,0 @@ };

{
"name": "@railgun-community/cookbook",
"version": "1.0.9",
"version": "1.0.10",
"license": "MIT",

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

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