Skip to content

Commit

Permalink
Merge pull request #55 from IndexCoop/feat/update-debt-issuance
Browse files Browse the repository at this point in the history
feat: update debt issuance
  • Loading branch information
janndriessen authored May 23, 2024
2 parents 608ea0c + 90495a0 commit 001abf7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/constants/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Index Protocol

export const FlashMintLeveragedAddress =
'0x45c00508C14601fd1C1e296eB3C0e3eEEdCa45D0'

export const FlashMintLeveragedExtendedAddress =
'0xC62e39d1f5232f154b7ccD3C6234A9c893bf9563'

export const FlashMintLeveragedForCompoundAddress =
'0xeA716Ed94964Ed0126Fb2fA3b546eD7F209cC2b8'

Expand All @@ -19,6 +15,12 @@ export const IndexDebtIssuanceModuleV2Address =
export const IndexDebtIssuanceModuleV2Address_v2 =
'0x04b59F9F09750C044D7CfbC177561E409085f0f3'

// Arbitrum
export const FlashMintLeveragedExtendedAddress =
'0xc6b3B4624941287bB7BdD8255302c1b337e42194'
export const IndexDebtIssuanceModuleV3Address =
'0x4ac26c26116fa976352b70700af58bc2442489d8'

// Set Protocol
export const BasicIssuanceModuleAddress =
'0xd8EF3cACe8b4907117a45B0b125c68560532F94D'
Expand Down
24 changes: 24 additions & 0 deletions src/utils/issuanceModules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DebtIssuanceModuleV2Address,
IndexDebtIssuanceModuleV2Address,
IndexDebtIssuanceModuleV2Address_v2,
IndexDebtIssuanceModuleV3Address,
} from 'constants/contracts'
import {
BanklessBEDIndex,
Expand All @@ -21,6 +22,7 @@ import {
CoinDeskEthTrendIndex,
IndexCoopEthereum2xIndex,
IndexCoopBitcoin2xIndex,
IndexCoopBitcoin3xIndex,
} from 'constants/tokens'

import { getIssuanceModule } from './issuanceModules'
Expand Down Expand Up @@ -120,6 +122,28 @@ describe('getIssuanceModule() - Mainnet - SetProtocol', () => {
})
})

describe('getIssuanceModule() - Arbitrum', () => {
test('returns debt issuance module v3 for BTC2X on Arbitrum', async () => {
const expectedModule = IndexDebtIssuanceModuleV3Address
const issuanceModule = getIssuanceModule(
IndexCoopBitcoin2xIndex.symbol,
ChainId.Arbitrum
)
expect(issuanceModule.address).toEqual(expectedModule)
expect(issuanceModule.isDebtIssuance).toBe(true)
})

test('returns debt issuance module v3 for BTC3X', async () => {
const expectedModule = IndexDebtIssuanceModuleV3Address
const issuanceModule = getIssuanceModule(
IndexCoopBitcoin3xIndex.symbol,
ChainId.Arbitrum
)
expect(issuanceModule.address).toEqual(expectedModule)
expect(issuanceModule.isDebtIssuance).toBe(true)
})
})

describe('getIssuanceModule() - Polygon', () => {
test('returns basic issuance module for any other index', async () => {
const expectedAddress = BasicIssuanceModulePolygonAddress
Expand Down
8 changes: 7 additions & 1 deletion src/utils/issuanceModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
DebtIssuanceModuleV2Address,
IndexDebtIssuanceModuleV2Address,
IndexDebtIssuanceModuleV2Address_v2,
IndexDebtIssuanceModuleV3Address,
} from '../constants/contracts'
import {
BTC2xFlexibleLeverageIndex,
Expand All @@ -29,12 +30,17 @@ export function getIssuanceModule(
tokenSymbol: string,
chainId: number = ChainId.Mainnet
): IssuanceModule {
if (chainId === ChainId.Arbitrum) {
return {
address: IndexDebtIssuanceModuleV3Address,
isDebtIssuance: true,
}
}
if (chainId === ChainId.Polygon)
return {
address: BasicIssuanceModulePolygonAddress,
isDebtIssuance: false,
}

// Mainnet
switch (tokenSymbol) {
case BTC2xFlexibleLeverageIndex.symbol:
Expand Down

0 comments on commit 001abf7

Please sign in to comment.