All blogposts
Introducing the Flash Mint SDK
Introducing the Flash Mint SDK
Flash Mint is an innovative integration that enables dApps and DEXs to pass along significant cost savings and provide deep liquidity for large cryptocurrency trades.
8/8/2022
Index Coop

Flash Mint is an innovative integration that enables dApps and DEXs to pass along significant cost savings and provide deep liquidity for large cryptocurrency trades.
The Index Coop is pleased to introduce the Flash Mint SDK, which provides support for dApps and exchanges looking to easily integrate mint and redeem capabilities for crypto structured products, such as DeFi Pulse Index (DPI) and Interest Compounding Ethereum (icETH). Integrating Flash Mint provides many benefits not only for developers but also for crypto users. The ability to Flash Mint tokens reduces slippage and unlocks cost savings on large trades. The Flash Mint SDK is written in TypeScript, and is available now on GitHub.
Disclaimer: the Flash Mint SDK should be treated as **beta** for now. ⚠️
TL;DR
“I’m a DeFi app and/or DEX aggregator. What’s in it for me?”
The Flash Mint SDK:
1. Provides the code and documentation so the ability to Flash Mint can be simply integrated into your dApp or DEX
2. Sources better trade execution for your users (especially for large trades)
What is Flash Mint?
A simple decentralized exchange (DEX) trade is usually cost-effective for smaller trades where you are likely to encounter low slippage. However, at some threshold on larger trades, you are likely to encounter significant slippage (> 1%). That’s where Flash Mint can offer cost savings.
Compared to typical DEX trades, Flash Mint can facilitate more cost-effective large trades by minting new units from the underlying product components. This is especially helpful where the cost of slippage would exceed the cost of gas for buying each token and minting a new product unit.
Flash Mint allows you to indirectly buy components of an index and then mint a new unit. As an example, here’s how that works for DPI:
You send your currency of choice (ETH, USDC, or DAI, for example) to the contract
Your currency is then exchanged into the correct amount of underlying DPI assets necessary to mint new units
New DPI units are minted and sent back to your wallet
The Contracts
To find out more about the code of Flash Mint contracts, go to Index Coop’s smart contract repository on GitHub.
The SDK includes:
ExchangeIssuanceLeveraged aka FlashMintLeveraged
Mainnet:
https://etherscan.io/address/0xb7cc88a13586d862b97a677990de14a122b74598
Supports:
ETH 2x Flexible Leverage Index (ETH2x-FLI)
BTC 2x Flexible Leverage Index (BTC2x-FLI)
Interest Compounding ETH (icETH)
Polygon:
https://polygonscan.com/address/0xe86636f23b502b8746a72a1ed87d65f096e419db
Supports:
ETH 2x Flexible Leverage Index Polygon (ETH2x-FLI-P)
BTC 2x Flexible Leverage Index Polygon (BTC2x-FLI-P)
MATIC 2x Flexible Leverage Index Polygon (MATIC2x-FLI-P)
Inverse ETH Flexible Leverage Index Polygon (iETH-FLI-P)
Inverse BTC Flexible Leverage Index Polygon (iBTC-FLI-P)
Inverse MATIC Flexible Leverage Index Polygon (iMATIC-FLI-P)
ExchangeIssuanceZeroEx aka FlashMintZeroEx
Mainnet:
https://etherscan.io/address/0xf42ecdc112365ff79a745b4cf7d4c266bd6e4b25
Supports:
DeFi Pulse Index (DPI)
Metaverse Index (MVI)
Data Economy Index (DATA)
Bankless Innovation Index (GMI)
Bankless BED Index (BED)
JPG NFT Index (JPG)
Check out the utility functions for easily obtaining the correct addresses and contracts when integrating into your project.
Limitations
There are a few limitations to be aware of when first getting started.
A Flash Mint contract can only mint or redeem an exact amount of Set token. The SDK currently does not support finding these amounts e.g., compared to other quotes. You're welcome to contact us and we can walk you through how we do it in our frontend.
(Set) tokens must be approved on the contracts before they can be used with any of the contract's functions. Use `approveSetToken`, `approveToken` or `approveTokens`. This functionality is currently not available through the SDK but can be easily executed via a block explorer like Etherscan.
Quick Install
The library is hosted on npm. Installing is as easy as:
$ npm i @indexcoop/flash-mint-sdkor$ yarn add @indexcoop/flash-mint-sdk
Using Flash Mint SDK
Flash Mint SDK currently supports two use cases - fetching quotes and issuing/redeeming a Set token. This is available for both the FlashMintLeveraged and FlashMintZeroEx.
Quotes
To fetch a quote for `FlashMintLeveraged` use the following code.
import { getFlashMintLeveragedQuote, ZeroExApi,} from '@indexcoop/flash-mint-sdk'// Input/output token should be of type QuoteToken with the following propertiesconst inputToken = { symbol: "ETH", decimals: 18, address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", }const outputToken = { ... }// Slippage should be defined in % e.g. 0.1 or 3%const slippage = 0.5// For quotes the provider can be read-onlyconst provider: JsonRpcProvider = ...// Define no base url to use the free default (watch rate limits!)const zeroExApi = new ZeroExApi()const quote = await getFlashMintLeveragedQuote( inputToken, outputToken, setTokenAmount, // How much of the Set token should be minted/redeemed isMinting, // Set here whether the Set token should be minted/redeemed slippage, zeroExApi, provider, chainId ?? 1)
Fetching quotes for the `FlashMintZeroEx` works similar to the example above.
const quote = await getFlashMintZeroExQuote( inputToken, outputToken, setTokenAmount, isMinting, slippage, zeroExApi, provider, chainId)
The quote functions will return objects of the following types (or null on error). Depending on minting/redeeming the `inputOutputTokenAmount` will be the quote for the input or output token amount that is needed to mint/redeem the exact set amount `setTokenAmount`. The other properties are data that will be used as input for the trade functions (when minting/redeeming).
export interface FlashMintLeveragedQuote { swapDataDebtCollateral: SwapData swapDataPaymentToken: SwapData inputOutputTokenAmount: BigNumber setTokenAmount: BigNumber}export interface FlashMintZeroExQuote { componentQuotes: string[] inputOutputTokenAmount: BigNumber setTokenAmount: BigNumber}
Mint/Redeem Tokens
Multiple functions for minting and redeeming Set tokens are included in the Flash Mint SDK. The functions will execute and return an object of type `TransactionResponse` (ethers.js). Only one mint and redeem function are shown here as examples. Check out the repository on GitHub to see how to call all functions. The functions always differentiate between the native chain token (e.g., ETH or MATIC) and other tokens.
FlashMintLeveraged
import { FlashMintLeveraged, getFlashMintLeveragedContract, SwapData,} from '@indexcoop/flash-mint-sdk'// For these functions you'll need a provider with a signerconst contract = getFlashMintLeveragedContract(provider?.getSigner(), chainId)// Pass the contract to the flash mint classconst flashMint = new FlashMintLeveraged(contract)// To redeem a Set token for ETHconst redeemTx = await flashMint.redeemExactSetForETH( setTokenAddress, setTokenAmount, inputOutputLimit, debtCollateralSwapData, inputOutputSwapData, { gasLimit: ... })
FlashMintZeroEx
import { FlashMintZeroEx, getFlashMintZeroExContract, getIssuanceModule,} from '@indexcoop/flash-mint-sdk'// For these functions you'll need a provider with a signerconst contract = getFlashMintZeroExContract(provider.getSigner(), chainId)// Pass the contract to the flash mint classconst flashMint = new FlashMintZeroEx(contract)// Determine the correct issuance module (helper function)const issuanceModule = getIssuanceModule(setTokenSymbol, chainId)// To mint a Set token from ETHconst mintTx = await flashMint.mintExactSetFromETH( setTokenAddress, setTokenAmount, quote.componentQuotes, // the component quotes that were fetched via the quote function earlier issuanceModule.address, issuanceModule.isDebtIssuance, quoteData.inputTokenAmount, { gasLimit: ... })
Integrate Flash Mint Today
We’ve introduced this SDK to help development teams more easily integrate Flash Mint into their apps and enable more cost-efficient trades. We look forward to your feedback and hearing how you integrate Flash Mint to benefit your protocol and users.
To discuss partnership opportunities, email Funkmaster Flex: institutions@indexcoop.com. For any technical questions, feel free to reach out to JD, jann@indexcoop.com, or our engineering team via our channel #product-nest on Discord.
The SDK is licensed under MIT. Copyright © 2022 Index Coop.
Find out more under: https://github.com/IndexCoop/flash-mint-sdk
https://www.npmjs.com/package/@indexcoop/flash-mint-sdk
Dive deeper
Watch, read, and learn everything you need to master our leverage tokens.
Subscribe to our newsletter
Join over 6,000 subscribers in receiving weekly updates about our products, DeFi, and the onchain structured products space.
FAQs
Index Coop yield tokens simplify earning yield in DeFi by automating complex strategies and diversifying across protocols. They are user-friendly and cost-efficient, appealing to both new and seasoned DeFi users.
Leverage tokens automate a leveraged position by utilizing onchain money markets like Aave or Morpho to borrow funds, amplifying a user's exposure to an asset without requiring manual management. The token's smart contracts autonomously handle the borrowing, lending, and rebalancing of assets, maintaining a consistent leverage ratio despite market fluctuations. This automation eliminates the complexities of collateral management and liquidation risks, while also charging low, transparent fees that avoid expensive funding rates often charged by perps.
Index Coop is a decentralized autonomous organization (DAO) that specializes in creating and maintaining onchain structured products. Index Coop aims to democratize access to the crypto market, empowering everyone to participate in the growing digital asset ecosystem with ease.
No, yield automatically compounds and accrues to the token price. The value of the tokens you hold in your wallet will simply go up over time without the need to claim or compound rewards.
Index Coop products protect you from liquidation with automated risk management that rebalances assets to maintain a target leverage ratio that avoids liquidation.
INDEX is the ERC-20 governance token on Ethereum for Index Coop. INDEX empowers its holders to participate in decision-making processes that shape the future of Index Coop.
Yes, all Index Coop products are instantly redeemable for their underlying value at all times.
Yes, all Index Coop smart contracts have been audited by leading independent security firms such as OpenZeppelin, ABDK, Isosiro, & more. There is also an active bug bounty program through ImmuneFi. Audit information is published in the docs here.
Streaming fees (an annual fee paid continuously block-by-block), mint and redeem fees (only on leverage tokens), and borrow costs (interest paid to borrow funds from onchain markets when using leverage).