Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
@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.
The npm package @mstable/mstable-js receives a total of 0 weekly downloads. As such, @mstable/mstable-js popularity was classified as not popular.
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
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.