You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
indigo-sdk is a TypeScript SDK designed to interact with Indigo endpoints for managing CDPs (Collateralized Debt Positions), Staking Positions, and Stability Pool Accounts by integrating the lucid-evolution library.
Installation
npm install @indigo-labs/indigo-sdk
Development
Prerequisites
Node.js 20 or newer (version in .nvmrc is the one used for development; pnpm run test:coverage relies on the V8 coverage provider and requires Node 20+)
pnpm package manager
Setup
Clone this repository
Install dependencies: pnpm install
Build the project: pnpm run build
Available Scripts
pnpm run build - Build the project using tsup
pnpm run lint - Run ESLint to check code quality
pnpm run format - Format code using Prettier
pnpm run format:check - Check if code is properly formatted
pnpm run test - Run tests using Vitest
pnpm run test:coverage - Run tests with a V8 coverage report (coverage/; open coverage/index.html for the HTML report)
Code Quality
This project uses:
ESLint for code linting and quality checks
Prettier for code formatting
TypeScript for type safety
Running Tests
There are currently a few unit tests available for datums, hash checks, and interest calculations. Additionally, acceptance tests have been published for CDPs, Staking Positions, and Stability Pool accounts. These tests initialize the Indigo Protocol and positively test that the transaction building is working in an emulated Cardano Blockchain.
Instructions:
Clone this repository
Run pnpm install
Run pnpm run test
For a coverage report (summary in the terminal, HTML under coverage/), run pnpm run test:coverage.
Transaction endpoints
The SDK exposes transaction builders (mostly async functions that return a Lucid TxBuilder, or attach to an existing builder). They are grouped below by on-chain contract module under src/contracts/.
CDP (cdp)
Function
Summary
openCdp
Open a new CDP: deposit collateral, mint iAsset, and wire creator, oracle, and treasury inputs.
depositCdp
Add collateral to an existing CDP (settles interest via the interest collector as needed).
withdrawCdp
Remove collateral, respecting collateral ratio using the price oracle when required.
mintCdp
Mint additional iAsset debt against the CDP’s collateral.
burnCdp
Burn iAsset to pay down debt.
closeCdp
Close the CDP: settle interest, burn remaining debt, and return collateral.
redeemCdp
Redeem iAsset for collateral through the CDP redemption flow (oracle-priced, with fees to treasury/collector as applicable).
freezeCdp
Freeze a CDP that is below the redemption collateral ratio so it can be liquidated.
liquidateCdp
Liquidate a frozen CDP via the stability pool: absorb debt, move collateral, and route fees.
mergeCdps
Merge several CDPs for the same iAsset into a single combined position.
Collector (collector)
Function
Summary
collectorFeeTx
Attach a collector fee payment to an in-flight transaction; returns the collector ref script UTXO for further chaining.
Governance (gov)
Function
Summary
createProposal
Create a governance proposal, lock the poll deposit, and return the new poll id.
createShardsChunks
Mint poll shard NFTs in chunks so voting can be split across shard UTxOs.
vote
Vote yes/no on a poll shard using a staking position (updates vote tallies and staking locks).
mergeShards
Burn shard NFTs and merge vote totals back into the poll manager.
endProposal
End the poll: update governance state, burn the poll NFT, and either enqueue execution or refund the deposit.