
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
@blockworks-foundation/mango-client
Advanced tools
Library for interacting with Mango Markets' solana smart contracts.
A client to engage with the mango program
2.0.0 released Jun 9, 2021
0.1.19
All tests are meant to be run on devnet The full test run, takes a long time to run and in some cases fail due to connectivity issues or someone else working on devnet. Therefore it is recommended to run isolated tests like so -
yarn test -g "<test description>"
For example the following test -
it('should log lotSizes', async() => {...});
would be run like this -
yarn test -g "should log lotSizes"
You can also specify a test group that can run multiple tests for example the following group -
describe('log stuff', async() => {...});
can be run like this -
yarn test -g "should log lotSizes"
If however you do want to run the full suite of tests simply run -
yarn test
Some tests like logging and order matching will run without any requirements, however all liquidation tests expect to have an AGGREGATOR_PATH
variable set in your .env.
The AGGREGATOR_PATH
variable should be the solana-flux-aggregator path which you can get here.
Example .env file -
AGGREGATOR_PATH=~/solana-flux-aggregator
One of the most dynamic tests in the suite are the liquidation tests, which can be found in the stress testing partial liquidation
group simply do a search for it in your IDE.
All of the tests there are variations of the stressTestLiquidation
function.
Roughly this function works by -
Listed below are the parameters that can allow to create many different liquidation scenarios -
mangoGroupSpotMarket: Market,
orderQuantity?: number, // Default = 1
customLiqeeOwner?: Account, // Default = null
shouldPartialLiquidate?: boolean, // Default = false
shouldCreateNewLiqor?: boolean, // Default = true
shouldFinishLiquidationInTest?: boolean, // Default = true
customOrderPrice?: number, // Default = 0
customOrderSize?: number, // Default = 0
leverageCoefficient?: number, // Default = 15
matchLeveragedOrder?: boolean, // Default = false
side?: 'buy' | 'sell' // Default = 'buy'
liqee
. This is useful if you want to chain liquidation scenarios. If left empty a new account is createdfalse
false
if you want to chain liquidation scenarios, or would like to finish the liquidation manually.minPrice
from the marketminSize
from the markettrue
it will double the leverageCoefficient.async function main() {
const client = new MangoClient()
const cluster = 'mainnet-beta'
const clusterUrl = process.env.CLUSTER_URL || IDS.cluster_urls[cluster]
const connection = new Connection(clusterUrl, 'singleGossip')
const programId = new PublicKey(IDS[cluster].mango_program_id)
const dexProgramId = new PublicKey(IDS[cluster].dex_program_id)
const mangoGroupPk = new PublicKey(IDS[cluster].mango_groups['BTC_ETH_USDT'].mango_group_pk)
const keyPairPath = process.env.KEYPAIR || homedir() + '/.config/solana/id.json'
const payer = new Account(JSON.parse(fs.readFileSync(keyPairPath, 'utf-8')))
const mangoGroup = await client.getMangoGroup(connection, mangoGroupPk)
const prices = await mangoGroup.getPrices(connection)
const marginAccounts = (await client.getMarginAccountsForOwner(connection, programId, mangoGroup, payer))
marginAccounts.sort(
(a, b) => (a.computeValue(mangoGroup, prices) > b.computeValue(mangoGroup, prices) ? -1 : 1)
)
let marginAccount = marginAccounts[0]
const market = await Market.load(connection, mangoGroup.spotMarkets[0], { skipPreflight: true, commitment: 'singleGossip'}, mangoGroup.dexProgramId)
console.log('placing order')
const txid = await client.placeOrder(connection, programId, mangoGroup, marginAccount, market, payer, 'buy', 48000, 0.0001)
console.log('order placed')
await sleep(5000)
marginAccount = await client.getMarginAccount(connection, marginAccount.publicKey, mangoGroup.dexProgramId)
const bids = await market.loadBids(connection)
const asks = await market.loadAsks(connection)
console.log('canceling orders')
await marginAccount.cancelAllOrdersByMarket(connection, client, programId, mangoGroup, market, bids, asks, payer)
console.log('orders canceled')
}
FAQs
Library for interacting with Mango Markets' solana smart contracts.
The npm package @blockworks-foundation/mango-client receives a total of 1,054 weekly downloads. As such, @blockworks-foundation/mango-client popularity was classified as popular.
We found that @blockworks-foundation/mango-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 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 look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.