
Security News
Another Round of TEA Protocol Spam Floods npm, But It’s Not a Worm
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.
@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 startRuns 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 buildBundles 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 testRuns 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.

Security News
Recent coverage mislabels the latest TEA protocol spam as a worm. Here’s what’s actually happening.

Security News
PyPI adds Trusted Publishing support for GitLab Self-Managed as adoption reaches 25% of uploads

Research
/Security News
A malicious Chrome extension posing as an Ethereum wallet steals seed phrases by encoding them into Sui transactions, enabling full wallet takeover.