From 664bef4d36e4308466623e8344454047baa2a778 Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 19 Jun 2024 15:07:35 +0200 Subject: [PATCH 1/7] feat: add rwa --- src/constants/tokens.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/constants/tokens.ts b/src/constants/tokens.ts index 1d8ac681..88b1c2e9 100644 --- a/src/constants/tokens.ts +++ b/src/constants/tokens.ts @@ -97,6 +97,11 @@ export const MetaverseIndex: Token = { symbol: 'MVI', } +export const RealWorldAssetIndex: Token = { + address: '0x7f5f1A44dd6f88cCb54Fe879e144dF644A4aDa24', + symbol: 'RWA', +} + // Other export const DAI: Token = { From 57ca76c9a0cf471a56b958e1be9883cd14e90e74 Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 19 Jun 2024 15:08:43 +0200 Subject: [PATCH 2/7] feat: add issuance for rwa --- src/utils/issuanceModules.test.ts | 8 ++++++++ src/utils/issuanceModules.ts | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/utils/issuanceModules.test.ts b/src/utils/issuanceModules.test.ts index fcf6dfe6..ddd92827 100644 --- a/src/utils/issuanceModules.test.ts +++ b/src/utils/issuanceModules.test.ts @@ -24,6 +24,7 @@ import { IndexCoopBitcoin2xIndex, IndexCoopBitcoin3xIndex, HighYieldETHIndex, + RealWorldAssetIndex, } from 'constants/tokens' import { getIssuanceModule } from './issuanceModules' @@ -78,6 +79,13 @@ describe('getIssuanceModule() - Mainnet - IndexProtocol', () => { expect(issuanceModule.isDebtIssuance).toBe(true) }) + test('returns debt issuance module v2 for RWA', async () => { + const expectedModule = IndexDebtIssuanceModuleV2Address_v2 + const issuanceModule = getIssuanceModule(RealWorldAssetIndex.symbol) + expect(issuanceModule.address).toEqual(expectedModule) + expect(issuanceModule.isDebtIssuance).toBe(true) + }) + test('returns debt issuance module v2 for wsETH2', async () => { const expectedModule = IndexDebtIssuanceModuleV2Address const issuanceModule = getIssuanceModule(wsETH2.symbol) diff --git a/src/utils/issuanceModules.ts b/src/utils/issuanceModules.ts index 8461a6b3..44b62f8b 100644 --- a/src/utils/issuanceModules.ts +++ b/src/utils/issuanceModules.ts @@ -20,6 +20,7 @@ import { IndexCoopEthereum2xIndex, IndexCoopBitcoin2xIndex, HighYieldETHIndex, + RealWorldAssetIndex, } from '../constants/tokens' export interface IssuanceModule { @@ -53,6 +54,7 @@ export function getIssuanceModule( case IndexCoopBitcoin2xIndex.symbol: case IndexCoopEthereum2xIndex.symbol: case LeveragedrEthStakingYield.symbol: + case RealWorldAssetIndex.symbol: return { address: IndexDebtIssuanceModuleV2Address_v2, isDebtIssuance: true, From 69fc54c51e32ae1df449b178bc2224cabcda36c4 Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 19 Jun 2024 15:11:44 +0200 Subject: [PATCH 3/7] feat: add contract --- src/utils/contracts.test.ts | 19 +++++++++++++++++++ src/utils/contracts.ts | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/utils/contracts.test.ts b/src/utils/contracts.test.ts index d9cc3317..b3e18a16 100644 --- a/src/utils/contracts.test.ts +++ b/src/utils/contracts.test.ts @@ -25,6 +25,7 @@ import { IndexCoopBitcoin3xIndex, IndexCoopInverseEthereumIndex, IndexCoopInverseBitcoinIndex, + RealWorldAssetIndex, } from 'constants/tokens' import { @@ -459,3 +460,21 @@ describe('iETH1x', () => { expect(contract.functions.issueExactSetFromETH).toBeDefined() }) }) + +describe('RWA', () => { + test('return correct contract for token - arbitrum', async () => { + const expectedAddress = FlashMintZeroExMainnetAddress + const contract = getFlashMintZeroExContractForToken( + RealWorldAssetIndex.symbol, + undefined, + ChainId.Mainnet + ) + expect(contract.address).toEqual(expectedAddress) + expect(contract.functions.getRequiredIssuanceComponents).toBeDefined() + expect(contract.functions.getRequiredRedemptionComponents).toBeDefined() + expect(contract.functions.issueExactSetFromETH).toBeDefined() + expect(contract.functions.issueExactSetFromToken).toBeDefined() + expect(contract.functions.redeemExactSetForETH).toBeDefined() + expect(contract.functions.redeemExactSetForToken).toBeDefined() + }) +}) diff --git a/src/utils/contracts.ts b/src/utils/contracts.ts index 87afaece..e81ef05a 100644 --- a/src/utils/contracts.ts +++ b/src/utils/contracts.ts @@ -35,6 +35,7 @@ import { IndexCoopEthereum3xIndex, IndexCoopInverseBitcoinIndex, IndexCoopInverseEthereumIndex, + RealWorldAssetIndex, } from '../constants/tokens' export function getExchangeIssuanceLeveragedContractAddress( @@ -217,6 +218,7 @@ export const getFlashMintZeroExContractForToken = ( case CoinDeskEthTrendIndex.symbol: case DiversifiedStakedETHIndex.symbol: case GitcoinStakedETHIndex.symbol: + case RealWorldAssetIndex.symbol: case wsETH2.symbol: return new Contract( FlashMintZeroExMainnetAddress, From 4ca12bb445fd5c9de02da906849832a2e6058232 Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 19 Jun 2024 15:27:24 +0200 Subject: [PATCH 4/7] feat: update contract type utils --- src/quote/provider/utils.test.ts | 9 +++++++++ src/quote/provider/utils.ts | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/quote/provider/utils.test.ts b/src/quote/provider/utils.test.ts index ec5f418f..3f9126ce 100644 --- a/src/quote/provider/utils.test.ts +++ b/src/quote/provider/utils.test.ts @@ -17,6 +17,7 @@ import { InterestCompoundingETHIndex, LeveragedrEthStakingYield, MetaverseIndex, + RealWorldAssetIndex, } from 'constants/tokens' import { FlashMintContractType } from './' @@ -153,4 +154,12 @@ describe('getContractType()', () => { ) 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) + }) }) diff --git a/src/quote/provider/utils.ts b/src/quote/provider/utils.ts index 70b41bf8..b3f413c1 100644 --- a/src/quote/provider/utils.ts +++ b/src/quote/provider/utils.ts @@ -17,6 +17,7 @@ import { InterestCompoundingETHIndex, LeveragedrEthStakingYield, MetaverseIndex, + RealWorldAssetIndex, } from 'constants/tokens' import { FlashMintContractType } from './index' @@ -46,7 +47,8 @@ export function getContractType( token === DefiPulseIndex.symbol || token === DiversifiedStakedETHIndex.symbol || token === GitcoinStakedETHIndex.symbol || - token === MetaverseIndex.symbol + token === MetaverseIndex.symbol || + token === RealWorldAssetIndex.symbol ) return FlashMintContractType.zeroEx if ( From 15e48c6889ca55e528e6e85ca9c0b5769ef66736 Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 19 Jun 2024 15:39:13 +0200 Subject: [PATCH 5/7] test: add test for rwa presale --- src/tests/rwa.presale.test.ts | 73 ++++++++++++++++++++++++++++++++++ src/tests/utils/quoteTokens.ts | 9 +++++ 2 files changed, 82 insertions(+) create mode 100644 src/tests/rwa.presale.test.ts diff --git a/src/tests/rwa.presale.test.ts b/src/tests/rwa.presale.test.ts new file mode 100644 index 00000000..469a8735 --- /dev/null +++ b/src/tests/rwa.presale.test.ts @@ -0,0 +1,73 @@ +import { + getMainnetTestFactory, + QuoteTokens, + SignerAccount4, + TestFactory, + transferFromWhale, + wei, + wrapETH, +} from './utils' + +const { eth, rwa, usdc, weth } = QuoteTokens + +describe('RWA presale', () => { + const indexToken = rwa + const signer = SignerAccount4 + let factory: TestFactory + beforeEach(async () => { + factory = getMainnetTestFactory(signer) + }) + + test('can mint with ETH', async () => { + await factory.fetchQuote({ + isMinting: true, + inputToken: eth, + outputToken: indexToken, + indexTokenAmount: wei('1'), + slippage: 0.5, + }) + await factory.executeTx() + }) + + test('can mint with WETH', async () => { + const quote = await factory.fetchQuote({ + isMinting: true, + inputToken: weth, + outputToken: indexToken, + indexTokenAmount: wei('1'), + slippage: 0.5, + }) + await wrapETH(quote.inputAmount, signer) + await factory.executeTx() + }) + + test('can mint with USDC', async () => { + const quote = await factory.fetchQuote({ + isMinting: true, + inputToken: usdc, + outputToken: indexToken, + indexTokenAmount: wei('1'), + slippage: 0.5, + }) + const whale = '0x7713974908Be4BEd47172370115e8b1219F4A5f0' + await transferFromWhale( + whale, + factory.getSigner().address, + wei('10000', quote.inputToken.decimals), + quote.inputToken.address, + factory.getProvider() + ) + await factory.executeTx() + }) + + test('can redeem to USDC', async () => { + await factory.fetchQuote({ + isMinting: false, + inputToken: indexToken, + outputToken: usdc, + indexTokenAmount: wei('1'), + slippage: 0.5, + }) + await factory.executeTx() + }) +}) diff --git a/src/tests/utils/quoteTokens.ts b/src/tests/utils/quoteTokens.ts index b39d3dce..b9e058c0 100644 --- a/src/tests/utils/quoteTokens.ts +++ b/src/tests/utils/quoteTokens.ts @@ -15,6 +15,7 @@ import { LeveragedrEthStakingYield, MetaverseIndex, RETH, + RealWorldAssetIndex, USDC, USDT, WETH, @@ -113,6 +114,13 @@ const reth: QuoteToken = { decimals: 18, symbol: RETH.symbol, } + +const rwa: QuoteToken = { + address: RealWorldAssetIndex.address!, + decimals: 18, + symbol: RealWorldAssetIndex.symbol, +} + const seth2: QuoteToken = { address: sETH2.address!, decimals: 18, @@ -165,6 +173,7 @@ export const QuoteTokens = { icreth, mvi, reth, + rwa, seth2, steth, usdc, From 06005a914b0b9083c1d133f9a6f469fe87420296 Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 19 Jun 2024 15:43:53 +0200 Subject: [PATCH 6/7] ci: add rwa tests --- .github/workflows/publish.yml | 1 + package.json | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cf196bfc..4afdeddd 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -41,6 +41,7 @@ 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 - run: npm run test:cdeti - run: npm run test:dseth diff --git a/package.json b/package.json index 26388945..a64ab554 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "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" From 0d48fd58c814f3ea869b088df9283646b0d21cc2 Mon Sep 17 00:00:00 2001 From: JD Date: Wed, 19 Jun 2024 15:55:32 +0200 Subject: [PATCH 7/7] ci: temp disable slow tests --- .github/workflows/publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4afdeddd..b51e4d9b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -45,9 +45,9 @@ jobs: - run: npm run test:btc2x - run: npm run test:cdeti - run: npm run test:dseth - - run: npm run test:eth2x - - run: npm run test:gtceth - - run: npm run test:iceth + # - run: npm run test:eth2x + # - run: npm run test:gtceth + # - run: npm run test:iceth # - run: npm run test:icreth # run last - as it alters the block number # skip as it can't be minted or redeemed with 0x