Skip to content

Commit

Permalink
Merge pull request #76 from IndexCoop/task/add-slippage-for-hyeth
Browse files Browse the repository at this point in the history
feat: add slippage for hyeth
  • Loading branch information
janndriessen authored Jul 3, 2024
2 parents 279062c + acfd0ac commit 9f3d1a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/quote/flashmint/hyeth/component-quotes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { BigNumber } from '@ethersproject/bignumber'
import { Address, isAddressEqual } from 'viem'

import { SwapQuoteProvider } from 'quote/swap'
import { slippageAdjustedTokenAmount } from 'utils'

import { QuoteToken } from '../../../interfaces'

Expand Down Expand Up @@ -175,9 +176,15 @@ export class ComponentQuotesProvider {
.reduce((prevValue, currValue) => {
return currValue + prevValue
})
const adjustedAmount = slippageAdjustedTokenAmount(
BigNumber.from(inputOutputTokenAmount.toString()),
isMinting ? inputToken.decimals : outputToken.decimals,
this.slippage,
isMinting
)
return {
componentQuotes: [],
inputOutputTokenAmount,
inputOutputTokenAmount: adjustedAmount.toBigInt(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/tests/hyeth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ describe('hyETH', () => {
await factory.executeTx()
})

test.skip('can mint with ETH (large amout)', async () => {
test('can mint with ETH (large amout)', async () => {
await factory.fetchQuote({
isMinting: true,
inputToken: eth,
outputToken: indexToken,
indexTokenAmount: wei('300'),
indexTokenAmount: wei('550'),
slippage: 0.5,
})
await factory.executeTx()
Expand Down

0 comments on commit 9f3d1a2

Please sign in to comment.