
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
@mstable/mstable-js
Advanced tools
Data processing and validation tools for the mStable Protocol.
Data processing and validation tools for the mStable Protocol.
With Yarn:
yarn add @mstable/mstable-js
Or with npm:
npm install @mstable/mstable-js
Deployed addresses are available on the mStable docs.
ABIs can be obtained from the @mstable/protocol
package.
Detailed documentation is available on the mStable docs and the Solidity code is available on GitHub.
The mStable Protocol Subgraph can be used to fetch data such as mAssets, bAssets, swap transactions, etc.
Available subgraphs:
Example query:
query {
masset(id: "0xe2f2a5c287993345a840db3b0845fbc70f5935a5") {
address: id
token {
symbol
decimals
totalSupply
}
feeRate
redemptionFeeRate
basket {
failed
collateralisationRatio
maxBassets
bassets {
address: id
maxWeight
status
vaultBalance
isTransferFeeCharged
token {
symbol
decimals
}
}
}
savingsContracts {
address: id
totalSavings
totalCredits
exchangeRates(orderBy: timestamp, orderDirection: desc, first: 1) {
exchangeRate
}
}
}
}
Example usage:
import { ApolloClient, InMemoryCache, gql } from '@apollo/client'
const client = new ApolloClient({
uri: 'https://api.thegraph.com/subgraphs/name/mstable/mstable-protocol',
cache: new InMemoryCache(),
})
const query = gql`
query {
masset(id: "0xe2f2a5c287993345a840db3b0845fbc70f5935a5") {
address: id
# ...as above
}
}
`
const response = await client.query({ query })
Data for mAssets can also be accessed directly from the contracts. This will generally involve more work than using the Subgraph.
Example:
import { ethers } from 'ethers'
import MassetABI from '@mstable/protocol/build/contracts/Masset.json'
import BasketManagerABI from '@mstable/protocol/build/contracts/BasketManager.json'
const provider = new ethers.providers.Web3Provider(window.ethereum)
const MUSD = new ethers.Contract(MUSDAddress, MassetABI, provider)
const basketManagerAddress = await MUSD.getBasketManager()
const basketManager = new ethers.Contract(basketManagerAddress, BasketManagerABI)
const basket = await basketManager.getBasket()
const bassets = await basketManager.getBassets()
import { validateMint } from '@mstable/mstable-js'
// TODO should make it easy to get this
const MUSD = await getMUSD()
{
const [ok, reason] = validateMint(MUSD, { '0xDAI': '100000', '0xUSDC': '2000' })
expect(ok).toBeTruthy()
expect(reason).toBeUndefined()
}
{
const [ok, reason] = validateMint(MUSD, { '0xDAI': '960000000' })
expect(ok).toBeFalsy()
expect(reason).toContain('DAI is overweight')
}
import { simulateMint } from '@mstable/mstable-js'
const MUSD = await getMUSD()
{
const [ok, simulation] = simulateMint(MUSD, { '0xDAI': '100000', '0xUSDC': '2000' })
expect(ok).toBeTruthy()
expect(simulation).toMatchObject({ bassets: { '0xDAI': '200000' } })
}
This project was bootstrapped with TSDX.
Below is a list of commands you will probably find useful.
npm start
or yarn start
Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.
Your library will be rebuilt if you make edits.
npm run build
or yarn build
Bundles the package to the dist
folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).
npm test
or yarn test
Runs the test watcher (Jest) in an interactive mode. By default, runs tests related to files changed since the last commit.
FAQs
Data processing and validation tools for the mStable Protocol.
We found that @mstable/mstable-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 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
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.