import { Fixture } from 'ethereum-waffle'
import { ethers, waffle } from 'hardhat'
import { clRouterFixture } from './externalFixtures'
import { constants, Contract } from 'ethers'
import { ISAMB, MockTimeSwapRouter02, TestERC20 } from '../../typechain'

const completeFixture: Fixture<{
  samb: ISAMB
  factoryClassic: Contract
  factory: Contract
  router: MockTimeSwapRouter02
  nft: Contract
  tokens: [TestERC20, TestERC20, TestERC20]
}> = async ([wallet], provider) => {
  const { samb, factoryClassic, factory, nft, router } = await clRouterFixture([wallet], provider)

  const tokenFactory = await ethers.getContractFactory('TestERC20')
  const tokens: [TestERC20, TestERC20, TestERC20] = [
    (await tokenFactory.deploy(constants.MaxUint256.div(2))) as TestERC20, // do not use maxu256 to avoid overflowing
    (await tokenFactory.deploy(constants.MaxUint256.div(2))) as TestERC20,
    (await tokenFactory.deploy(constants.MaxUint256.div(2))) as TestERC20,
  ]

  tokens.sort((a, b) => (a.address.toLowerCase() < b.address.toLowerCase() ? -1 : 1))

  return {
    samb,
    factoryClassic,
    factory,
    router,
    tokens,
    nft,
  }
}

export default completeFixture
