Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: FlashmintNAV #186

Merged
merged 38 commits into from
Oct 3, 2024
Merged

Feat: FlashmintNAV #186

merged 38 commits into from
Oct 3, 2024

Conversation

edkim
Copy link
Contributor

@edkim edkim commented Sep 19, 2024

No description provided.

*/
function issueSetFromExactETH(
ISetToken _setToken,
uint256 _minSetTokenAmount,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janndriessen double-checking that you're able to integrate with this issuance function that doesn't return an exact amount of SetTokens?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edkim so we'd have to call getIssueAmount or getRedeemAmountOut to determine this minSetTokenAmount?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ISetToken _setToken,
address _inputToken,
uint256 _inputTokenAmount,
DEXAdapterV2.SwapData memory _reserveAssetSwapData

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@edkim reserve asset would be e.g. USDC? and then the regular swap data format e.g. if inputToken DAI for DAI-USDC for the given inputTokenAmount?

Copy link
Contributor Author

@edkim edkim Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, reserve asset is USDC for USDCY. So for issuing with DAI the swapData would look like this example test:

subjectSwapData = {
exchange: Exchange.UniV3,
fees: [100],
path: [addresses.tokens.dai, addresses.tokens.USDC],
pool: ADDRESS_ZERO,
};
.


it("should issue SetToken with ETH", async () => {
const setTokenOutEstimate = await subjectQuote();
subjectMinSetTokenOut = setTokenOutEstimate.mul(995).div(1000); // 0.5% slippage
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@janndriessen here's an example of getting the minSetTokenAmount for issuance

it("should redeem SetToken for ETH", async () => {
const outputAmountEstimate = await subjectQuote();
subjectMinOutputTokenAmount = outputAmountEstimate.mul(995).div(1000); // 0.5% slippage

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example of estimating minOutputTokenAmount when redeeming.

Copy link
Collaborator

@ckoopmann ckoopmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Only super minor nits regarding comments / styling.
Great work. 👍

contracts/interfaces/INAVIssuanceHook.sol Show resolved Hide resolved
contracts/exchangeIssuance/FlashMintNAV.sol Show resolved Hide resolved
contracts/exchangeIssuance/FlashMintNAV.sol Outdated Show resolved Hide resolved
Comment on lines +36 to +45
/**
* @title FlashMintNAV
* @author Index Cooperative
* @notice Part of a family of FlashMint contracts that allows users to issue and redeem SetTokens with a single input/output token (ETH/ERC20).
* Allows the caller to combine a DEX swap and a SetToken issuance or redemption in a single transaction.
* Supports SetTokens that use a NAV Issuance Module, and does not require use of off-chain APIs for swap quotes.
* The SetToken must be configured with a reserve asset that has liquidity on the exchanges supported by the DEXAdapterV2 library.
*
* See the FlashMint SDK for integrating any FlashMint contract (https://github.com/IndexCoop/flash-mint-sdk).
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Comment on lines +120 to +124
erc4626Oracle = await deployer.setV2.deployERC4626Oracle(
tokenAddresses.gtUSDC,
usdc(1),
"gtUSDC - USDC Calculated Oracle",
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noting this constructor's arguments may change soon IndexCoop/index-protocol#49

Copy link
Contributor

@pblivin0x pblivin0x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@pblivin0x pblivin0x merged commit bcec4c1 into master Oct 3, 2024
5 checks passed
@pblivin0x pblivin0x deleted the flashmint-nav-issuance branch October 3, 2024 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants