Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@indexcoop/flash-mint-sdk

Package Overview
Dependencies
Maintainers
5
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@indexcoop/flash-mint-sdk

The FlashMintSDK of the Index Coop.

Source
npmnpm
Version
3.35.0
Version published
Weekly downloads
151
11.03%
Maintainers
5
Weekly downloads
 
Created
Source

Flash Mint SDK v3

The Flash Mint SDK provides easy to use functions to integrate flash minting for Index's products.

The Contracts

To find out more about the contracts, go to Index's smart contracts repo.

This SDK currently supports the contracts listed here.

Install

$ npm install @indexcoop/flash-mint-sdk

Limitations

A limitation to be aware of (especially for getting quotes) is that the contracts can only mint or redeem an exact amount of Index token.

Additionally, make sure that the (Index/Set) tokens have been approved on the specific FlashMint contracts.

Usage

Quotes

With v3, while you could still use other quote providers individually, we recommend solely using the FlashMintQuoteProvider which will do most of the guess work for you. This provider will return the appropriate quotes for any Index token, automatically selecting the correct FlashMint contract for you - as well as preparing the call data.

import { FlashMintQuoteProvider, QuoteToken } from '@indexcoop/flash-mint-sdk'

// Input/output token should be of type QuoteToken with the following properties
const inputToken: QuoteToken = {
  symbol: 'ETH',
  decimals: 18,
  address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
}
const outputToken: QuoteToken = {
  symbol: 'icETH',
  decimals: 18,
  address: '0xc4506022Fb8090774E8A628d5084EED61D9B99Ee',
}

// Add a RPC URL e.g. from Alchemy
const rpcUrl = ''
// Use the 0x v2 swap quote provider configured with your API key or provide your 
// own adapter implementing the `SwapQuoteProviderV2` interface.
const zeroexV2SwapQuoteProvider = new ZeroExV2SwapQuoteProvider()
// As 0x v2 does not allow swap quotes by defining outputAmounts any longer we're
// now added a second swap quote provider for that - Li.Fi (provide API key).
const lifiSwapQuoteProvider = new LiFiSwapQuoteProvider(apiKey, integrator)
const quoteProvider = new FlashMintQuoteProvider(
  rpcUrl,
  zeroexV2SwapQuoteProvider,
  lifiSwapQuoteProvider
)
// Option 1 - get a quote for a specified index token amount
const quote = await quoteProvider.getQuote({
  chainId: 1,
  isMinting: true,
  inputToken,
  outputToken,
  indexTokenAmount: wei(1).toString(),
  inputTokenAmount: wei(1).toString(),
  slippage: 0.1,
})
// Option 2 - get a quote for a fixed input amount (am approx. indexTokenAmount 
// should still be added to the request).
await quoteProvider.getFixedInputQuote({
  chainId: 1,
  isMinting: true,
  inputToken,
  outputToken,
  indexTokenAmount: wei(1).toString(),
  inputTokenAmount: wei(1).toString(),
  slippage: 0.1,
})

The returned quote is an object including meta data but most importantly the inputOutputAmount which is the quote for the given request* and a tx object which is a tx object basically ready to be send.

interface FlashMintQuote {
  chainId: number
  contractType: FlashMintContractType
  contract: string
  isMinting: boolean
  inputToken: QuoteToken
  outputToken: QuoteToken
  inputAmount: BigNumber
  outputAmount: BigNumber
  indexTokenAmount: BigNumber
  inputOutputAmount: BigNumber
  slippage: number
  tx: TransactionRequest
}

* for minting this will be the input amount, for redeeming the output amount

Flashmint

To execute the flash minting of an Index token for convenience use the tx object returned by the FlashMintQuoteProvider.

...
const quoteProvider = new FlashMintQuoteProvider(
      rpcUrl,
      zeroexV2SwapQuoteProvider,
      lifiSwapQuoteProvider
    )
const quote = await quoteProvider.getQuote({...})
let tx = quote.tx
const gasEstimate = await provider.estimateGas(tx)
tx.gasLimit = gasEstimate
const res = await signer.sendTransaction(tx)
console.log(res.hash)

Development

.env vars

When adding new .env vars do not forget to update the publish.yml

Adding a new Index token

  • add a test for determining the correct issuance module (only if using 0x) here
  • add a test for determining the correct contract here
  • if there is a new FlashMint contract, add it as described below
  • add symbol to function getContractType(token: string) in src/quote/provider/utils.ts and add a test
  • additionally, add a test in tests

Adding a new contract

Testing

// run all tests
npm run test:hardhat src/tests/e2e/index.test.ts

// run tests for a specific chain
npm run test:hardhat src/tests/e2e/index.test.ts -- --grep "chain 1"

// run tests for a specific product exiting on first failure
npm run test:hardhat src/tests/e2e/index.test.ts -- --bail --grep "hyETH"

Debugging

cast run --rpc-url http://127.0.0.1:8545/ 0x8ea51dd6cec3e1bea98b143715fe9a1375ca7e01c120f0065cb4ef6c0e0dd23a // mainnet
cast run --rpc-url http://127.0.0.1:8453/ 0x362c844b7a1ecd5feb14e389eccd68d34373281892e5a6d387131ed9bfef9b01 // base
cast run --rpc-url http://127.0.0.1:8548/ 0x5434cd90c4b06faed9d77d256e5d569b94c1ef88217d25e82bc6cf1b84153b69 // arbitrum

Contributing

We will encourage contributing and open dialog how to improve the SDK. How though is still TBD. 🚧 In the meantime just open an issue.

License

Copyright © 2025 Index Coop.

MIT License

Keywords

flashmint

FAQs

Package last updated on 23 Jun 2025

Did you know?

Socket

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.

Install

Related posts