Skip to content

Commit

Permalink
add tests and ci
Browse files Browse the repository at this point in the history
  • Loading branch information
janndriessen committed Feb 14, 2024
1 parent 28206f1 commit fcdabed
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- run: npm ci
- run: npm run lint
- run: npm run build --if-present
- run: npm run hardhat & npm run test:btc2x
- run: npm run hardhat & npm run test:cdeti
- run: npm run hardhat & npm run test:dseth
- run: npm run hardhat & npm run test:eth2x
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"lint": "prettier -c . && eslint ./src",
"lint:fix": "prettier -w . && eslint ./src --fix",
"test": "jest",
"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",
Expand Down
2 changes: 2 additions & 0 deletions src/quote/indexQuoteProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DiversifiedStakedETHIndex,
ETH2xFlexibleLeverageIndex,
GitcoinStakedETHIndex,
IndexCoopBitcoin2xIndex,
IndexCoopEthereum2xIndex,
InterestCompoundingETHIndex,
LeveragedrEthStakingYield,
Expand Down Expand Up @@ -178,6 +179,7 @@ function getContractType(token: string): FlashMintContractType | null {
if (
token === BTC2xFlexibleLeverageIndex.symbol ||
token === ETH2xFlexibleLeverageIndex.symbol ||
token === IndexCoopBitcoin2xIndex.symbol ||
token === IndexCoopEthereum2xIndex.symbol ||
token === InterestCompoundingETHIndex.symbol ||
token === LeveragedrEthStakingYield.symbol
Expand Down
42 changes: 42 additions & 0 deletions src/tests/btc2x.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import {
LocalhostProvider,
QuoteTokens,
SignerAccount4,
TestFactory,
wei,
ZeroExApiSwapQuote,
} from './utils'

const { btc2x, eth } = QuoteTokens
const zeroExApi = ZeroExApiSwapQuote

describe('BTC2X (mainnet)', () => {
let factory: TestFactory
beforeEach(async () => {
const provider = LocalhostProvider
const signer = SignerAccount4
factory = new TestFactory(provider, signer, zeroExApi)
})

test('can mint with ETH', async () => {
await factory.fetchQuote({
isMinting: true,
inputToken: eth,
outputToken: btc2x,
indexTokenAmount: wei('1'),
slippage: 0.5,
})
await factory.executeTx()
})

test('can redeem with ETH', async () => {
await factory.fetchQuote({
isMinting: false,
inputToken: btc2x,
outputToken: eth,
indexTokenAmount: wei('1'),
slippage: 0.5,
})
await factory.executeTx()
})
})
8 changes: 8 additions & 0 deletions src/tests/utils/quoteTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ETH,
ETH2xFlexibleLeverageIndex,
GitcoinStakedETHIndex,
IndexCoopBitcoin2xIndex,
IndexCoopEthereum2xIndex,
InterestCompoundingETHIndex,
LeveragedrEthStakingYield,
Expand All @@ -22,6 +23,12 @@ import {
} from 'constants/tokens'
import { QuoteToken } from 'quote/quoteToken'

const btc2x: QuoteToken = {
address: IndexCoopBitcoin2xIndex.address!,
decimals: 18,
symbol: IndexCoopBitcoin2xIndex.symbol,
}

const btc2xfli: QuoteToken = {
address: BTC2xFlexibleLeverageIndex.address!,
decimals: 18,
Expand Down Expand Up @@ -136,6 +143,7 @@ const wseth: QuoteToken = {
}

export const QuoteTokens = {
btc2x,
btc2xfli,
cdeti,
dai,
Expand Down

0 comments on commit fcdabed

Please sign in to comment.