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

test: remove obsolete tests #79

Merged
merged 10 commits into from
Jul 29, 2024
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
12 changes: 1 addition & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,8 @@ jobs:
- run: npm run test:builders
- run: npm run test:quotes
- run: npm run test:hyeth
- run: npm run test:rwa
- run: npm run test:btc2x
# skipping as currently no liquidity for sfrETH
# - run: npm run test:dseth
# - run: npm run test:eth2x
# - run: npm run test:gtceth
# - run: npm run test:iceth
# - run: npm run test:icreth
# - run: npm run test:cdeti
# run last - as it alters the block number
# skip as it can't be minted or redeemed with 0x
# - run: npm run test:eth2xfli
- run: npm run test:eth2x
publish:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/main' }}
Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,10 @@
"test:quotes": "npm test src/quote/",
"test:utils": "npm test src/utils",
"test:btc2x": "npm test src/tests/btc2x.test.ts",
"test:cdeti": "npm test src/tests/cdeti",
"test:dseth": "npm test src/tests/dseth",
"test:eth2x": "npm test src/tests/eth2x.test.ts",
"test:eth2xfli": "npm test src/tests/eth2xfli",
"test:gtceth": "npm test src/tests/gtceth",
"test:hyeth": "npm test src/tests/hyeth.test.ts",
"test:rwa": "npm test src/tests/rwa.presale.test.ts",
"test:iceth": "npm test src/tests/iceth",
"test:icreth": "npm test src/tests/icreth",
"test:watch": "jest --watch"
},
"keywords": [
Expand Down
5 changes: 0 additions & 5 deletions src/constants/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ export const InterestCompoundingETHIndex: Token = {
address: '0x7C07F7aBe10CE8e33DC6C5aD68FE033085256A84',
}

export const LeveragedrEthStakingYield: Token = {
symbol: 'icRETH',
address: '0xcCdAE12162566E3f29fEfA7Bf7F5b24C644493b5',
}

export const MetaverseIndex: Token = {
address: '0x72e364F2ABdC788b7E918bc238B21f109Cd634D7',
addressPolygon: '0xfe712251173A2cd5F5bE2B46Bb528328EA3565E1',
Expand Down
39 changes: 2 additions & 37 deletions src/flashmint/builders/leveraged.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { BigNumber } from '@ethersproject/bignumber'

import {
ExchangeIssuanceLeveragedMainnetAddress,
FlashMintLeveragedAddress,
} from 'constants/contracts'
import { ExchangeIssuanceLeveragedMainnetAddress } from 'constants/contracts'
import {
collateralDebtSwapData,
debtCollateralSwapData,
Expand All @@ -26,7 +23,7 @@ const chainId = 1
const provider = LocalhostProvider
const rpcUrl = LocalhostProviderUrl

const { iceth, icreth, reth, usdc } = QuoteTokens
const { iceth, usdc } = QuoteTokens

const eth = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'
const indexToken = iceth
Expand Down Expand Up @@ -175,38 +172,6 @@ describe('LeveragedTransactionBuilder()', () => {
expect(tx.value).toEqual(buildRequest.inputOutputTokenAmount)
})

test('returns a tx for minting icRETH (rETH)', async () => {
const isMinting = true
const buildRequest = {
isMinting,
indexToken: icreth.address,
indexTokenSymbol: icreth.symbol,
inputOutputToken: reth.address,
inputOutputTokenSymbol: reth.symbol,
indexTokenAmount: wei(1),
inputOutputTokenAmount: BigNumber.from(194235680),
swapDataDebtCollateral: isMinting
? collateralDebtSwapData['icETH']
: debtCollateralSwapData['icETH'],
swapDataPaymentToken: isMinting
? inputSwapData[indexToken.symbol]['ETH']
: outputSwapData[indexToken.symbol]['ETH'],
}
const refTx = await contract.populateTransaction.issueExactSetFromERC20(
buildRequest.indexToken,
buildRequest.indexTokenAmount,
buildRequest.inputOutputToken,
buildRequest.inputOutputTokenAmount,
buildRequest.swapDataDebtCollateral,
buildRequest.swapDataPaymentToken
)
const builder = new LeveragedTransactionBuilder(rpcUrl)
const tx = await builder.build(buildRequest)
if (!tx) fail()
expect(tx.to).toBe(FlashMintLeveragedAddress)
expect(tx.data).toEqual(refTx.data)
})

test('returns a tx for redeeming dsETH (ERC20)', async () => {
const buildRequest = createBuildRequest(false)
const refTx = await contract.populateTransaction.redeemExactSetForERC20(
Expand Down
38 changes: 2 additions & 36 deletions src/quote/provider/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import { ChainId } from 'constants/chains'
import {
FlashMintHyEthAddress,
FlashMintZeroExMainnetAddress,
} from 'constants/contracts'
import { FlashMintHyEthAddress } from 'constants/contracts'
import { IndexCoopEthereum2xIndex } from 'constants/tokens'
import {
getFlashMintLeveragedContractForToken,
Expand Down Expand Up @@ -31,7 +28,7 @@ const rpcUrl = LocalhostProviderUrl
const provider = LocalhostProvider
const zeroexSwapQuoteProvider = IndexZeroExSwapQuoteProvider

const { cdeti, dseth, eth, eth2x, hyeth, iceth, usdc } = QuoteTokens
const { dseth, eth, eth2x, hyeth, iceth, usdc } = QuoteTokens

describe('FlashMintQuoteProvider()', () => {
test('throws if token is unsupported', async () => {
Expand All @@ -57,37 +54,6 @@ describe('FlashMintQuoteProvider()', () => {
)
})

test('returns a quote for minting cdETI', async () => {
const request: FlashMintQuoteRequest = {
isMinting: true,
inputToken: eth,
outputToken: cdeti,
indexTokenAmount: wei(1),
slippage: 0.1,
}
const quoteProvider = new FlashMintQuoteProvider(
rpcUrl,
zeroexSwapQuoteProvider
)
const quote = await quoteProvider.getQuote(request)
if (!quote) fail()
const chainId = (await provider.getNetwork()).chainId
expect(quote.chainId).toEqual(chainId)
expect(quote.contractType).toEqual(FlashMintContractType.zeroEx)
expect(quote.contract).toEqual(FlashMintZeroExMainnetAddress)
expect(quote.isMinting).toEqual(request.isMinting)
expect(quote.inputToken).toEqual(request.inputToken)
expect(quote.outputToken).toEqual(request.outputToken)
expect(quote.inputAmount).toEqual(quote.inputOutputAmount)
expect(quote.outputAmount).toEqual(request.indexTokenAmount)
expect(quote.indexTokenAmount).toEqual(request.indexTokenAmount)
expect(quote.inputOutputAmount.gt(0)).toBe(true)
expect(quote.slippage).toEqual(request.slippage)
expect(quote.tx).not.toBeNull()
expect(quote.tx.to).toBe(FlashMintZeroExMainnetAddress)
expect(quote.tx.data?.length).toBeGreaterThan(0)
})

test.skip('returns a quote for minting dsETH', async () => {
const inputToken = usdc
const outputToken = dseth
Expand Down
36 changes: 0 additions & 36 deletions src/quote/provider/utils.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { ChainId } from 'constants/chains'
import {
BanklessBEDIndex,
BTC2xFlexibleLeverageIndex,
CoinDeskEthTrendIndex,
DefiPulseIndex,
DiversifiedStakedETHIndex,
ETH2xFlexibleLeverageIndex,
Expand All @@ -15,9 +13,7 @@ import {
IndexCoopInverseBitcoinIndex,
IndexCoopInverseEthereumIndex,
InterestCompoundingETHIndex,
LeveragedrEthStakingYield,
MetaverseIndex,
RealWorldAssetIndex,
} from 'constants/tokens'

import { FlashMintContractType } from './'
Expand Down Expand Up @@ -65,14 +61,6 @@ describe('getContractType()', () => {
expect(contractType).toBe(FlashMintContractType.zeroEx)
})

test('returns correct contract type for cdETI', async () => {
const contractType = getContractType(
CoinDeskEthTrendIndex.symbol,
ChainId.Mainnet
)
expect(contractType).toBe(FlashMintContractType.zeroEx)
})

test('returns correct contract type for DPI', async () => {
const contractType = getContractType(DefiPulseIndex.symbol, ChainId.Mainnet)
expect(contractType).toBe(FlashMintContractType.zeroEx)
Expand All @@ -99,14 +87,6 @@ describe('getContractType()', () => {
expect(contractType).toBe(FlashMintContractType.zeroEx)
})

test('returns correct contract type for BTC2x-FLI', async () => {
const contractType = getContractType(
BTC2xFlexibleLeverageIndex.symbol,
ChainId.Mainnet
)
expect(contractType).toBe(FlashMintContractType.leveraged)
})

test('returns correct contract type for ETH2x-FLI', async () => {
const contractType = getContractType(
ETH2xFlexibleLeverageIndex.symbol,
Expand Down Expand Up @@ -146,20 +126,4 @@ describe('getContractType()', () => {
)
expect(contractType).toBe(FlashMintContractType.leveraged)
})

test('returns correct contract type for icRETH', async () => {
const contractType = getContractType(
LeveragedrEthStakingYield.symbol,
ChainId.Mainnet
)
expect(contractType).toBe(FlashMintContractType.leveraged)
})

test('returns correct contract type for RWA', async () => {
const contractType = getContractType(
RealWorldAssetIndex.symbol,
ChainId.Mainnet
)
expect(contractType).toBe(FlashMintContractType.zeroEx)
})
})
4 changes: 1 addition & 3 deletions src/quote/provider/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
IndexCoopInverseBitcoinIndex,
IndexCoopInverseEthereumIndex,
InterestCompoundingETHIndex,
LeveragedrEthStakingYield,
MetaverseIndex,
RealWorldAssetIndex,
} from 'constants/tokens'
Expand Down Expand Up @@ -56,8 +55,7 @@ export function getContractType(
token === ETH2xFlexibleLeverageIndex.symbol ||
token === IndexCoopBitcoin2xIndex.symbol ||
token === IndexCoopEthereum2xIndex.symbol ||
token === InterestCompoundingETHIndex.symbol ||
token === LeveragedrEthStakingYield.symbol
token === InterestCompoundingETHIndex.symbol
)
return FlashMintContractType.leveraged
return null
Expand Down
12 changes: 5 additions & 7 deletions src/quote/swap/adapters/adapter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ETH, stETH } from 'constants/tokens'
import { EthAddress } from 'constants/addresses'
import { stETH } from 'constants/tokens'
import { CurveSwapQuoteProvider } from 'quote/swap/adapters/curve'
import { UniswapSwapQuoteProvider } from 'quote/swap/adapters/uniswap'
import {
Expand All @@ -17,15 +18,12 @@ export class IndexSwapQuoteProvider implements SwapQuoteProvider {
let inputToken = request.inputToken
let outputToken = request.outputToken
if (inputToken === 'ETH') {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
inputToken = ETH.address!
inputToken = EthAddress
}
if (outputToken === 'ETH') {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
outputToken = ETH.address!
outputToken = EthAddress
}
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const eth = ETH.address!
const eth = EthAddress
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const stEth = stETH.address!
const isEth =
Expand Down
52 changes: 0 additions & 52 deletions src/tests/btc2xfli/index.test.ts

This file was deleted.

Loading