From f98524ff2af72350ece7d212372c3f61f74c74aa Mon Sep 17 00:00:00 2001 From: JD Date: Fri, 20 Dec 2024 10:41:46 -0500 Subject: [PATCH] fix: hyeth quotes for erc20's (#104) * fix: hyeth quotes for erc20's * make test more robust --- .../flashmint/hyeth/component-quotes/index.ts | 7 ++++++- src/tests/hyeth.test.ts | 15 ++++++++++++++- src/utils/component-swap-data.test.ts | 3 ++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/quote/flashmint/hyeth/component-quotes/index.ts b/src/quote/flashmint/hyeth/component-quotes/index.ts index ade71be3..05f15faf 100644 --- a/src/quote/flashmint/hyeth/component-quotes/index.ts +++ b/src/quote/flashmint/hyeth/component-quotes/index.ts @@ -86,7 +86,12 @@ export class ComponentQuotesProvider { const amount = positions[index].toBigInt() if (isAddressEqual(component, this.wethAddress)) { - quotePromises.push(Promise.resolve(amount)) + if ( + isAddressEqual(inputTokenAddress, this.wethAddress) || + isAddressEqual(outputTokenAddress, this.wethAddress) + ) { + quotePromises.push(Promise.resolve(amount)) + } } if (this.isAcross(component)) { diff --git a/src/tests/hyeth.test.ts b/src/tests/hyeth.test.ts index 2865deae..dd9e831e 100644 --- a/src/tests/hyeth.test.ts +++ b/src/tests/hyeth.test.ts @@ -7,6 +7,7 @@ import { TestFactory, transferFromWhale, wei, + wrapETH, } from './utils' describe('hyETH', () => { @@ -31,6 +32,18 @@ describe('hyETH', () => { await factory.executeTx() }) + test.skip('can mint with WETH', async () => { + const quote = await factory.fetchQuote({ + isMinting: true, + inputToken: getTokenByChainAndSymbol(chainId, 'WETH'), + outputToken: indexToken, + indexTokenAmount: wei('3').toString(), + slippage: 0.5, + }) + await wrapETH(quote.inputAmount, factory.getSigner(), chainId) + await factory.executeTx() + }) + test.skip('can mint with ETH (large amout)', async () => { await factory.fetchQuote({ isMinting: true, @@ -42,7 +55,7 @@ describe('hyETH', () => { await factory.executeTx() }) - test.skip('can mint with USDC', async () => { + test('can mint with USDC', async () => { const quote = await factory.fetchQuote({ isMinting: true, inputToken: usdc, diff --git a/src/utils/component-swap-data.test.ts b/src/utils/component-swap-data.test.ts index f2b76fca..e9be7644 100644 --- a/src/utils/component-swap-data.test.ts +++ b/src/utils/component-swap-data.test.ts @@ -138,7 +138,8 @@ describe('getRedemptionComponentSwapData()', () => { const dexData = componentSwapData[i].dexData expect(dexData.exchange).toEqual(Exchange.UniV3) expect(dexData.fees.length).toBeGreaterThan(0) - expect(dexData.path).toEqual([usdc.toLowerCase(), weth]) + expect(dexData.path[0]).toEqual(usdc.toLowerCase()) + expect(dexData.path[1]).toEqual(weth) expect(dexData.pool).toEqual(AddressZero) expect(dexData.poolIds).toEqual([]) expect(