{"id":17495432,"url":"https://github.com/indexcoop/flash-mint-sdk","last_synced_at":"2025-07-31T12:04:24.769Z","repository":{"id":49949042,"uuid":"518364635","full_name":"IndexCoop/flash-mint-sdk","owner":"IndexCoop","description":"The Flash Mint SDK provides helper functions for using Index's Flash Mint contracts from your app.","archived":false,"fork":false,"pushed_at":"2025-06-17T09:38:34.000Z","size":2354,"stargazers_count":11,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-19T07:52:19.317Z","etag":null,"topics":["contracts","ethereum","index"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@indexcoop/flash-mint-sdk","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IndexCoop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-07-27T08:02:47.000Z","updated_at":"2025-06-17T09:38:38.000Z","dependencies_parsed_at":"2023-02-09T15:46:28.520Z","dependency_job_id":"ad411df7-e5ca-43ea-9b40-7f1ef50e8e85","html_url":"https://github.com/IndexCoop/flash-mint-sdk","commit_stats":{"total_commits":56,"total_committers":2,"mean_commits":28.0,"dds":"0.017857142857142905","last_synced_commit":"d30c8abc6042bb6f7d8c634ded56a5b86f5f243e"},"previous_names":[],"tags_count":83,"template":false,"template_full_name":null,"purl":"pkg:github/IndexCoop/flash-mint-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexCoop%2Fflash-mint-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexCoop%2Fflash-mint-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexCoop%2Fflash-mint-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexCoop%2Fflash-mint-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IndexCoop","download_url":"https://codeload.github.com/IndexCoop/flash-mint-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IndexCoop%2Fflash-mint-sdk/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268035589,"owners_count":24185063,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-31T02:00:08.723Z","response_time":66,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["contracts","ethereum","index"],"created_at":"2024-10-19T14:06:06.266Z","updated_at":"2025-07-31T12:04:24.730Z","avatar_url":"https://github.com/IndexCoop.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flash Mint SDK v3\n\nThe Flash Mint SDK provides easy to use functions to integrate flash minting for\nIndex's products.\n\n## The Contracts\n\nTo find out more about the contracts, go to Index's smart contracts [repo](https://github.com/IndexCoop/index-coop-smart-contracts/tree/master/contracts/exchangeIssuance).\n\nThis SDK currently supports the contracts listed [here](./src/constants/contracts.ts).\n\n## Install\n\n```\n$ npm install @indexcoop/flash-mint-sdk\n```\n\n## Limitations\n\nA limitation to be aware of (especially for getting quotes) is that the contracts\ncan only mint or redeem an exact amount of Index token.\n\nAdditionally, make sure that the (Index/Set) tokens have been approved on the\nspecific FlashMint contracts.\n\n## Usage\n\n### Quotes\n\nWith v3, while you could still use other quote providers individually, we recommend\nsolely using the `FlashMintQuoteProvider` which will do most of the guess work for you.\nThis provider will return the appropriate quotes for any Index token, automatically\nselecting the correct FlashMint contract for you - as well as preparing the call data.\n\n```typescript\nimport { FlashMintQuoteProvider, QuoteToken } from '@indexcoop/flash-mint-sdk'\n\n// Input/output token should be of type QuoteToken with the following properties\nconst inputToken: QuoteToken = {\n  symbol: 'ETH',\n  decimals: 18,\n  address: '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',\n}\nconst outputToken: QuoteToken = {\n  symbol: 'icETH',\n  decimals: 18,\n  address: '0xc4506022Fb8090774E8A628d5084EED61D9B99Ee',\n}\n\n// Add a RPC URL e.g. from Alchemy\nconst rpcUrl = ''\n// Use the 0x v2 swap quote provider configured with your API key or provide your \n// own adapter implementing the `SwapQuoteProviderV2` interface.\nconst zeroexV2SwapQuoteProvider = new ZeroExV2SwapQuoteProvider()\n// As 0x v2 does not allow swap quotes by defining outputAmounts any longer we're\n// now added a second swap quote provider for that - Li.Fi (provide API key).\nconst lifiSwapQuoteProvider = new LiFiSwapQuoteProvider(apiKey, integrator)\nconst quoteProvider = new FlashMintQuoteProvider(\n  rpcUrl,\n  zeroexV2SwapQuoteProvider,\n  lifiSwapQuoteProvider\n)\n// Option 1 - get a quote for a specified index token amount\nconst quote = await quoteProvider.getQuote({\n  chainId: 1,\n  isMinting: true,\n  inputToken,\n  outputToken,\n  indexTokenAmount: wei(1).toString(),\n  inputTokenAmount: wei(1).toString(),\n  slippage: 0.1,\n})\n// Option 2 - get a quote for a fixed input amount (am approx. indexTokenAmount \n// should still be added to the request).\nawait quoteProvider.getFixedInputQuote({\n  chainId: 1,\n  isMinting: true,\n  inputToken,\n  outputToken,\n  indexTokenAmount: wei(1).toString(),\n  inputTokenAmount: wei(1).toString(),\n  slippage: 0.1,\n})\n```\n\nThe returned quote is an object including meta data but most importantly the `inputOutputAmount`\nwhich is the quote for the given request\\* and a `tx` object which is a tx object\nbasically ready to be send.\n\n```typescript\ninterface FlashMintQuote {\n  chainId: number\n  contractType: FlashMintContractType\n  contract: string\n  isMinting: boolean\n  inputToken: QuoteToken\n  outputToken: QuoteToken\n  inputAmount: BigNumber\n  outputAmount: BigNumber\n  indexTokenAmount: BigNumber\n  inputOutputAmount: BigNumber\n  slippage: number\n  tx: TransactionRequest\n}\n```\n\n\\* for minting this will be the input amount, for redeeming the output amount\n\n## Flashmint\n\nTo execute the flash minting of an Index token for convenience use the `tx` object\nreturned by the `FlashMintQuoteProvider`.\n\n```typescript\n...\nconst quoteProvider = new FlashMintQuoteProvider(\n      rpcUrl,\n      zeroexV2SwapQuoteProvider,\n      lifiSwapQuoteProvider\n    )\nconst quote = await quoteProvider.getQuote({...})\nlet tx = quote.tx\nconst gasEstimate = await provider.estimateGas(tx)\ntx.gasLimit = gasEstimate\nconst res = await signer.sendTransaction(tx)\nconsole.log(res.hash)\n```\n\n## Development\n\n### .env vars\n\nWhen adding new .env vars do not forget to update the [publish.yml](.github/workflows/publish.yml)\n\n### Adding a new Index token\n\n0. add a test for determining the correct issuance module (only if using 0x) [here](./src/utils/issuance-modules.test.ts)\n1. add a test for determining the correct contract [here](./src/utils/contracts.test.ts)\n2. if there is a new FlashMint contract, add it as described [below](#adding-a-new-contract)\n3. add symbol to `function getContractType(token: string)` in [src/quote/provider/utils.ts](./src/quote//provider/utils.ts) and add a test\n4. additionally, add a test in [tests](./src/tests/)\n\n### Adding a new contract\n\n0. add the contract address in [constants](./src/constants/contracts.ts)\n1. add appropriate getters and tests in [utils/contracts](./src/utils/contracts.ts)\n2. add a new [builder](./src/flashmint/builders/) and [quote provider](./src/quote/)\n3. The new quote provider has to be integrated into the [FlashMintQuoteProvider](./src/quote/indexQuoteProvider.ts)\n\n## Testing\n\n```\n// run all tests\nnpm run test:hardhat src/tests/e2e/index.test.ts\n\n// run tests for a specific chain\nnpm run test:hardhat src/tests/e2e/index.test.ts -- --grep \"chain 1\"\n\n// run tests for a specific product exiting on first failure\nnpm run test:hardhat src/tests/e2e/index.test.ts -- --bail --grep \"hyETH\"\n```\n\n## Debugging\n\n```\ncast run --rpc-url http://127.0.0.1:8545/ 0x8ea51dd6cec3e1bea98b143715fe9a1375ca7e01c120f0065cb4ef6c0e0dd23a // mainnet\ncast run --rpc-url http://127.0.0.1:8453/ 0x362c844b7a1ecd5feb14e389eccd68d34373281892e5a6d387131ed9bfef9b01 // base\ncast run --rpc-url http://127.0.0.1:8548/ 0x5434cd90c4b06faed9d77d256e5d569b94c1ef88217d25e82bc6cf1b84153b69 // arbitrum\n```\n\n## Contributing\n\nWe will encourage contributing and open dialog how to improve the SDK. How though\nis still TBD. 🚧 In the meantime just open an issue.\n\n## License\n\nCopyright © 2025 Index Coop.\n\n[MIT License](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findexcoop%2Fflash-mint-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findexcoop%2Fflash-mint-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findexcoop%2Fflash-mint-sdk/lists"}