Query Minswap data and build transactions
npm install @aiquant/minswap-sdk> Official fork of the Minswap SDK with dual build support for CommonJS (CJS) and ECMAScript Modules (ESM).
This package provides both the CommonJS and ESM distributions of the Minswap SDK, ensuring compatibility across Node.js environments that do and do not use ES Modules.
---
The Minswap open-source SDK offers off-chain tooling to interact with the Minswap DEX. It supports:
* Stableswap
* AMM V1
* AMM V2
* LBE V2
Features include pool price feeds, trade simulations, transaction builders, and historical data access.
---
* [x] Pool price feed
* [x] Historical pool data
* [x] Calculate trade price & impact
* [x] Build and submit orders via Lucid
* [x] Syncer for liquidity pool data
---
Choose the package that matches your project setup:
| Build | Install Command | Usage |
| ----- | ---------------------------------- | -------------------------------------------------- |
| CJS | npm install @aiquant/minswap-sdk | const { ... } = require("@aiquant/minswap-sdk"); |
| ESM | npm install @aiquant/minswap-sdk | import { ... } from "@aiquant/minswap-sdk"; |
| PNPM | pnpm add @aiquant/minswap-sdk | Supports both CJS & ESM |
| Yarn | yarn add @aiquant/minswap-sdk | Supports both CJS & ESM |
---
``ts
import { BlockFrostAPI } from "@blockfrost/blockfrost-js";
import { BlockfrostAdapter } from "@aiquant/minswap-sdk"; // forked package
const api = new BlockfrostAdapter({
blockFrost: new BlockFrostAPI({
projectId: "
network: "mainnet",
}),
});
const [adaPerMin, minPerAda] = await api.getPoolPrice({ pool: await api.getV1PoolById({ id: "
console.log(ADA/MIN: ${adaPerMin.toString()}, MIN/ADA: ${minPerAda.toString()});`
`ts
import { BlockFrostAPI } from "@blockfrost/blockfrost-js";
import { BlockfrostAdapter, NetworkId } from "@aiquant/minswap-sdk";
const api = new BlockfrostAdapter({ / ... / });
const history = await api.getPoolHistory({ id: "
for (const point of history) {
const pool = await api.getPoolInTx({ txHash: point.txHash });
const [priceA, priceB] = await api.getPoolPrice({ pool, decimalsA: 6, decimalsB: 6 });
console.log(${point.time}: ADA/MIN=${priceA}, MIN/ADA=${priceB});`
}
`ts
import { Lucid, Blockfrost } from "@aiquant/lucid-cardano";
import { BlockfrostAdapter, Dex } from "@aiquant/minswap-sdk";
const lucid = await Lucid.new(new Blockfrost("...", "
const adapter = new BlockfrostAdapter({ / ... / });
const { poolState, poolDatum } = await api.getPoolById({ id: "
const dex = new Dex(lucid);
const tx = await dex.buildSwapExactOutTx({ / parameters / }).sign().complete();
const hash = await tx.submit();
console.log("Swap tx hash:", hash);
``
---
Contributions welcome! Please see our CONTRIBUTING.md.
---
MIT © Minswap Labs