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

refactor: test factory #112

Merged
merged 5 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = {
chainId: 1,
forking: {
url: process.env.MAINNET_ALCHEMY_API,
blockNumber: 21582195,
// blockNumber: 21582195,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

going with the latest for now

},
chains: {
1: {
Expand Down
7 changes: 2 additions & 5 deletions src/tests/arbitrum/btc2x.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { ChainId } from 'constants/chains'
import {
QuoteTokens,
type TestFactory,
getArbitrumTestFactory,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
wei,
} from 'tests/utils'

Expand All @@ -16,8 +14,7 @@ const { eth } = QuoteTokens
describe('BTC2X (Arbitrum)', () => {
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(3, getTestRpcProvider(chainId))
factory = getArbitrumTestFactory(signer)
factory = getTestFactoryZeroEx(3, chainId)
})

test('can mint with ETH', async () => {
Expand Down
10 changes: 4 additions & 6 deletions src/tests/arbitrum/btc2xeth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ import { ChainId } from 'constants/chains'
import {
QuoteTokens,
type TestFactory,
getArbitrumTestFactory,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
wei,
} from 'tests/utils'

describe('BTC2xETH (Arbitrum)', () => {
const chainId = ChainId.Arbitrum
const { eth } = QuoteTokens
const btc2xEth = getTokenByChainAndSymbol(ChainId.Arbitrum, 'BTC2xETH')
const btc2xEth = getTokenByChainAndSymbol(chainId, 'BTC2xETH')
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(3, getTestRpcProvider(ChainId.Arbitrum))
factory = getArbitrumTestFactory(signer)
factory = getTestFactoryZeroEx(3, chainId)
})

test('can mint with ETH', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/tests/arbitrum/btc3x.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { getTokenByChainAndSymbol } from '@indexcoop/tokenlists'
import { ChainId } from 'constants/chains'
import {
getTestFactoryZeroEx,
QuoteTokens,
type TestFactory,
getArbitrumTestFactory,
getSignerAccount,
getTestRpcProvider,
wei,
} from 'tests/utils'

Expand All @@ -16,8 +14,7 @@ const { eth } = QuoteTokens
describe.skip('BTC3X (Arbitrum)', () => {
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(5, getTestRpcProvider(chainId))
factory = getArbitrumTestFactory(signer)
factory = getTestFactoryZeroEx(5, chainId)
})

test('can mint with ETH', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/tests/arbitrum/eth2x.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { ChainId } from 'constants/chains'
import {
QuoteTokens,
type TestFactory,
getArbitrumTestFactory,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
wei,
} from 'tests/utils'

Expand All @@ -16,8 +14,7 @@ const { eth } = QuoteTokens
describe('ETH2X (Arbitrum)', () => {
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(0, getTestRpcProvider(chainId))
factory = getArbitrumTestFactory(signer)
factory = getTestFactoryZeroEx(0, chainId)
})

test('can mint with ETH', async () => {
Expand Down
10 changes: 4 additions & 6 deletions src/tests/arbitrum/eth2xbtc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ import { ChainId } from 'constants/chains'
import {
QuoteTokens,
type TestFactory,
getArbitrumTestFactory,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
wei,
} from 'tests/utils'

describe('ETH2xBTC (Arbitrum)', () => {
const chainId = ChainId.Arbitrum
const { eth } = QuoteTokens
const eth2xBtc = getTokenByChainAndSymbol(ChainId.Arbitrum, 'ETH2xBTC')
const eth2xBtc = getTokenByChainAndSymbol(chainId, 'ETH2xBTC')
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(3, getTestRpcProvider(ChainId.Arbitrum))
factory = getArbitrumTestFactory(signer)
factory = getTestFactoryZeroEx(3, chainId)
})

test('can mint with ETH', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/tests/arbitrum/eth3x.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { ChainId } from 'constants/chains'
import {
QuoteTokens,
type TestFactory,
getArbitrumTestFactory,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
wei,
} from 'tests/utils'

Expand All @@ -16,8 +14,7 @@ const { eth } = QuoteTokens
describe('ETH3X (Arbitrum)', () => {
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(2, getTestRpcProvider(chainId))
factory = getArbitrumTestFactory(signer)
factory = getTestFactoryZeroEx(2, chainId)
})

test.only('can mint with ETH', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/tests/arbitrum/ibtc1x.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { getTokenByChainAndSymbol } from '@indexcoop/tokenlists'
import { ChainId } from 'constants/chains'
import {
getTestFactoryZeroEx,
QuoteTokens,
type TestFactory,
getArbitrumTestFactory,
getSignerAccount,
getTestRpcProvider,
wei,
} from 'tests/utils'

Expand All @@ -16,8 +14,7 @@ const { eth } = QuoteTokens
describe('iBTC1X (Arbitrum)', () => {
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(4, getTestRpcProvider(chainId))
factory = getArbitrumTestFactory(signer)
factory = getTestFactoryZeroEx(4, chainId)
})

test('can mint with ETH', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/tests/arbitrum/ieth1x.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { getTokenByChainAndSymbol } from '@indexcoop/tokenlists'
import { ChainId } from 'constants/chains'
import {
getTestFactoryZeroEx,
QuoteTokens,
type TestFactory,
getArbitrumTestFactory,
getSignerAccount,
getTestRpcProvider,
wei,
} from 'tests/utils'

Expand All @@ -16,8 +14,7 @@ const { eth } = QuoteTokens
describe('iETH1X (Arbitrum)', () => {
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(1, getTestRpcProvider(chainId))
factory = getArbitrumTestFactory(signer)
factory = getTestFactoryZeroEx(1, chainId)
})

test('can mint with ETH', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/tests/base/eth2x.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { ChainId } from 'constants/chains'
import {
QuoteTokens,
type TestFactory,
getBaseTestFactory,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
wei,
} from 'tests/utils'

Expand All @@ -15,8 +13,7 @@ describe('ETH2X (Base)', () => {
const eth2x = getTokenByChainAndSymbol(chainId, 'ETH2X')
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(0, getTestRpcProvider(chainId))
factory = getBaseTestFactory(signer)
factory = getTestFactoryZeroEx(0, chainId)
})

test('can mint with ETH', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/tests/base/eth3x.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import { ChainId } from 'constants/chains'
import {
QuoteTokens,
type TestFactory,
getBaseTestFactory,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
wei,
} from 'tests/utils'

Expand All @@ -15,8 +13,7 @@ describe('ETH3X (Base)', () => {
const eth3x = getTokenByChainAndSymbol(chainId, 'ETH3X')
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(2, getTestRpcProvider(chainId))
factory = getBaseTestFactory(signer)
factory = getTestFactoryZeroEx(2, chainId)
})

test('can mint with ETH', async () => {
Expand Down
14 changes: 5 additions & 9 deletions src/tests/btc2x.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { getTokenByChainAndSymbol } from '@indexcoop/tokenlists'
import {
QuoteTokens,
getMainnetTestFactory,
getMainnetTestFactoryUniswap,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
wei,
} from './utils'

Expand All @@ -15,10 +13,8 @@ describe('BTC2X (mainnet)', () => {
const btc2x = getTokenByChainAndSymbol(chainId, 'BTC2X')
const { eth } = QuoteTokens
let factory: TestFactory
const provider = getTestRpcProvider(chainId)
const signer = getSignerAccount(4, provider)
beforeEach(async () => {
factory = getMainnetTestFactory(signer)
factory = getTestFactoryZeroEx(4)
})

test('can mint with ETH', async () => {
Expand All @@ -33,15 +29,15 @@ describe('BTC2X (mainnet)', () => {
})

test.skip('can mint with ETH (IndexSwapQuoteProvider)', async () => {
const factory = getMainnetTestFactoryUniswap(signer)
await factory.fetchQuote({
const uniFactory = getMainnetTestFactoryUniswap(factory.getSigner())
await uniFactory.fetchQuote({
isMinting: true,
inputToken: eth,
outputToken: btc2x,
indexTokenAmount: wei('1').toString(),
slippage: 0.5,
})
await factory.executeTx()
await uniFactory.executeTx()
})

test.skip('can redeem with ETH', async () => {
Expand Down
7 changes: 2 additions & 5 deletions src/tests/dseth/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import {
QuoteTokens,
type TestFactory,
addLiquidityToLido,
getMainnetTestFactory,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
swapExactInput,
transferFromWhale,
wei,
Expand All @@ -19,8 +17,7 @@ describe('dsETH (mainnet)', () => {
const { eth, steth, usdc, weth } = QuoteTokens
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(3, getTestRpcProvider(1))
factory = getMainnetTestFactory(signer)
factory = getTestFactoryZeroEx(3)
})

test.only('minting with ETH', async () => {
Expand Down
19 changes: 8 additions & 11 deletions src/tests/eth2x.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@ import { getTokenByChainAndSymbol } from '@indexcoop/tokenlists'
import {
QuoteTokens,
type TestFactory,
getMainnetTestFactory,
getTestFactoryZeroEx,
getMainnetTestFactoryUniswap,
getSignerAccount,
getTestRpcProvider,
wei,
} from './utils'

describe('ETH2X (mainnet)', () => {
const chainId = 1
const { eth } = QuoteTokens
const eth2x = getTokenByChainAndSymbol(chainId, 'ETH2X')
const signer = getSignerAccount(4, getTestRpcProvider(chainId))
let factory: TestFactory
beforeEach(async () => {
factory = getMainnetTestFactory(signer)
factory = getTestFactoryZeroEx(4)
})

test.only('can mint with ETH', async () => {
Expand All @@ -31,15 +28,15 @@ describe('ETH2X (mainnet)', () => {
})

test.skip('can mint with ETH (IndexSwapQuoteProvider)', async () => {
const factory = getMainnetTestFactoryUniswap(signer)
await factory.fetchQuote({
const uniFactory = getMainnetTestFactoryUniswap(factory.getSigner())
await uniFactory.fetchQuote({
isMinting: true,
inputToken: eth,
outputToken: eth2x,
indexTokenAmount: wei('1').toString(),
slippage: 0.5,
})
await factory.executeTx()
await uniFactory.executeTx()
})

test('can redeem with ETH', async () => {
Expand All @@ -54,14 +51,14 @@ describe('ETH2X (mainnet)', () => {
})

test.skip('can redeem with ETH (IndexSwapQuoteProvider)', async () => {
const factory = getMainnetTestFactoryUniswap(signer)
await factory.fetchQuote({
const uniFactory = getMainnetTestFactoryUniswap(factory.getSigner())
await uniFactory.fetchQuote({
isMinting: false,
inputToken: eth2x,
outputToken: eth,
indexTokenAmount: wei('1').toString(),
slippage: 0.5,
})
await factory.executeTx()
await uniFactory.executeTx()
})
})
7 changes: 2 additions & 5 deletions src/tests/hyeth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import {
QuoteTokens,
type TestFactory,
balanceOf,
getMainnetTestFactory,
getSignerAccount,
getTestRpcProvider,
getTestFactoryZeroEx,
transferFromWhale,
wei,
wrapETH,
Expand All @@ -18,8 +16,7 @@ describe('hyETH', () => {
const usdc = getTokenByChainAndSymbol(chainId, 'USDC')
let factory: TestFactory
beforeEach(async () => {
const signer = getSignerAccount(4, getTestRpcProvider(chainId))
factory = getMainnetTestFactory(signer)
factory = getTestFactoryZeroEx(4)
})

test('can mint with ETH', async () => {
Expand Down
Loading
Loading