-
Notifications
You must be signed in to change notification settings - Fork 48
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
Feat: FlashmintNAV #186
Conversation
*/ | ||
function issueSetFromExactETH( | ||
ISetToken _setToken, | ||
uint256 _minSetTokenAmount, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janndriessen exactly. See example for issuance here https://github.com/IndexCoop/index-coop-smart-contracts/pull/186/files#r1768661768.
And for redemption https://github.com/IndexCoop/index-coop-smart-contracts/pull/186/files#r1768665399
ISetToken _setToken, | ||
address _inputToken, | ||
uint256 _inputTokenAmount, | ||
DEXAdapterV2.SwapData memory _reserveAssetSwapData |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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:
index-coop-smart-contracts/test/integration/ethereum/flashMintNAV.spec.ts
Lines 336 to 341 in e21b456
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 |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this 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. 👍
/** | ||
* @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). | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
erc4626Oracle = await deployer.setV2.deployERC4626Oracle( | ||
tokenAddresses.gtUSDC, | ||
usdc(1), | ||
"gtUSDC - USDC Calculated Oracle", | ||
); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚢
No description provided.