Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
You can use this SDK in order to swap or pay using ERC-20 tokens.
We've built an example dApp that can found here https://github.com/paraswap/demo-dapp
You can also check a live example at: https://paraswap-sdk.netlify.com
https://paraswapv2.docs.apiary.io
Install the lib using npm or yarn
yarn install paraswap
const { ParaSwap } = require('paraswap');
const paraSwap = new ParaSwap();
ES6 or TypeScript
import { ParaSwap } from 'paraswap';
const paraSwap = new ParaSwap();
const tokens = await paraSwap.getTokens();
const srcToken = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'; // ETH
const destToken = '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359'; // DAI
const srcAmount = '1000000000000000000'; //The source amount multiplied by its decimals: 10 ** 18 here
const priceRoute: OptimalRates = await paraSwap.getRate(
srcToken,
destToken,
srcAmount,
);
Where priceRoute contains the rate and the distribution among exchanges, checkout the OptimalRates type for more details.
This can be used for trustless integrations, the
const paraswapFeed = new ParaswapFeed(1);
const priceRoute: OptimalRates = await paraswapFeed.getRate(
srcToken,
destToken,
srcAmount,
);
This is a schema that describes the data flow from price query to executing a Swap:
Also available at https://paraswap-achirecture.netlify.com
const paraSwap = new ParaSwap().setWeb3Provider(web3Provider);
const allowance = await paraSwap.getAllowance(userAddress, tokenAddress);
const paraSwap = new ParaSwap().setWeb3Provider(web3Provider);
const txHash = await paraSwap.approveToken(amount, userAddress, tokenAddress);
const srcToken = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
const destToken = '0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359';
const srcAmount = '1000000000000000000'; //The source amount multiplied by its decimals
const senderAddress = '0xfceA770875E7e6f25E33CEa5188d12Ef234606b4';
const receiver = '0x8B4e846c90a2521F0D2733EaCb56760209EAd51A'; // Useful in case of swap and transfer
const referrer = 'my-company-or-nick-name';
const txParams = await paraSwap.buildTx(
srcToken,
destToken,
srcAmount,
destAmount,
priceRoute,
senderAddress,
referrer,
receiver,
);
web3.eth.sendTransaction(
txParams,
async (err: Error, transactionHash: string) => {
if (err) {
return this.setState({ error: err.toString(), loading: false });
}
console.log('transactionHash', transactionHash);
},
);
Created an .env file with these 2 env variables:
PROVIDER_URL=YOUR_PROVIDRER_URL_OR_INFURA_URL
NODE_ENV=production
run
yarn install paraswap
For local developement you can run
yarn dev
For production build:
yarn build
Which will generate a production build on "dist" folder
FAQs
ParaSwap SDK
The npm package paraswap receives a total of 370 weekly downloads. As such, paraswap popularity was classified as not popular.
We found that paraswap demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 9 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.