Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@gnosis.pm/cow-sdk
Advanced tools
Install the Cow SDK library:
yarn add cow-sdk
Then you need to instantiate the SDK object:
import { CowSdk } from 'cow-sdk'
const chainId = 4 // Rinkeby
const cowSdk = new CowSdk(chainId)
That should be enough to run queries against the CoW Protocol API:
const trades = await cowSdk.cowApi.getTrades({ owner: "0x1811be0994930fE9480eAEDe25165608B093ad7A" })
console.log(trades)
In case you want to execute a swap, the SDK must be initialized with a Signer:
import { Wallet } from 'ethers'
import { CowSdk, OrderKind } from 'cow-sdk'
const mnemonic = 'fall dirt bread cactus...'
const wallet = Wallet.fromMnemonic(mnemonic)
const cowSdk = new CowSdk(4, { signer: wallet })
// We will get a price quote for selling 1 WETH for USDC
const quoteResponse = await cowSdk.cowApi.getQuote({
kind: OrderKind.SELL,
amount: '1000000000000000000',
sellToken: '0xc778417e063141139fce010982780140aa0cd5ab', // WETH
buyToken: '0x4dbcdf9b62e891a7cec5a2568c3f4faf9e8abe2b', // USDC
userAddress: '0x1811be0994930fe9480eaede25165608b093ad7a',
validTo: 2524608000,
})
const order = {
kind: OrderKind.SELL,
sellToken: quoteResponse.quote.sellToken,
buyToken: quoteResponse.quote.buyToken,
validTo: quoteResponse.quote.validTo,
buyAmount: quoteResponse.quote.buyAmount,
sellAmount: quoteResponse.quote.sellAmount,
receiver: quoteResponse.quote.receiver,
partiallyFillable: false,
feeAmount: quoteResponse.quote.feeAmount,
}
const signedOrder = await cowSdk.signOrder(order)
const orderId = await cowSdk.cowApi.sendOrder({
order: { ...order, ...signedOrder },
owner: '0x1811be0994930fe9480eaede25165608b093ad7a',
})
// We can inspect the Order details in the CoW Protocol Explorer
console.log(`https://explorer.cow.fi/rinkeby/orders/${orderId}`)
yarn
yarn build
yarn start
yarn lint
yarn format
yarn test
FAQs
Unknown package
The npm package @gnosis.pm/cow-sdk receives a total of 2 weekly downloads. As such, @gnosis.pm/cow-sdk popularity was classified as not popular.
We found that @gnosis.pm/cow-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 18 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.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
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.