@indexcoop/flash-mint-sdk
Version:
The FlashMintSDK of the Index Coop.
1,951 lines (1,939 loc) • 351 kB
JavaScript
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
AddressZero: () => AddressZero,
BasicIssuanceModuleAddress: () => BasicIssuanceModuleAddress,
ChainId: () => ChainId,
Contracts: () => Contracts,
DebtIssuanceModuleV2Address: () => DebtIssuanceModuleV2Address,
ETH: () => ETH,
EthAddress: () => EthAddress,
Exchange: () => Exchange,
FlashMintAbis: () => FlashMintAbis,
FlashMintContractType: () => FlashMintContractType,
FlashMintHyEthQuoteProvider: () => FlashMintHyEthQuoteProvider,
FlashMintHyEthTransactionBuilder: () => FlashMintHyEthTransactionBuilder,
FlashMintQuoteProvider: () => FlashMintQuoteProvider,
FlashMintQuoteProviderErrorCode: () => FlashMintQuoteProviderErrorCode,
HashZero: () => HashZero,
IndexDebtIssuanceModuleV2Address_v2: () => IndexDebtIssuanceModuleV2Address_v2,
LeveragedZeroExBuilder: () => LeveragedZeroExBuilder,
LeveragedZeroExErrorCode: () => LeveragedZeroExErrorCode,
LeveragedZeroExQuoteProvider: () => LeveragedZeroExQuoteProvider,
LiFiSwapQuoteProvider: () => LiFiSwapQuoteProvider,
StaticQuoteProvider: () => StaticQuoteProvider,
ZeroExQuoteProvider: () => ZeroExQuoteProvider,
ZeroExTransactionBuilder: () => ZeroExTransactionBuilder,
ZeroExV2AllowanceHolderContract: () => ZeroExV2AllowanceHolderContract,
ZeroExV2SwapQuoteProvider: () => ZeroExV2SwapQuoteProvider,
getFlashMintContract: () => getFlashMintContract,
getFlashMintHyEthContract: () => getFlashMintHyEthContract,
getFlashMintZeroExContract: () => getFlashMintZeroExContract,
getFlashMintZeroExContractForToken: () => getFlashMintZeroExContractForToken,
getIssuanceModule: () => getIssuanceModule,
getRequiredComponents: () => getRequiredComponents2,
getTokenAddressOrWeth: () => getTokenAddressOrWeth,
isZeroExV2AllowanceHolderContract: () => isZeroExV2AllowanceHolderContract,
noopSwapData: () => noopSwapData,
slippageAdjustedTokenAmount: () => slippageAdjustedTokenAmount,
wei: () => wei
});
module.exports = __toCommonJS(index_exports);
// src/constants/addresses.ts
var AddressZero = "0x0000000000000000000000000000000000000000";
var EthAddress = "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE";
var HashZero = "0x0000000000000000000000000000000000000000000000000000000000000000";
var ZeroExV2AllowanceHolderContract = "0x0000000000001fF3684f28c67538d4D072C22734";
// src/constants/chains.ts
var ChainId = /* @__PURE__ */ ((ChainId2) => {
ChainId2[ChainId2["Mainnet"] = 1] = "Mainnet";
ChainId2[ChainId2["Optimism"] = 10] = "Optimism";
ChainId2[ChainId2["Polygon"] = 137] = "Polygon";
ChainId2[ChainId2["Base"] = 8453] = "Base";
ChainId2[ChainId2["Arbitrum"] = 42161] = "Arbitrum";
return ChainId2;
})(ChainId || {});
// src/constants/contracts.ts
var Contracts = {
[1 /* Mainnet */]: {
DebtIssuanceModuleV3: "0x86B7C605C03B9bbb0F6A25FBBb63baF15d875193",
ExchangeIssuanceZeroEx: "0x8760FCD90c82e1e95e55047b6b6A0F22dc07d7d1",
// redeployed version (March 2025)
FlashMintHyEthV3: "0xCb1eEA349f25288627f008C5e2a69b684bddDf49",
FlashMintLeveragedZeroEx: "0x58093c03B4e7804D0127A6D0A5D86dcbd5652113",
FlashMintLeveragedZeroEx_AaveV2: "0x8B46956eA9a87c0AD3cb71911dDdEd23bE10e04d",
FlashMintLeveragedAaveFL: "0xb2eb42e5a360834676df36fb3a00aa398dc9d721"
},
[42161 /* Arbitrum */]: {
DebtIssuanceModuleV3: "0x4ac26c26116fa976352b70700af58bc2442489d8",
FlashMintLeveragedZeroEx: "0xdb4b7d3f812D0A8D98A1E17F9750c4E7a6477291",
// Exit ramp for post-disengage AAVE2x and LINK2x. Unwraps the SetToken's
// aToken components via Aave V3 Pool.withdraw, then swaps each underlying
// to a chosen output token via DEXAdapterV3 (UniV3 paths).
FlashMintAaveDelevered: "0x85eC64C97b6E17e7092cE584a2643C6C824E51FC"
},
[8453 /* Base */]: {
DebtIssuanceModuleV3: "0xa30E87311407dDcF1741901A8F359b6005252F22",
FlashMintLeveragedZeroEx: "0xBbE31D5946Dd3dabf797744732A7E18cbb4DE2a9",
// Non-leveraged FlashMint with DEXAdapterV5 (Aerodrome SlipStream support).
// Used for the post-disengage Morpho leverage tokens (uSOL2x/3x, uSUI2x/3x,
// uXRP2x/3x) that the leveraged flashmints reject with "TOO MANY COMPONENTS".
FlashMintDexV5: "0xdeB2BB9f5F848eCDd4983f908748793dAeC32c7d"
}
};
var IndexDebtIssuanceModuleV2Address_v2 = "0x04b59F9F09750C044D7CfbC177561E409085f0f3";
var BasicIssuanceModuleAddress = "0xd8EF3cACe8b4907117a45B0b125c68560532F94D";
var DebtIssuanceModuleV2Address = "0x69a592D2129415a4A1d1b1E309C17051B7F28d57";
// src/utils/abis.ts
var import_chains2 = require("viem/chains");
// src/constants/abis/FlashMintLeveragedZeroEx.json
var FlashMintLeveragedZeroEx_default = [
{
inputs: [
{
internalType: "contract IController",
name: "_setController",
type: "address"
},
{
internalType: "contract IDebtIssuanceModule",
name: "_debtIssuanceModule",
type: "address"
},
{
internalType: "contract IMorphoLeverageModule",
name: "_morphoLeverageModule",
type: "address"
},
{
internalType: "contract IMorphoLeverageModule",
name: "_aaveLeverageModule",
type: "address"
},
{
internalType: "contract IMorpho",
name: "_morpho",
type: "address"
},
{
internalType: "contract IPool",
name: "_aavePool",
type: "address"
},
{ internalType: "contract IWETH", name: "_weth", type: "address" },
{ internalType: "address", name: "_swapTarget", type: "address" }
],
stateMutability: "nonpayable",
type: "constructor"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "_recipient",
type: "address"
},
{
indexed: true,
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "_inputToken",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "_amountSetIssued",
type: "uint256"
}
],
name: "FlashMint",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "_recipient",
type: "address"
},
{
indexed: true,
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "_outputToken",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "_amountSetRedeemed",
type: "uint256"
}
],
name: "FlashRedeem",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "previousOwner",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "OwnershipTransferred",
type: "event"
},
{
inputs: [],
name: "ETH_ADDRESS",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "ROUNDING_ERROR_MARGIN",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "aaveLeverageModule",
outputs: [
{
internalType: "contract IMorphoLeverageModule",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "aavePool",
outputs: [
{ internalType: "contract IPool", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "approveSetToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{ internalType: "contract IERC20", name: "_token", type: "address" }
],
name: "approveToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract IERC20[]",
name: "_tokens",
type: "address[]"
}
],
name: "approveTokens",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "debtIssuanceModule",
outputs: [
{
internalType: "contract IDebtIssuanceModule",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{ internalType: "bool", name: "_isIssuance", type: "bool" },
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "getLeveragedTokenData",
outputs: [
{
components: [
{
internalType: "address",
name: "collateralToken",
type: "address"
},
{
internalType: "address",
name: "collateralAToken",
type: "address"
},
{
internalType: "uint256",
name: "collateralAmount",
type: "uint256"
},
{ internalType: "address", name: "debtToken", type: "address" },
{ internalType: "uint256", name: "debtAmount", type: "uint256" }
],
internalType: "struct FlashMintLeveragedZeroEx.LeveragedTokenData",
name: "",
type: "tuple"
}
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{ internalType: "address", name: "_inputToken", type: "address" },
{
internalType: "uint256",
name: "_maxAmountInputToken",
type: "uint256"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroEx.SwapData",
name: "_swapDataDebtForCollateral",
type: "tuple"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroEx.SwapData",
name: "_swapDataInputToken",
type: "tuple"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "issueExactSetFromERC20",
outputs: [
{ internalType: "uint256[]", name: "", type: "uint256[]" }
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroEx.SwapData",
name: "_swapDataDebtForCollateral",
type: "tuple"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroEx.SwapData",
name: "_swapDataInputToken",
type: "tuple"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "issueExactSetFromETH",
outputs: [
{ internalType: "uint256[]", name: "", type: "uint256[]" }
],
stateMutability: "payable",
type: "function"
},
{
inputs: [],
name: "morpho",
outputs: [
{ internalType: "contract IMorpho", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "morphoLeverageModule",
outputs: [
{
internalType: "contract IMorphoLeverageModule",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{ internalType: "uint256", name: "assets", type: "uint256" },
{ internalType: "bytes", name: "data", type: "bytes" }
],
name: "onMorphoFlashLoan",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "owner",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{ internalType: "address", name: "_outputToken", type: "address" },
{
internalType: "uint256",
name: "_minAmountOutputToken",
type: "uint256"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroEx.SwapData",
name: "_swapDataCollateralForDebt",
type: "tuple"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroEx.SwapData",
name: "_swapDataOutputToken",
type: "tuple"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "redeemExactSetForERC20",
outputs: [
{ internalType: "uint256[]", name: "", type: "uint256[]" }
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{
internalType: "uint256",
name: "_minAmountOutputToken",
type: "uint256"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroEx.SwapData",
name: "_swapDataCollateralForDebt",
type: "tuple"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroEx.SwapData",
name: "_swapDataOutputToken",
type: "tuple"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "redeemExactSetForETH",
outputs: [
{ internalType: "uint256[]", name: "", type: "uint256[]" }
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "renounceOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "setController",
outputs: [
{ internalType: "contract IController", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{ internalType: "address", name: "_swapTarget", type: "address" },
{ internalType: "bool", name: "_isAllowed", type: "bool" }
],
name: "setSwapTargetWhitelist",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [{ internalType: "address", name: "", type: "address" }],
name: "swapTargetWhitelist",
outputs: [{ internalType: "bool", name: "", type: "bool" }],
stateMutability: "view",
type: "function"
},
{
inputs: [
{ internalType: "address", name: "newOwner", type: "address" }
],
name: "transferOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "weth",
outputs: [
{ internalType: "contract IWETH", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{ internalType: "contract IERC20", name: "_token", type: "address" }
],
name: "withdrawToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{ stateMutability: "payable", type: "receive" }
];
// src/constants/abis/FlashMintLeveragedZeroExBalancerFL.json
var FlashMintLeveragedZeroExBalancerFL_default = [
{
inputs: [
{
internalType: "contract IController",
name: "_setController",
type: "address"
},
{
internalType: "contract IDebtIssuanceModule",
name: "_debtIssuanceModule",
type: "address"
},
{
internalType: "contract IMorphoLeverageModule",
name: "_morphoLeverageModule",
type: "address"
},
{
internalType: "contract IMorphoLeverageModule",
name: "_aaveLeverageModule",
type: "address"
},
{
internalType: "contract IVault",
name: "_balancerV2Vault",
type: "address"
},
{
internalType: "contract IPool",
name: "_aavePool",
type: "address"
},
{ internalType: "contract IWETH", name: "_weth", type: "address" },
{ internalType: "address", name: "_swapTarget", type: "address" }
],
stateMutability: "nonpayable",
type: "constructor"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "_recipient",
type: "address"
},
{
indexed: true,
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "_inputToken",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "_amountSetIssued",
type: "uint256"
}
],
name: "FlashMint",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "_recipient",
type: "address"
},
{
indexed: true,
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "_outputToken",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "_amountSetRedeemed",
type: "uint256"
}
],
name: "FlashRedeem",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "previousOwner",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "OwnershipTransferred",
type: "event"
},
{
inputs: [],
name: "ETH_ADDRESS",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "ROUNDING_ERROR_MARGIN",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "aaveLeverageModule",
outputs: [
{
internalType: "contract IMorphoLeverageModule",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "aavePool",
outputs: [
{ internalType: "contract IPool", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "approveSetToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{ internalType: "contract IERC20", name: "_token", type: "address" }
],
name: "approveToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract IERC20[]",
name: "_tokens",
type: "address[]"
}
],
name: "approveTokens",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "balancerV2Vault",
outputs: [
{ internalType: "contract IVault", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "debtIssuanceModule",
outputs: [
{
internalType: "contract IDebtIssuanceModule",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{ internalType: "bool", name: "_isIssuance", type: "bool" },
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "getLeveragedTokenData",
outputs: [
{
components: [
{
internalType: "address",
name: "collateralToken",
type: "address"
},
{
internalType: "address",
name: "collateralAToken",
type: "address"
},
{
internalType: "uint256",
name: "collateralAmount",
type: "uint256"
},
{ internalType: "address", name: "debtToken", type: "address" },
{ internalType: "uint256", name: "debtAmount", type: "uint256" }
],
internalType: "struct FlashMintLeveragedZeroExBalancerFL.LeveragedTokenData",
name: "",
type: "tuple"
}
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{ internalType: "address", name: "_inputToken", type: "address" },
{
internalType: "uint256",
name: "_maxAmountInputToken",
type: "uint256"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroExBalancerFL.SwapData",
name: "_swapDataDebtForCollateral",
type: "tuple"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroExBalancerFL.SwapData",
name: "_swapDataInputToken",
type: "tuple"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "issueExactSetFromERC20",
outputs: [
{ internalType: "uint256[]", name: "", type: "uint256[]" }
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroExBalancerFL.SwapData",
name: "_swapDataDebtForCollateral",
type: "tuple"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroExBalancerFL.SwapData",
name: "_swapDataInputToken",
type: "tuple"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "issueExactSetFromETH",
outputs: [
{ internalType: "uint256[]", name: "", type: "uint256[]" }
],
stateMutability: "payable",
type: "function"
},
{
inputs: [],
name: "morphoLeverageModule",
outputs: [
{
internalType: "contract IMorphoLeverageModule",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "owner",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract IERC20[]",
name: "tokens",
type: "address[]"
},
{ internalType: "uint256[]", name: "amounts", type: "uint256[]" },
{
internalType: "uint256[]",
name: "feeAmounts",
type: "uint256[]"
},
{ internalType: "bytes", name: "userData", type: "bytes" }
],
name: "receiveFlashLoan",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{ internalType: "address", name: "_outputToken", type: "address" },
{
internalType: "uint256",
name: "_minAmountOutputToken",
type: "uint256"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroExBalancerFL.SwapData",
name: "_swapDataCollateralForDebt",
type: "tuple"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroExBalancerFL.SwapData",
name: "_swapDataOutputToken",
type: "tuple"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "redeemExactSetForERC20",
outputs: [
{ internalType: "uint256[]", name: "", type: "uint256[]" }
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{ internalType: "uint256", name: "_setAmount", type: "uint256" },
{
internalType: "uint256",
name: "_minAmountOutputToken",
type: "uint256"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroExBalancerFL.SwapData",
name: "_swapDataCollateralForDebt",
type: "tuple"
},
{
components: [
{
internalType: "address",
name: "swapTarget",
type: "address"
},
{ internalType: "bytes", name: "callData", type: "bytes" }
],
internalType: "struct FlashMintLeveragedZeroExBalancerFL.SwapData",
name: "_swapDataOutputToken",
type: "tuple"
},
{ internalType: "bool", name: "_isAave", type: "bool" }
],
name: "redeemExactSetForETH",
outputs: [
{ internalType: "uint256[]", name: "", type: "uint256[]" }
],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "renounceOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "setController",
outputs: [
{ internalType: "contract IController", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{ internalType: "address", name: "_swapTarget", type: "address" },
{ internalType: "bool", name: "_isAllowed", type: "bool" }
],
name: "setSwapTargetWhitelist",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [{ internalType: "address", name: "", type: "address" }],
name: "swapTargetWhitelist",
outputs: [{ internalType: "bool", name: "", type: "bool" }],
stateMutability: "view",
type: "function"
},
{
inputs: [
{ internalType: "address", name: "newOwner", type: "address" }
],
name: "transferOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "weth",
outputs: [
{ internalType: "contract IWETH", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{ internalType: "contract IERC20", name: "_token", type: "address" }
],
name: "withdrawToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{ stateMutability: "payable", type: "receive" }
];
// src/utils/abis.ts
var FlashMintAbis = {
[Contracts[import_chains2.arbitrum.id].FlashMintLeveragedZeroEx]: FlashMintLeveragedZeroExBalancerFL_default,
[Contracts[import_chains2.base.id].FlashMintLeveragedZeroEx]: FlashMintLeveragedZeroEx_default,
[Contracts[import_chains2.mainnet.id].FlashMintLeveragedZeroEx]: FlashMintLeveragedZeroEx_default,
[Contracts[import_chains2.mainnet.id].FlashMintLeveragedZeroEx_AaveV2]: FlashMintLeveragedZeroEx_default
};
// src/utils/addresses.ts
var import_tokenlists = require("@indexcoop/tokenlists");
function getTokenAddressOrWeth(token, chainId) {
return (0, import_tokenlists.isAddressEqual)(token, EthAddress) ? (0, import_tokenlists.getTokenByChainAndSymbol)(chainId, "WETH").address : token;
}
function isZeroExV2AllowanceHolderContract(address) {
return (0, import_tokenlists.isAddressEqual)(address, ZeroExV2AllowanceHolderContract);
}
// src/utils/contracts.ts
var import_contracts2 = require("@ethersproject/contracts");
// src/constants/abis/ExchangeIssuanceZeroEx.json
var ExchangeIssuanceZeroEx_default = [
{
inputs: [
{ internalType: "address", name: "_weth", type: "address" },
{
internalType: "contract IController",
name: "_setController",
type: "address"
},
{ internalType: "address", name: "_swapTarget", type: "address" }
],
stateMutability: "nonpayable",
type: "constructor"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "_recipient",
type: "address"
},
{
indexed: true,
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
indexed: true,
internalType: "contract IERC20",
name: "_inputToken",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "_amountInputToken",
type: "uint256"
},
{
indexed: false,
internalType: "uint256",
name: "_amountSetIssued",
type: "uint256"
}
],
name: "ExchangeIssue",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "_recipient",
type: "address"
},
{
indexed: true,
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
indexed: true,
internalType: "contract IERC20",
name: "_outputToken",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "_amountSetRedeemed",
type: "uint256"
},
{
indexed: false,
internalType: "uint256",
name: "_amountOutputToken",
type: "uint256"
}
],
name: "ExchangeRedeem",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "previousOwner",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "OwnershipTransferred",
type: "event"
},
{
inputs: [],
name: "ETH_ADDRESS",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "WETH",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
internalType: "address",
name: "_issuanceModule",
type: "address"
}
],
name: "approveSetToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract IERC20",
name: "_token",
type: "address"
},
{ internalType: "address", name: "_spender", type: "address" }
],
name: "approveToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract IERC20[]",
name: "_tokens",
type: "address[]"
},
{ internalType: "address", name: "_spender", type: "address" }
],
name: "approveTokens",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_issuanceModule",
type: "address"
},
{ internalType: "bool", name: "_isDebtIssuance", type: "bool" },
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
internalType: "uint256",
name: "_amountSetToken",
type: "uint256"
}
],
name: "getRequiredIssuanceComponents",
outputs: [
{
internalType: "address[]",
name: "components",
type: "address[]"
},
{ internalType: "uint256[]", name: "positions", type: "uint256[]" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "address",
name: "_issuanceModule",
type: "address"
},
{ internalType: "bool", name: "_isDebtIssuance", type: "bool" },
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
internalType: "uint256",
name: "_amountSetToken",
type: "uint256"
}
],
name: "getRequiredRedemptionComponents",
outputs: [
{
internalType: "address[]",
name: "components",
type: "address[]"
},
{ internalType: "uint256[]", name: "positions", type: "uint256[]" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
internalType: "uint256",
name: "_amountSetToken",
type: "uint256"
},
{
internalType: "bytes[]",
name: "_componentQuotes",
type: "bytes[]"
},
{
internalType: "address",
name: "_issuanceModule",
type: "address"
},
{ internalType: "bool", name: "_isDebtIssuance", type: "bool" }
],
name: "issueExactSetFromETH",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "payable",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
internalType: "contract IERC20",
name: "_inputToken",
type: "address"
},
{
internalType: "uint256",
name: "_amountSetToken",
type: "uint256"
},
{
internalType: "uint256",
name: "_maxAmountInputToken",
type: "uint256"
},
{
internalType: "bytes[]",
name: "_componentQuotes",
type: "bytes[]"
},
{
internalType: "address",
name: "_issuanceModule",
type: "address"
},
{ internalType: "bool", name: "_isDebtIssuance", type: "bool" }
],
name: "issueExactSetFromToken",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "owner",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
internalType: "uint256",
name: "_amountSetToken",
type: "uint256"
},
{
internalType: "uint256",
name: "_minEthReceive",
type: "uint256"
},
{
internalType: "bytes[]",
name: "_componentQuotes",
type: "bytes[]"
},
{
internalType: "address",
name: "_issuanceModule",
type: "address"
},
{ internalType: "bool", name: "_isDebtIssuance", type: "bool" }
],
name: "redeemExactSetForETH",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
internalType: "contract IERC20",
name: "_outputToken",
type: "address"
},
{
internalType: "uint256",
name: "_amountSetToken",
type: "uint256"
},
{
internalType: "uint256",
name: "_minOutputReceive",
type: "uint256"
},
{
internalType: "bytes[]",
name: "_componentQuotes",
type: "bytes[]"
},
{
internalType: "address",
name: "_issuanceModule",
type: "address"
},
{ internalType: "bool", name: "_isDebtIssuance", type: "bool" }
],
name: "redeemExactSetForToken",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "renounceOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "setController",
outputs: [
{ internalType: "contract IController", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "swapTarget",
outputs: [{ internalType: "address", name: "", type: "address" }],
stateMutability: "view",
type: "function"
},
{
inputs: [
{ internalType: "address", name: "newOwner", type: "address" }
],
name: "transferOwnership",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract IERC20[]",
name: "_tokens",
type: "address[]"
},
{ internalType: "address payable", name: "_to", type: "address" }
],
name: "withdrawTokens",
outputs: [],
stateMutability: "payable",
type: "function"
},
{ stateMutability: "payable", type: "receive" }
];
// src/constants/abis/FlashMintHyEth.json
var FlashMintHyEth_default = [
{
inputs: [
{
components: [
{
internalType: "address",
name: "quickRouter",
type: "address"
},
{
internalType: "address",
name: "sushiRouter",
type: "address"
},
{
internalType: "address",
name: "uniV3Router",
type: "address"
},
{
internalType: "address",
name: "uniV3Quoter",
type: "address"
},
{
internalType: "address",
name: "curveAddressProvider",
type: "address"
},
{
internalType: "address",
name: "curveCalculator",
type: "address"
},
{
internalType: "address",
name: "balV2Vault",
type: "address"
},
{ internalType: "address", name: "weth", type: "address" }
],
internalType: "struct DEXAdapterV3.Addresses",
name: "_dexAddresses",
type: "tuple"
},
{
internalType: "contract IController",
name: "_setController",
type: "address"
},
{
internalType: "contract IDebtIssuanceModule",
name: "_issuanceModule",
type: "address"
},
{
internalType: "contract IStETH",
name: "_stETH",
type: "address"
},
{ internalType: "address", name: "_stEthETHPool", type: "address" }
],
stateMutability: "nonpayable",
type: "constructor"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "_recipient",
type: "address"
},
{
indexed: true,
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
indexed: true,
internalType: "contract IERC20",
name: "_inputToken",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "_amountInputToken",
type: "uint256"
},
{
indexed: false,
internalType: "uint256",
name: "_amountSetIssued",
type: "uint256"
}
],
name: "FlashMint",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "_recipient",
type: "address"
},
{
indexed: true,
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
indexed: true,
internalType: "contract IERC20",
name: "_outputToken",
type: "address"
},
{
indexed: false,
internalType: "uint256",
name: "_amountSetRedeemed",
type: "uint256"
},
{
indexed: false,
internalType: "uint256",
name: "_amountOutputToken",
type: "uint256"
}
],
name: "FlashRedeem",
type: "event"
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "address",
name: "previousOwner",
type: "address"
},
{
indexed: true,
internalType: "address",
name: "newOwner",
type: "address"
}
],
name: "OwnershipTransferred",
type: "event"
},
{
inputs: [],
name: "ROUNDING_ERROR",
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "acrossPool",
outputs: [
{
internalType: "contract IAcrossHubPoolV2",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "acrossToken",
outputs: [
{ internalType: "contract IERC20", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "agETH",
outputs: [
{ internalType: "contract IERC20", name: "", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
}
],
name: "approveSetToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [
{
internalType: "contract IERC20",
name: "_token",
type: "address"
},
{ internalType: "address", name: "_spender", type: "address" },
{ internalType: "uint256", name: "_allowance", type: "uint256" }
],
name: "approveToken",
outputs: [],
stateMutability: "nonpayable",
type: "function"
},
{
inputs: [],
name: "dexAdapter",
outputs: [
{ internalType: "address", name: "quickRouter", type: "address" },
{ internalType: "address", name: "sushiRouter", type: "address" },
{ internalType: "address", name: "uniV3Router", type: "address" },
{ internalType: "address", name: "uniV3Quoter", type: "address" },
{
internalType: "address",
name: "curveAddressProvider",
type: "address"
},
{
internalType: "address",
name: "curveCalculator",
type: "address"
},
{ internalType: "address", name: "balV2Vault", type: "address" },
{ internalType: "address", name: "weth", type: "address" }
],
stateMutability: "view",
type: "function"
},
{
inputs: [{ internalType: "address", name: "", type: "address" }],
name: "erc4626Components",
outputs: [{ internalType: "bool", name: "", type: "bool" }],
stateMutability: "view",
type: "function"
},
{
inputs: [],
name: "issuanceModule",
outputs: [
{
internalType: "contract IDebtIssuanceModule",
name: "",
type: "address"
}
],
stateMutability: "view",
type: "function"
},
{
inputs: [
{
internalType: "contract ISetToken",
name: "_setToken",
type: "address"
},
{
internalType: "uint256",
name: "_amountSetToken",
type: "uint256"
},
{
internalType: "contract IERC20",
name: "_inputToken",
type: "address"
},
{
internalType: "uint256",
name: "_maxInputTokenAmount",
type: "uint256"
},
{
components: [
{ internalType: "address[]", name: "path", type: "address[]" },
{ internalT